add default query setting method

This commit is contained in:
祁宁 2014-04-20 20:29:02 +08:00
parent e6d5d5e7de
commit df63e19190

View File

@ -32,7 +32,7 @@ class Typecho_Db_Query
* @var array
* @access private
*/
private $_default = array(
private static $_default = array(
'action' => NULL,
'table' => NULL,
'fields' => '*',
@ -80,7 +80,7 @@ class Typecho_Db_Query
$this->_adapter = &$adapter;
$this->_prefix = $prefix;
$this->_sqlPreBuild = $this->_default;
$this->_sqlPreBuild = self::$_default;
}
/**
@ -199,6 +199,16 @@ class Typecho_Db_Query
return $values;
}
/**
* set default params
*
* @param array $default
*/
public static function setDefault(array $default)
{
self::$_default = array_merge(self::$_default, $default);
}
/**
* 获取查询字串属性值
*
@ -221,7 +231,7 @@ class Typecho_Db_Query
public function cleanAttribute($attributeName)
{
if (isset($this->_sqlPreBuild[$attributeName])) {
$this->_sqlPreBuild[$attributeName] = $this->_default[$attributeName];
$this->_sqlPreBuild[$attributeName] = self::$_default[$attributeName];
}
return $this;
}