2011-08-13 4 views

답변

0

첫 번째로 일치하는 행을 가져 오려고한다고 가정합니다. 원하지 않으면 다시 설명해주십시오.
시도 뭔가 같은 :

$query = $this->db-> 
       select('title')-> 
       from('mytable')-> 
       where('*', $id)-> 
       limit(1)-> //Only want 1 row 
       get(); //Get result 
if ($query->num_rows() == 0) 
    show_error('No rows to return'); //Exits, nothing after this will run 
$row = $query->row(); //Gives you the first row, you can 
0
나는이 한 줄의 코드 그래서 $result = $this->db->get_where(<table_name>, array(<field_name> => <check_value>));

을 사용하는 것이 좋습니다 것입니다

, 당신이 요구하는 코드가 될 것

$result = $this->db->get_where('mytable', array('*' => $id));

그러나 당신이 요구하는 코드가 다음과 같이 작동하는지 확신 할 수 없다 : |

0

이 코드

$this->db->where('id', $id); 
$result = $this->db->get('mytable); 

와 함께 단일 행의 모든 ​​열을 얻을 수 있습니다 또는 단순히 당신이

$result = $this->db->get_where('mytable', array('id' => $id), $limit, $offset); 
관련 문제