Medoo
Medoo copied to clipboard
Feature request: Custom Data Type Declaration
It might be useful to have the ability to extend the Data Type Declaration. We can now choose [String],[Bool],[Int],[Number],[Object],[JSON] etc.
For example, specify your own type with the following method
$medoo->type('set', 'comma', function($data){
//set is the process used for insert and update
return join(',', $data);
});
$medoo->type('get', 'comma', function($data){
//get is the process used in select
return explode(',', $data);
});
Example of use
$arr = ['a', 'b', 'c'];
$medoo->insert('table', ['id'=>1, 'tags[comma]'=>$arr]);
//Saved as 'a,b,c' in the database.
$medoo->get('table', 'tags[comma]', ['id'=>1]);
//Get ['a', 'b', 'c']
Please considering.