CodeIgniter Forums
how can i read just one field from a db table - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how can i read just one field from a db table (/showthread.php?tid=5540)



how can i read just one field from a db table - El Forum - 01-25-2008

[eluser]alebenson[/eluser]
hi there!.. basic stuff here again
i cant understand this
i just want to read only 1 field of my DB... the content of the Image from some ID

here is what i am doing

Code:
$this->db->select('image');
$this->db->where('id', $id);
$JustTheImage = $this->db->get('post');

but by the whole things i've try to readit the only one that works is just a forech
a foreach for a single thing has no sense


how can i read just one field from a db table - El Forum - 01-25-2008

[eluser]xwero[/eluser]
you have to add
Code:
$result = $this->db->get('post');
$row = $result->row();
$row->image;
in php5 you can do
Code:
$this->db->select('image')->from('post')->where('id', $id)->get()->row()->image;



how can i read just one field from a db table - El Forum - 01-25-2008

[eluser]alebenson[/eluser]
now is working!.. thanks!