RedBeanPHP\QueryWriter\AQueryWriter::glueSQLCondition PHP 메소드

glueSQLCondition() 공개 메소드

또한 보기: QueryWriter::glueSQLCondition
public glueSQLCondition ( $sql, $glue = NULL )
    public function glueSQLCondition($sql, $glue = NULL)
    {
        static $snippetCache = array();
        if (trim($sql) === '') {
            return $sql;
        }
        $key = $glue . '|' . $sql;
        if (isset($snippetCache[$key])) {
            return $snippetCache[$key];
        }
        $lsql = ltrim($sql);
        if (preg_match('/^(INNER|LEFT|RIGHT|JOIN|AND|OR|WHERE|ORDER|GROUP|HAVING|LIMIT|OFFSET)\\s+/i', $lsql)) {
            if ($glue === QueryWriter::C_GLUE_WHERE && stripos($lsql, 'AND') === 0) {
                $snippetCache[$key] = ' WHERE ' . substr($lsql, 3);
            } else {
                $snippetCache[$key] = $sql;
            }
        } else {
            $snippetCache[$key] = ($glue === QueryWriter::C_GLUE_AND ? ' AND ' : ' WHERE ') . $sql;
        }
        return $snippetCache[$key];
    }