mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-08 04:22:40 +00:00
Adding sanity checking / warning messages for data returned from Model::loadInfo() (thanks phishy)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5027 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8a3914f8df
commit
360690ed7f
2 changed files with 19 additions and 3 deletions
|
@ -848,7 +848,12 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function getColumnTypes() {
|
||||
$columns = $this->loadInfo();
|
||||
return array_combine($columns->extract('{n}.name'), $columns->extract('{n}.type'));
|
||||
$names = $columns->extract('{n}.name');
|
||||
$types = $columns->extract('{n}.type');
|
||||
if (!count($names) || !count($types)) {
|
||||
trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing loadInfo()', true), E_USER_WARNING);
|
||||
}
|
||||
return array_combine($names, $types);
|
||||
}
|
||||
/**
|
||||
* Returns the column type of a column in the model
|
||||
|
@ -1727,6 +1732,8 @@ class Model extends Overloadable {
|
|||
}
|
||||
|
||||
$valid = true;
|
||||
$msg = null;
|
||||
|
||||
if (method_exists($this, $rule)) {
|
||||
$ruleParams[] = array_diff_key($validator, $default);
|
||||
$valid = call_user_func_array(array(&$this, $rule), $ruleParams);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue