SQL 查询状态

SQL Query State

我看到了另一位开发人员编写的一些代码。这是一个 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 常量的目的是什么 谢谢。

我能想到的是 STATE_DIRTY/STATE_CLEAN 是某种标志,告诉 $this->SQLBlocks 表示的查询主体是否已从上次使用该对象时更改或未更改. 如果我错了有人纠正我