We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Issue with MySQL trigger vs. Phalcon

Hi, I have a location table with columns lat, lng and the geohash of the point, and associated Location Phalcon model. In MySQL I have a before insert type trigger function that automatically generates the geohash (as a VARCHAR) when a location row is added, so if I put in the SQL:

INSERT INTO location (lat, lng) VALUES (100, 100); 

the geohash for (100,100) is duly inserted in into the geohash column.

However if I user phalcon like this ...

$location = new Location();
$location->lat = 100;
$location->lng = 100;
$location->save();

... the trigger is ignored (or perhaps the value it writes is overwritten) to NULL. Am I missing something? Has anyone else had simillar isses with MySQL triggers vs. Phalcon. Would like to know why this is happening. Any ideas much appreciated.



720
Accepted
answer

Answering my own question...

Added the following line:

    $this->skipAttributes(array("geohash"));

to Location object's initialise() method. Seems to be working okay.