Prehistory:
I have Microsoft SQL Server as DBMS behind my Yii2 REST API. SQL Server has its internal data types: geography and geometry. Techincally, in terms of PDO, these types are PHP binary strings
Question:
So, i need a transparent way to map columns of these types to my class MyApp\Geometry, for example.
That is i should be able to:
- access ActiveRecord instance property as
Geometryinstance(e.g$model->geometryBorders->someGeometryTransformation(); - save ActiveRecord instance with
Geometryproperty transformation by__toString()method
As of the second point - it looks clear for me ( as far, as i understand, PDO engine automatically converts all values to PHP string type before sending them to DBMS), but about the first point - i do not know how to implement it within the Yii2 architecture
So, are there any way to map ActiveRecord attribute to PHP class? I belive, that someone has already met this problem before.