[英]Calling MySQL functions in Lithium
How it's possible to call MySQL function (like GeomFromText() or SELECT AS ) in the Lithium Framework's CRUD?如何在锂框架的CRUD 中调用 MySQL function(如GeomFromText()或SELECT AS )? Using database->read() is to inconvenient (I often change the database columns) and including the function in the variable's value only ends up being escaped.使用database->read()很不方便(我经常更改数据库列)并且在变量值中包含 function 最终只会被转义。
Have you tried putting the function in the fields option?您是否尝试过将 function 放入字段选项中?
For example, I do this:例如,我这样做:
Model::first(array(
'fields' => 'max(id)'
));
To clarify, in your query, try this (i have not tested this):为了澄清,在您的查询中,试试这个(我没有测试过这个):
Model::first(array(
'fields' => array('field1 as myField', 'GeomFromText("POINT(x y)") as geom')
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.