私は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 = $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->num_rows() > 0)
方法(最も簡潔)最速でそれらにアクセスしようとする前に結果をチェックしていることを確認します複数のフィールドを使用します:
$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