我来自另一位开发人员编写的一些代码。这是一个 php 数据库抽象层,我正在尝试研究代码,但我无法理解其中的一些。
class QueryBuilderBase
{
/*
* The builder SQLStates.
*/
const STATE_DIRTY = 0;
const STATE_CLEAN = 1;
/**
* @var array The array of SQL parts collected.
*/
private $SQLBlocks = [
'select' => [],
'from' => [],
'join' => [],
'set' => [],
'where' => null,
'groupBy' => [],
'having' => null,
'orderBy' => [],
'values' => [],
'limit' => null
];
/**
*
* Either appends to or replaces a single, generic query part.
*
* The available parts are: 'select', 'from', 'set', 'where',
* 'groupBy', 'having' and 'orderBy'.
*
* @param $sqlPartName
* @param $sqlPart
* @param bool $append
* @return $this
*/
private function addSQLBlock($sqlPartName, $sqlPart, $append = false)
{
$isArray = is_array($sqlPart);
$isMultiple = is_array($this->SQLBlocks[$sqlPartName]);
if ($isMultiple && !$isArray)
$sqlPart = array($sqlPart);
$this->SQLState = self::STATE_DIRTY;
.....(some other code that's not relevant)
}
}
所以请谁能告诉我他在做什么以及 STATE_CLEAN 和 STATE_DIRTY consts 的目的是什么,谢谢。