PHP code example of rafayhingoro / vmodel-idiorm-extension
1. Go to this page and download the library: Download rafayhingoro/vmodel-idiorm-extension library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rafayhingoro / vmodel-idiorm-extension example snippets
class YourModelName extends VModel {
//your code
}
class YourModelName extends VModel {
public $_isValid = true; //by default making it valid
//fields which are in database
public $_fields = array(
'id',
'name',
'email',
'contact_number',
'description'
);
//adding rules for fields
protected $_rules = array(
'category_id' => '
class ControllerUser {
try {
// $form is array of inputs here's an example
// $form['username'] = 'user1234';
// $form['password'] = 'mySecretPassword';
// $form['email'] = '[email protected]';
// ...
$oModel = Model::factory("YourModelName")->create();
$oModel->validateForm($form); //throws exception if form is not valid
...
} catch (Exception $ex) {
$ex->getMessage(); //validation error will be available here
}
}