Calling MySQL functions in Lithium

淺唱寂寞╮ 提交于 2019-12-06 08:59:44

问题


How it's possible to call MySQL function (like GeomFromText() or SELECT AS) in the Lithium Framework's CRUD? 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.


回答1:


Have you tried putting the function in the fields option?

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')
));


来源:https://stackoverflow.com/questions/10000727/calling-mysql-functions-in-lithium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!