Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select a dummy column with a dummy value in Zend framework Select?

How can i specify Zend Db Table Select to fetch a dummy column.

i want to generate sql like this

SELECT 'ABC' AS xyz , name FROM employee

Edit:

I have tried this

$select->from('employee',array( 
        'xyz'=>'ABC',
        'name'
));

and also as

$select->from('employee',"'ABC' AS xyz , name"));

in both cases Zend intelligently considers 'ABC' as a field in schema. so it generate something like

SELECT `employee`.`'ABC'` AS `xyz` , `name` FROM `employee`

which produces error as ABC is not a field of employee

like image 495
Rasikh Mashhadi Avatar asked Dec 08 '12 22:12

Rasikh Mashhadi


1 Answers

You should try

$select->from ('employee', array (new Zend_Db_Expr ('"ABC" AS title'), 'name'));
like image 75
akond Avatar answered Sep 21 '22 17:09

akond