i want to fetch the record from database which pages without parent_id or we can say pages without parent..
the page model ..........................................
public function get_no_parents() {
// fecth pages wihtout parents
$this->db->select ( 'id','title' );
$this->db->where ( 'parent_id', 0 );
$pages = parent::get ();
// if there are pages then return key as page->id and value $page->title
$array = array (
0 => 'no parent'
);
if(is_array($pages)){
foreach ($pages as $page){
$array[$page->id]=$page->title;
$return $array;
}
}
}
.....the page controller
$this->data['pages_no_parents']=$this->Page_model->get_no_parents();
var_dump($this->data['pages_no_parents']);
.... the dump is null i have two error
1- Undefined property: stdClass::$title
2- Invalid argument supplied for foreach()
can someone help me ?