PHP Class Pheasant\Database\Binder

Datei anzeigen Open project: lox/pheasant Class Usage Examples

Public Methods

Method Description
_bindInto ( $pattern, $sql, $params, $func ) Bind parameters into a particular pattern, skipping quoted strings which might have question marks in them.
bind ( $sql, array $params = [] ) : string Interpolates quoted values in a string with ? in it.
escape ( $string ) : string Escapes any characters not allowed in an SQL string
magicBind ( $sql, array $params = [] ) : string Like bind(), but adds some magic: - a=? becomes a IS NULL if passed null - a!=? or a<>? becomes a IS NOT NULL if passed null - a=? becomes a IN (1, 2, 3) if passed array(1, 2, 3) - a!=? or a<>? becomes a NOT IN (1, 2, 3) if passed array(1, 2, 3)
quote ( $string ) : string Surrounds a string with quote marks, null is returned as NULL, bools converted to 1|empty string for compatibility
reduce ( $array ) : string Reduces an array of values into a bracketed, quoted, comma delimited list
sqlValue ( $mixed ) : string Intelligently quotes/escapes based on the provided type. If an object is passed with a toSql() method, that is used, otherwise the php type is used to infer what needs escaping.

Method Details

_bindInto() public method

Bind parameters into a particular pattern, skipping quoted strings which might have question marks in them.
public _bindInto ( $pattern, $sql, $params, $func )

bind() public method

Interpolates quoted values in a string with ? in it.
public bind ( $sql, array $params = [] ) : string
$params array
return string

escape() public method

Escapes any characters not allowed in an SQL string
public escape ( $string ) : string
return string

magicBind() public method

Like bind(), but adds some magic: - a=? becomes a IS NULL if passed null - a!=? or a<>? becomes a IS NOT NULL if passed null - a=? becomes a IN (1, 2, 3) if passed array(1, 2, 3) - a!=? or a<>? becomes a NOT IN (1, 2, 3) if passed array(1, 2, 3)
public magicBind ( $sql, array $params = [] ) : string
$params array
return string

quote() public method

Surrounds a string with quote marks, null is returned as NULL, bools converted to 1|empty string for compatibility
public quote ( $string ) : string
return string

reduce() public method

Reduces an array of values into a bracketed, quoted, comma delimited list
public reduce ( $array ) : string
return string

sqlValue() public method

Intelligently quotes/escapes based on the provided type. If an object is passed with a toSql() method, that is used, otherwise the php type is used to infer what needs escaping.
public sqlValue ( $mixed ) : string
return string