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

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 ST_AsGeoJson(geom) when I select the model and on save ST_GeomFromText(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?



16.4k

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