How to select only one field from table inside a model.
For example: table1(field1, field2 , ..)
and the select only field 1
Asked
Active
Viewed 6,472 times
3

Robert Harvey
- 178,213
- 47
- 333
- 501

S L
- 14,262
- 17
- 77
- 116
1 Answers
9
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'));

mauromartini
- 338
- 1
- 5
-
I mean from Model file of the framework. if i try this code in model then i get the error ,,,,cannot join this table to that table. Please could you help me in the MODEL file. I would appreciate a lot. – S L Dec 17 '10 at 05:45
-
what is t in first array? – Farzan Najipour Jan 11 '15 at 11:11