简体   繁体   English

Zend / Db / Sql / columns中的新Zend框架更改导致问题

[英]New Zend framework changes in Zend/Db/Sql/columns causes problems

Our framework sits on top of the Zend framework. 我们的框架位于Zend框架之上。 A change in the way columns() is working causes problems with our database calls. 更改columns()的工作方式会导致数据库调用出现问题。 Before, it was fine to do something like: 以前,可以执行以下操作:

$distanceFormula = "$earthRadius*ACOS(COS(RADIANS($lat)))";
$select->columns(array('distance' => $distanceFormula));

This created a query: 这创建了一个查询:

SELECT `items`.*, 6371*ACOS(COS(RADIANS(51.985103)) AS `distance`

NOW it creates a query: 现在,它创建一个查询:

SELECT `items`.*, `6371*ACOS(COS(RADIANS(51.985103))` AS `distance`

columns() puts ` (apostrophe) around everything so we get the following error: column()将`(撇号)放在所有内容周围,因此我们得到以下错误:

Zend_Db_Statement_Mysqli_Exception
Mysqli prepare error: Unknown column '6371*ACOS.... etc

Is there a way to tell columns not to put the formula between apostrophes? 有没有办法告诉列不要将公式放在撇号之间?

I found that if the formula is entered as Zend_Db_Expr, everything works fine. 我发现,如果将公式输入为Zend_Db_Expr,则一切正常。

$distanceFormula = new Zend_Db_Expr("($earthRadius*ACOS(COS(RADIANS($lat))");
$select->columns(array('distance' => $distanceFormula));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM