CodeIgniter Forums
Select All from datebase - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Select All from datebase (/showthread.php?tid=52229)



Select All from datebase - El Forum - 06-02-2012

[eluser]Gabi3xz[/eluser]
Datebasee access
Code:
public function select_article($id) {
  
   $q = $this
            ->db
            ->select('article_title', 'article_description', 'article_keywords', 'article_content')
            ->where('id', $id)
            ->limit(1)
            ->get('article');

      if ( $q->num_rows > 0 ) {
         // person has account with us
         return $row = $q->row();
      }
      return false;
        
}

and call function
Code:
$this->load->model('call_db');
$result = $this->call_db->select_article($id);  
    
print_r($result);
I ensue a single value "Class Object ( [article_title] => title )"
Why?
I have four values in datebase.

My table from datebase http://img822.imageshack.us/img822/1391/asssiu.jpg.


Select All from datebase - El Forum - 06-02-2012

[eluser]Oscar Dias[/eluser]
The select should contain only one string with the values. Should be like this:
Code:
$q = $this
            ->db
            ->select('article_title, article_description, article_keywords, article_content')
            ->where('id', $id)
            ->limit(1)
            ->get('article');
The official reference: http://ellislab.com/codeigniter/user-guide/database/active_record.html#select