How to select only one field from table inside a model.
For example: table1(field1, field2 , ..) and the select only field 1
How to select only one field from table inside a model. For example: table1(field1,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You want only one value or a rowset with one column?
In first case, you can use fetchOne():
$result = $db->fetchOne(‘SELECT bug_status FROM bugs WHERE bug_id = 2’);
Or you can make a select only with the fields you want to retreive:
$select = $db->select()
->from(array(‘t’ => ‘table1’),
array(‘field1’));