Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - get only 1 row from table
#1

I know this is a noob question but atm I can't figure out what i'm doing wrong.

I have model :
PHP Code:
public function getRow($id$table)    {
$data NULL;

$this->db->select()
->
from($table)
->
where('id'$id)
->
where_not_in('deleted''1');

$query $this->db->get();
if (
$query->num_rows() > 0)    {
 
  return $query->row(); 
}

return 
NULL;


and in view :

PHP Code:
<?php echo $data->column_name?>

This work but if there are no records I get :   Trying to get property of non-object ..

I can't for the life of me remember how I fix the problem last time ...
Reply


Messages In This Thread
Codeigniter - get only 1 row from table - by GrigoreMihai - 03-20-2015, 02:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB