MySQL geometry Type Data in CakePHP 3

MySQL geometry Type Data in CakePHP 3

Takahiro Iwasa
Takahiro Iwasa
1 min read
CakePHP GIS

CakePHP 3 can handle MySQL geometry type data. Happy Coding!

$myHousesTable = TableRegistry::get('MyHouses');
$myHouse = $myHousesTable->newEntity();

$myHouse->latlng = $myHousesTable->query()->newExpr()->add(
    // Note that Point argument order is longitude followed by latitude.
    "ST_GeomFromText('Point(138.727777 35.360556)')"
);
Takahiro Iwasa

Takahiro Iwasa

Software Developer at KAKEHASHI Inc.
Involved in the requirements definition, design, and development of cloud-native applications using AWS. Now, building a new prescription data collection platform at KAKEHASHI Inc. Japan AWS Top Engineers 2020-2023.