これは少しばかげた質問かもしれませんが、私はこれを理解していません:
モデルにこれらの2つの関数があります
public function count()
{
return $this->db->num_rows();
}
public function changes()
{
return $this->db->affected_rows();
}
コントローラを呼び出すchanges();
と、最後の(更新)クエリの影響を受けた行が表示されます。count();
ただし、最後の(選択)クエリの行を表示するために使用すると、エラーが発生します。
コントローラのコードは次のようになります。
if (!$this->synchronization_model->get_contact_knowledge($contact['account_id'], SERVER_LOCATION_ID)) {
throw new Exception("Failed to update knowledge");
}
if( $this->synchronization_model->count() == 0) {
$this->synchronization_model->insert_knowledge($contact['account_id'], $contact_server_time);
}
これを修正または回避する方法はありますか?