Answer the question
In order to leave comments, you need to log in
How to remove escaping in sql query in ZF2?
Actually, the problem is that the output is a query with escaping all field names, aliases, etc., and this does not allow adding a new value at the output.
What it's about:
an example request in zf2
$sql = new Sql(<адаптер>);
$select = $sql
->select()
->from(array('v' => 'video'))
->columns(array('id','title'))
SELECT `v`.`id`, `v`.`title` FROM `video` AS `v`
'video' AS 'cat'
->columns(array('id','title', "'cat'" => "'video'"))
- you can not do it this way. SELECT `v`.`id`, `v`.`title`, 'video' AS 'cat' FROM `video` AS `v`
- what should be the output
Answer the question
In order to leave comments, you need to log in
->columns(array('id','title',
'cat' => new \Zend\Db\Sql\Expression('video'),
))
this problem can be solved by adding a method
however this is not the solution to all escaping difficulties, are there any other solutions?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question