本文整理汇总了PHP中ORM::check方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::check方法的具体用法?PHP ORM::check怎么用?PHP ORM::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::check方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
public function check()
{
if (!parent::check()) {
return FALSE;
}
if (count($this->_transactions['incomes']) == 0 and count($this->_transactions['transfers']) == 0 and count($this->_transactions['expenses']) == 0) {
$this->_validate->error('balance', 'No transactions');
return FALSE;
}
$balance = 0;
foreach ($this->_transactions as $type => $transactions) {
switch ($type) {
case 'incomes':
foreach ($transactions as $transaction) {
$balance += $transaction->amount;
}
break;
default:
foreach ($transactions as $transaction) {
$balance -= $transaction->amount;
}
}
}
if ($balance != 0) {
$this->_validate->error('balance', 'Not zero');
return FALSE;
}
return TRUE;
}
示例2: validate
/**
* Validates and optionally
*
* @param array values to check
* @param boolean save the record when validation succeeds
* @return boolean
*/
public function validate()
{
$this->_filters += array(TRUE => array('trim' => array()));
#array($this, 'email_available')=>array()
$this->_rules += array('email' => array('min_length' => array(4), 'max_length' => array(255), 'email' => array()));
# array($this, 'user_name_available')
$this->_rules += array('user_name' => array('min_length' => array(4), 'max_length' => array(255), 'alpha_dash' => array()));
return parent::check();
}
示例3: validate
public function validate()
{
$this->_filters += array(TRUE => array('trim' => array()));
$this->_rules = array('password' => array('min_length' => array(6)));
if (isset($this->password_confirm)) {
$this->_rules += array('password_confirm' => array('matches' => array('password')));
}
return parent::check();
}
示例4: check
public function check()
{
if (!isset($this->_validate)) {
// Initialize the validation object
$this->_validate();
}
// add custom rules to $this->_validate();
event::run('yuriko_core.model.validate.site_settings', $this->_validate);
return parent::check();
}
示例5: populate
/**
* @return bool
*/
public function populate()
{
if (!$this->allowed('write')) {
return FALSE;
}
$hash = $this->_hash_input_name;
// nothing or the other form has been submitted
if (!isset($_POST[$hash])) {
return FALSE;
}
$values = array();
foreach ($this as $name => $field) {
if ($field->allowed('write')) {
if (!is_null($value = Arr::get($_POST, $name))) {
$values[$name] = $field->prepare_to_populate($value);
}
}
}
$this->_object->values($values);
foreach ($this as $name => $field) {
$field->set_value($this->_object->{$name});
}
$valid = $this->_object->check();
foreach ($this as $name => $field) {
$valid = ($valid and $field->validate($this->_object->validate(), $name));
}
if ($valid) {
return TRUE;
}
$errors = $this->_object->validate()->errors($this->_messages_file);
foreach ($errors as $name => $error) {
if (isset($this[$name])) {
$this[$name]->set_error($error);
}
}
return FALSE;
}
示例6: check
/**
* Check user throttle status.
*
* @param \Validation $extra_validation
* @return bool
* @throws \Cartalyst\Sentry\Throttling\UserBannedException
* @throws \Cartalyst\Sentry\Throttling\UserSuspendedException
*/
public function check(\Validation $extra_validation = NULL)
{
if ($this->isBanned()) {
throw new UserBannedException(sprintf('User [%s] has been banned.', $this->getUser()->getLogin()));
} else {
if ($this->isSuspended()) {
throw new UserSuspendedException(sprintf('User [%s] has been suspended.', $this->getUser()->getLogin()));
}
}
return parent::check($extra_validation);
}
示例7: check
/**
* Sync field values with
* @param Validation $extra_validation
* @todo Clean this up and enable error passing directly to fields
*/
public function check(Validation $extra_validation = NULL)
{
$ex = NULL;
$errors = array();
// Reapply filters by setting objects again
foreach ($this->table_columns() as $column => $definition) {
if ($column == $this->primary_key()) {
continue;
}
$this->{$column} = $this->{$column};
}
try {
parent::check($extra_validation);
} catch (ORM_Validation_Exception $ex) {
$errors = $ex->errors('models', TRUE);
}
// After applying filters, set field values back.
foreach ($this->_z_fields as $column => $field) {
$field->value = $this->{$column};
$field->error = Arr::get($errors, $column);
}
// Rethrow exception
if ($ex instanceof ORM_Validation_Exception) {
throw $ex;
}
}