1. Go to this page and download the library: Download jmjjg/cakephp3-database 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/ */
public function initialize(array $config)
{
// ...
$this->addBehavior('DatabaseAutovalidate',
[
'className' => 'Database.Autovalidate',
// Default values
// 1°) Accepted validator names, as a string or an array of strings, NULL for any
'accepted' => null,
// 2°) Cache validation rules and their error messages ? NULL for global settings
'cache' => null,
// 3°) Domain to use for error messages
'domain' => 'database'
]
);
$this->addBehavior('DatabaseFormattable',
[
'className' => 'Database.Formattable',
// Default values
// 1°) Cache formatters and the field list they apply to ? NULL for global settings
'cache' => null,
// 2°) List of formatter functions or static methods as keys, fields they apply to as values
// a°) A NOT key is allowed to negate the condition
// b°) Boolean true means all fields, false means the formatter is not used
// c°) Strings or array of strings are allowed
// * regular expressions (delimited by "/") are used to filter field names
// * other strings are used to filter field types
'formatters' => [
// Extract the part after the last "_" character
'\\Database\\Utility\\Formatter::formatSuffix' => '/_id$/',
// Trim the value
'\\Database\\Utility\\Formatter::formatTrim' => [ 'NOT' => 'binary'],
// Transform empty string to a NULL value
'\\Database\\Utility\\Formatter::formatNull' => true,
// Tries to parse an integer value using the current intl.default_locale value
'\\Database\\Utility\\Formatter::formatInteger' => ['integer', 'biginteger'],
// Tries to parse a decimal value using the current intl.default_locale value
'\\Database\\Utility\\Formatter::formatDecimal' => ['decimal', 'float', 'numeric']
]
]
);
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.