6

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

Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
Rasikh Mashhadi
  • 1,422
  • 1
  • 15
  • 25

1 Answers1

8

You should try

$select->from ('employee', array (new Zend_Db_Expr ('"ABC" AS title'), 'name'));
Marvo
  • 17,845
  • 8
  • 50
  • 74
akond
  • 15,865
  • 4
  • 35
  • 55