浏览代码

Added model alias to validation methods

As I stated on the GitHub page of the Imagebehavior of josbeir, I got an error in the cooperation between your plugins :)
"column id is ambigous" error because there wasn't a model alias supplied in the validation queries.
lorro 9 年之前
父节点
当前提交
dcfcc478a4
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Model/Behavior/PasswordableBehavior.php

+ 2 - 2
src/Model/Behavior/PasswordableBehavior.php

@@ -416,7 +416,7 @@ class PasswordableBehavior extends Behavior {
 		$primaryKey = $context['data'][$this->_table->primaryKey()];
 		$primaryKey = $context['data'][$this->_table->primaryKey()];
 		$value = $context['data'][$context['field']];
 		$value = $context['data'][$context['field']];
 
 
-		$dbValue = $this->_table->find()->where([$this->_table->primaryKey() => $primaryKey])->first();
+		$dbValue = $this->_table->find()->where([$this->_table->alias() . '.' . $this->_table->primaryKey() => $primaryKey])->first();
 		if (!$dbValue) {
 		if (!$dbValue) {
 			return true;
 			return true;
 		}
 		}
@@ -440,7 +440,7 @@ class PasswordableBehavior extends Behavior {
 		$field = $this->_config['field'];
 		$field = $this->_config['field'];
 
 
 		$primaryKey = $context['data'][$this->_table->primaryKey()];
 		$primaryKey = $context['data'][$this->_table->primaryKey()];
-		$dbValue = $this->_table->find()->where([$this->_table->primaryKey() => $primaryKey])->first();
+		$dbValue = $this->_table->find()->where([$this->_table->alias() . '.' . $this->_table->primaryKey() => $primaryKey])->first();
 		if (!$dbValue) {
 		if (!$dbValue) {
 			return false;
 			return false;
 		}
 		}