I am setting up a system for a database with some POINT
columns. I need to SELECT
them using ST_AsText(location)
to process the POINT
s. I was able to achieve this using Query Builder
:
$this->Houses->find()->select(['location' => 'ST_AsText(location)'])
However, I would like to have this happen by default, even when I haven’t called ->select(...)
yet from a controller. To do this, I was thinking of using the beforeFind
event. How can I replace a field with a function when it is going to be included?
Older comparable question on CakePHP discourse: https://discourse.cakephp.org/t/read-data-from-spatial-mysql-field-point-polygon/2124