Geometry - PostGIS with Phalcon

Hello, I am new to Phalcon...

How can I implement inside a model PostGIS functions?

More exacly I need to call STAsGeoJson(geom) when I select the model and on save STGeomFromText(geom).

Something like this:

class NYCBuildings extends \Phalcon\Mvc\Model
{
    /**
     * Geometry column
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $geom;

    public function getGeom(){
        return "ST_AsGeoJson(geom)";
    }
    public function setGeom($geom)
    {
        $this->geom = "ST_GeomFromText(".$geom.")";
    }

}

How can I implement this corectly in Phalcon?

I have 7 models that have the geometry column. Can I do this for a base model and then extend?



10.8k

i use postgis with phalcon. just run the raw query or this params inside the conditions of your models or phlsql and you should be fine ;)

Can you give me a example?

i use postgis with phalcon. just run the raw query or this params inside the conditions of your models or phlsql and you should be fine ;)