Solar_Sql_Adapter::quoteMulti PHP 메소드

quoteMulti() 공개 메소드

The placeholder is a question-mark; all placeholders will be replaced with the quoted value. For example ... {{code: php $sql = Solar::factory('Solar_Sql'); $list = array( "WHERE date > ?" => '2005-01-01', " AND date < ?" => '2005-02-01', " AND type IN(?)" => array('a', 'b', 'c'), ); $safe = $sql->quoteMulti($list); $safe = "WHERE date > '2005-01-02' AND date < 2005-02-01 AND type IN('a','b','c')" }}
public quoteMulti ( array $list, string $sep = null ) : string
$list array A series of key-value pairs where the key is the placeholder text and the value is the value to be quoted into it. If the key is an integer, it is assumed that the value is piece of literal text to be used and not quoted.
$sep string Return the list pieces separated with this string (for example ' AND '), default null.
리턴 string An SQL-safe string composed of the list keys and quoted values.
    public function quoteMulti($list, $sep = null)
    {
        $text = array();
        foreach ((array) $list as $key => $val) {
            if (is_int($key)) {
                // integer $key means a literal phrase and no value to
                // be bound into it
                $text[] = $val;
            } else {
                // string $key means a phrase with a placeholder, and
                // $val should be bound into it.
                $text[] = $this->quoteInto($key, $val);
            }
        }
        // return the condition list
        $result = implode($sep, $text);
        return $result;
    }