Codeigniter의 Active Record Class를 사용하고 있습니다. 따라서 쿼리는 다음과 같습니다.쿼리의 첫 번째 행에서 필드 가져 오기
$query = $this->db->get_where('Table', array('field' => $value));
이제 첫 번째 행에서 필드를 가져 오는 가장 빠른 방법은 무엇입니까? 하겠습니까 $query->first_row->field
; 작업?
감사합니다!
Codeigniter의 Active Record Class를 사용하고 있습니다. 따라서 쿼리는 다음과 같습니다.쿼리의 첫 번째 행에서 필드 가져 오기
$query = $this->db->get_where('Table', array('field' => $value));
이제 첫 번째 행에서 필드를 가져 오는 가장 빠른 방법은 무엇입니까? 하겠습니까 $query->first_row->field
; 작업?
감사합니다!
빠르고 빠르지 만 오류는 아닙니다. 로 액세스를 시도하기 전에 당신은 항상 결과를 확인해야합니다 ($query->num_rows() > 0)
가장 빠른 (대부분의 휴대용) 방법 : 기본적으로
$query = $this->db->get_where('Table', array('field' => $value));
echo(($query->num_rows() > 0) ? $query->first_row()->field : 'No Results');
같은 같은 :
$query = $this->db->get_where('Table', array('field' => $value));
if($query->num_rows() > 0)
{
echo $query->first_row()->field;
}
else
{
echo 'No Results';
}
들어 여러 필드를 사용하는 경우 :
$query = $this->db->get_where('Table', array('field' => $value));
if ($query->num_rows() > 0)
{
$row = $query->row();
echo $row->title;
echo $row->name;
echo $row->body;
}
$query->first_row()->field
자세한 답변을 보내 주셔서 감사합니다. – skndstry