drelkata
drelkata

Reputation: 347

Calling MySQL functions in Lithium

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.

Upvotes: 3

Views: 343

Answers (1)

anon
anon

Reputation:

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

Upvotes: 4

Related Questions