PHP Class Pheasant\Database\Binder

Afficher le fichier Open project: lox/pheasant Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

bind() public méthode

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

escape() public méthode

Escapes any characters not allowed in an SQL string
public escape ( $string ) : string
Résultat string

magicBind() public méthode

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
Résultat string

quote() public méthode

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

reduce() public méthode

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

sqlValue() public méthode

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
Résultat string