|
@@ -31,7 +31,9 @@ class Base {
|
|
|
*
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function defaultFieldsValue(){}
|
|
|
+ public function defaultFieldsValue(){
|
|
|
+ return array();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 返回 table 的名字,以便分库分表的时候指定使用
|
|
@@ -42,12 +44,14 @@ class Base {
|
|
|
public function getTable() {
|
|
|
throw new \Exception('请先设置需要保存的数据表');
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* set hooker for method
|
|
|
* 目前 where 和 order 及 fields 支持
|
|
|
* @param $key
|
|
|
* @param $hooker
|
|
|
- * @return void
|
|
|
+ * @param $args
|
|
|
+ * @return $this
|
|
|
*/
|
|
|
protected function setHooker($key, $hooker, $args) {
|
|
|
$this->hooker[$key]['func'] = $hooker;
|
|
@@ -58,7 +62,7 @@ class Base {
|
|
|
/**
|
|
|
* 设置where hooker
|
|
|
* @param object $hooker
|
|
|
- * @return void
|
|
|
+ * @return $this
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
final public function setWhereHooker($hooker, $args = null) {
|
|
@@ -82,7 +86,7 @@ class Base {
|
|
|
/**
|
|
|
* 设置order by hooker
|
|
|
* @param object $hooker
|
|
|
- * @return void
|
|
|
+ * @return $this
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
final public function setOrderHooker($hooker, $args = null) {
|
|
@@ -95,7 +99,7 @@ class Base {
|
|
|
* 设置 limit hooker
|
|
|
*
|
|
|
* @param object $hooker
|
|
|
- * @return void
|
|
|
+ * @return $this
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
final public function setLimitHooker($hooker, $args = null) {
|
|
@@ -119,7 +123,7 @@ class Base {
|
|
|
*
|
|
|
* @param callable $hooker
|
|
|
* @param array| mixed $args
|
|
|
- * @return void
|
|
|
+ * @return $this
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
final public function setCacheHooker($hooker, $args = null) {
|
|
@@ -178,7 +182,7 @@ class Base {
|
|
|
/**
|
|
|
* 设置order by hooker
|
|
|
* @param object $hooker
|
|
|
- * @return void
|
|
|
+ * @return $this
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
final public function setQueryFieldsHooker($hooker, $args = null) {
|
|
@@ -216,7 +220,7 @@ class Base {
|
|
|
/**
|
|
|
* 返回使用的db信息
|
|
|
*
|
|
|
- * @return mixed
|
|
|
+ * @return \Qii\Driver\Base
|
|
|
*/
|
|
|
final public function db() {
|
|
|
return _loadClass('\Qii\Driver\Model');
|
|
@@ -386,7 +390,7 @@ class Base {
|
|
|
/**
|
|
|
* bind value
|
|
|
* @param $values
|
|
|
- * @return $this|false
|
|
|
+ * @return $this
|
|
|
*/
|
|
|
final public function bindValues($values) {
|
|
|
if(!is_array($values)) {
|
|
@@ -431,7 +435,8 @@ class Base {
|
|
|
final public function info() {
|
|
|
try{
|
|
|
$info = $this->db()->fields($this->getFieldsHooker())->where($this->getWhereHooker())->selectRow($this->getTable());
|
|
|
- return Response::Success(static::class .'::'. __FUNCTION__,
|
|
|
+ return Response::Success(
|
|
|
+ static::class .'::'. __FUNCTION__,
|
|
|
['_result' => ['code' => Response::DO_SUCCESS, 'msg' => '获取成功', 'body' => $info]]
|
|
|
);
|
|
|
}catch (\Exception $e) {
|
|
@@ -822,9 +827,12 @@ class Base {
|
|
|
if(!in_array($key, $fields)) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
$field = $this->entity()->convertToField($key);
|
|
|
+ $value = isset($values[$field]) ? $values[$field] : null;
|
|
|
+ $limit = isset($val[2]) ? $val[2]: '';
|
|
|
|
|
|
- $verify = new Verify($val[0], $values[$field] ?? null, strtolower($valid), $val[1], $val[2] ?? '');
|
|
|
+ $verify = new Verify($val[0], $value, strtolower($valid), $val[1], $limit);
|
|
|
$res = $verify->valid();
|
|
|
if($res->isError()) {
|
|
|
$result[] = $res->getResult() .',获取的是 '. $values[$field];
|