diff --git a/app/library/Mvc/Model/Behavior/RandomId.php b/app/library/Mvc/Model/Behavior/RandomId.php index e5c644a..93d3c2a 100644 --- a/app/library/Mvc/Model/Behavior/RandomId.php +++ b/app/library/Mvc/Model/Behavior/RandomId.php @@ -60,6 +60,12 @@ class RandomId extends Behavior implements BehaviorInterface $field = $this->_options['field']; $len = $this->_options['length']; + if (isset($this->_options['expression'])) { + $expr = 'AND ' . $this->_options['expression']; + } else { + $expr = ''; + } + if ($model->$field === null) { $random = new \Phalcon\Security\Random(); @@ -67,7 +73,7 @@ class RandomId extends Behavior implements BehaviorInterface $id = substr($random->base64Safe(), 0, $len); $count = $model->count(array( - "$field = ?0", + "$field = ?0 $expr", 'bind' => array($id) ));