Medoo icon indicating copy to clipboard operation
Medoo copied to clipboard

Feature request: Custom Data Type Declaration

Open webgoto opened this issue 3 years ago • 0 comments

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.

webgoto avatar Apr 21 '22 00:04 webgoto