2015-05-28 86 views
0
case "up": 
    $current_row = $this -> crud_model -> get('client_list', array('id_client_list' => $entry_id), 'id_client_list', 'asc', '1'); 
    $affected_row = $this -> crud_model -> get('client_list', array('id_company' => $current_row -> id_company, 'ord' => $current_row -> ord - 1), 'id_client_list', 'asc', '1'); 
    $this -> crud_model -> save('client_list', array('id_client_list' => $current_row -> id_client_list), array('ord' => $affected_row -> ord)); 
    $this -> crud_model -> save('client_list', array('id_client_list' => $affected_row -> id_client_list), array('ord' => $current_row -> ord)); 

我得到這個錯誤得到非對象的屬性:消息:嘗試使用CodeIgniter的框架

Message: Trying to get property of non-object 

從我可以告訴這是建立在一個框架,這使得這個難於理解的頂部。

錯誤發生在最後兩行。這是一個框架無法做到這一點,或者它是一個代碼錯誤?

+0

你確定'$ current_row'&'$ affected_row'獲得了正確的值嗎? –

回答

1

你沒有返回任何東西。

$current_row = $this->crud_model->get('client_list', array('id_client_list' => $entry_id), 'id_client_list', 'asc', '1')->row(); 
$affected_row = $this->crud_model->get('client_list', array('id_company' => $current_row->id_company, 'ord' => $current_row->ord - 1), 'id_client_list', 'asc', '1')->row(); 
$this->crud_model->save('client_list', array('id_client_list' => $current_row->id_client_list), array('ord' => $affected_row->ord)); 
$this->crud_model->save('client_list', array('id_client_list' => $affected_row->id_client_list), array('ord' => $current_row->ord)); 

在最後添加了->row();

+0

致命錯誤:當我嘗試調用未定義的方法stdClass :: row()時 –