Reputation: 11
How to make a request with the Zend_Select
SELECT "subdivision" as `type`, a.id as id FROM `some_table` a;
doing so
$ this-> select ()
-> from (
array ('a' => 'some_table'), array ('type' => "subdivision", 'id' => 'a.id')
)
result
SELECT `a`. `" Subdivision "` as `type`, a.id as id FROM `some_table` a;
Upvotes: 1
Views: 700
Reputation: 3804
It's not always obvious but for Laminas it'll look like this
$select->from(['a' => 'some_table'])
->columns([
'id' => 'id',
'type' => new Laminas\Db\Sql\Expression('"subdivision"')
]);
Upvotes: 0
Reputation: 83692
You have to mark the static value so that Zend_Db_Select
does not quote the value as an identifier using Zend_Db_Expr
.
$this->select()
->from(array(
'a' => 'some_table'
), array(
'type' => new Zend_Db_Expr($db->quote('subdivision')),
'id' => 'a.id'
)
);
Upvotes: 5