0

i am working on a project that need to work with spatial object in mysql and i choose redbeanphp as ORM system in this project. i found redbeanphp so terrific and awesome. i search in google and found this link that say bindFunc method can help me in working with spatial object but i cannot find any example for using this method.

how this method work and how can i use this method?

Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65

1 Answers1

1

According to the database part of that website you linked:

As of RedBeanPHP 4.1 you can bind an SQL function to a column. This is useful for wrapping values when reading from / writing to the database. For instance, to use MySQL spatial data types you need to prepare the columns like this:

R::bindFunc( 'read', 'location.point', 'asText' );
R::bindFunc( 'write', 'location.point', 'GeomFromText' );

$location = R::dispense( 'location' );
$location->point = 'POINT(14 6)';

//inserts using GeomFromText() function
R::store( $location );

//to unbind a function, pass NULL:
R::bindFunc( 'read', 'location.point', NULL );

This function was added to support spatial datatypes in MySQL as shown above. The documentation isn't amazing, so I recommend looking at the source code on Github if you want to dig in deeper.

Palu Macil
  • 1,708
  • 1
  • 24
  • 34
  • haha, good... I like EATING red beans best... but as far as this library goes, it's not the best documentation I've seen. It might help to look at the source code now and then if you want to learn it well, and there are 34 contributors on Github, but you might be able to spark some enthusiasm (and learn a bit yourself) if you start contributing documentations. It's a great way to learn. :) – Palu Macil Jul 08 '15 at 13:26
  • yes , you are right and it was in my mind too... i add a issue to redbean github for its documentation :https://groups.google.com/forum/?fromgroups#!topic/redbeanorm/zjD2es88ByA – Navid_pdp11 Jul 08 '15 at 14:23
  • dear paul do you guide me to create a mixed column such as full_name from first_name and last_name by using bindFunc method – Navid_pdp11 Jul 09 '15 at 11:07