在Lithium中调用MySQL函数 [英] Calling MySQL functions in Lithium
本文介绍了在Lithium中调用MySQL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.
推荐答案
您是否尝试过将函数放在fields选项中?
Have you tried putting the function in the fields option?
例如,我这样做:
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')
));
这篇关于在Lithium中调用MySQL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文