Select a dummy column with a dummy value in Zend framework Select?
Asked Answered
H

1

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

Hierodule answered 8/12, 2012 at 22:14 Comment(2)
Can't you just add those columns in your code? Why do you need those "dummy columns"?Acciaccatura
i have edited my question. please re read, i appreciate you quick responseHierodule
N
8

You should try

$select->from ('employee', array (new Zend_Db_Expr ('"ABC" AS title'), 'name'));
Nylons answered 9/12, 2012 at 10:56 Comment(2)
And how can make its alias like 'ABC' AS title ?Hierodule
Add an AS statement: new Zend_Db_Expr ('"ABC" AS title')Nylons

© 2022 - 2024 — McMap. All rights reserved.