Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Custom Data Type Declaration #1042

Open
webgoto opened this issue Apr 21, 2022 · 0 comments
Open

Feature request: Custom Data Type Declaration #1042

webgoto opened this issue Apr 21, 2022 · 0 comments

Comments

@webgoto
Copy link

webgoto commented Apr 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant