How to fetch single row from database in php codeigniter?
In this post we will give you information about How to fetch single row from database in php codeigniter?. Hear we will give you detail about How to fetch single row from database in php codeigniter?And how to use it also give you demo for it if it is necessary.
If you require to get only one record from database table using codeigniter query then you can do it using row(). we can easily return one row from database in codeigniter.
I will give you simple example of fetch single record from database using mysql codeigniter.
Sometime we need to get only one record from database. might be you require to get last one row from database or fetch any single row using where or other condition. So just see bellow query how it make done.
Example:
$data = $this->db->get("items")->row();
print_r($data);
Output:
stdClass Object
(
[id] => 2
[title] => Codeigniter 3 CRUD Example
[description] => Codeigniter 3 CRUD Example From Scratch To follow : Itsolutionstuff.com
[created_at] => 0000-00-00 00:00:00
[updated_at] => 0000-00-00 00:00:00
)
You can get single fields value from object:
$data = $this->db->get("items")->row();
print_r($data->title);
I hope it can help you….
Hope this code and post will helped you for implement How to fetch single row from database in php codeigniter?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs