Support for (PostGis) spatial columns in Gii


I am using spatial columns in postgres (extension is called PostGIS). Geographical objects are saved there in an unreadable manner. To get something readable (Well Known Text), one has to call the db-function asEWKT().

I found a simple solution to get this right:

In the model of the table with the spatial column "poly" I just write this in the beforeFind function:

$criteria = new CDbCriteria;

$criteria->select = "asEWKT(poly) AS poly";


instead of the generated

$criteria = new CDbCriteria;

$criteria->select = "poly AS poly";


Well, it would be cool if this could be integrated in the model generation with gii.

To easily distinguish the column I thought of this code, but have not taken any look into the gii-code…

framework/db/schema/PgsqlCPgsqlColumnSchema.php - line #35:

else if(strpos($dbType,'geom')!==false)