Created
December 14, 2011 10:45
-
-
Save kaz29/1476089 to your computer and use it in GitHub Desktop.
CakePHP Advent Calendar 2011/12/14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @ operator | |
// compare to circle | |
$conditions = array( | |
'loc @' => array('circle' => array('point'=> array(10.1,10.1), 100)), | |
); | |
// order by distance | |
$order = array( | |
'loc <-> point(10.1,10.1)' | |
); | |
$result = $model->find('all', array('conditions'=>$conditions, 'order'=>$order)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostgresGeoFixture extends CakeTestFixture { | |
/** | |
* name property | |
* | |
* @var string 'PostgresGeo' | |
*/ | |
public $name = 'PostgresGeo'; | |
/** | |
* fields property | |
* | |
* @var array | |
*/ | |
public $fields = array( | |
'id' => array('type' => 'integer', 'key' => 'primary'), | |
'loc' => array('type' => 'point', 'null' => false), | |
'rect' => array('type' => 'box', 'null' => false), | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = array( | |
'loc' => array(10.1,10.1), | |
'rect' => array(array(10.1,10.2), array(100.1,100.2)), | |
); | |
$Model->create(); | |
$Model->set($data); | |
$result = $Model->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment