Hi Maurits,
I needed a callback function that got triggered on a new db entry (Create).
For example I wanted to send an e-mail to a newly registered member.
In this example I have a "members" table with the columns: id , firstName, lastName, email
the yourEmailFunction method will send a welcome message to the newly entered member.
```php
$api = new PHP_CRUD_API(array(
'after_create'=>function($db,$tab,$row) {
if ($tab == 'members')
yourEmailFunction($row['firstName'],$row['lastName'],$row['email']);
}
}
));
$api->executeCommand();
```
Tell me you thoughts... maybe if you like it and willing to accept the pull request I can also create an after_delete and after_update method.
First of all, thanks for building this great php api framework and sharing it with the world!
I am a SAP Developer mainly developping JS apps with SAPui5 / OpenUit (https://open.sap.com/)
And for Sapui5 to work with your API, i made a SAPui5 model implementation of your api
With this model I can retrieve, edit and send data to your api and bind it to my views.
Other SAPui5 Models (like Odata) auto convert api response data to usable js json objects.
for example. Any date/time fields in the api will in js be converted to a new Date() object.
I wanted to do this too with my model implementation of your api.. but therefore I needed to know what db column and types my db tables have.
I found that in your metadata under paths/TABLENAME/post/parameters[0]/schema/properties
all db columns could be found.. and that all types are set to "string"
In order to get the db-types aswel I edited your class and added "db-type" to
paths/TABLENAME/get/responses/200/schema/items/properties/PROPERTYNAME
So now I can what what the column types are in the db, and so for my model I could convert a db column date to a js Date() object and viseversa.
note: I only added the query reflect_type to the MySQL class, I don't have the experience to write it also in PostgreSQL, SQLServer, SQLite.
hit me back what you think of it, and if maybe you are willing to accept the pull request or have a better solution, please let me know.
Barry