src/Dao/AbstractDao.php
protected function bind( $stmt, $values ) {
		$values = $values ?: [];

		if ( (bool)count( array_filter( array_keys( $values ), 'is_string' ) ) ) {
			// associative array provided
			foreach ( $values as $key => $value ) {
				// infer bind type from key prefix
				list( $prefix, $ignored ) = explode( '_', "{$key}_", 2 );

				$type = \PDO::PARAM_STR;
				switch ( $prefix ) {
					case 'int':
						$type = \PDO::PARAM_INT;
						break;
					case 'bool':
						$type = \PDO::PARAM_BOOL;
						break;
					case 'null':
						$type = \PDO::PARAM_NULL;
						break;
					default:
						$type = \PDO::PARAM_STR;
				}

				$stmt->bindValue( $key, $value, $type );
			}

		} else {
			// vector provided
			$idx = 1;
			foreach ( $values as $value ) {
				$stmt->bindValue( $idx, $value );
				$idx++;
			}
		}
	}
protected function bind( $stmt, $values ) {
		$values = $values ?: [];

		if ( (bool)count( array_filter( array_keys( $values ), 'is_string' ) ) ) {
			// associative array provided
			foreach ( $values as $key => $value ) {
				// infer bind type from key prefix
				list( $prefix, $ignored ) = explode( '_', "{$key}_", 2 );

				$type = \PDO::PARAM_STR;
				switch ( $prefix ) {
					case 'int':
						$type = \PDO::PARAM_INT;
						break;
					case 'bool':
						$type = \PDO::PARAM_BOOL;
						break;
					case 'null':
						$type = \PDO::PARAM_NULL;
						break;
					default:
						$type = \PDO::PARAM_STR;
				}

				$stmt->bindValue( $key, $value, $type );
			}

		} else {
			// vector provided
			$idx = 1;
			foreach ( $values as $value ) {
				$stmt->bindValue( $idx, $value );
				$idx++;
			}
		}
	}
protected function bind ( $ stmt , $ values ) { $ values = $ values ? : [ ] ; if ( ( bool ) count ( array_filter ( array_keys ( $ values ) , 'is_string' ) ) ) { // associative array provided foreach ( $ values as $ key => $ value ) { // infer bind type from key prefix list ( $ prefix , $ ignored ) = explode ( '_' , "{$key}_" , 2 ) ; $ type = \ PDO :: PARAM_STR ; switch ( $ prefix ) { case 'int' : $ type = \ PDO :: PARAM_INT ; break ; case 'bool' : $ type = \ PDO :: PARAM_BOOL ; break ; case 'null' : $ type = \ PDO :: PARAM_NULL ; break ; default : $ type = \ PDO :: PARAM_STR ; } $ stmt -> bindValue ( $ key , $ value , $ type ) ; } } else { // vector provided $ idx = 1 ; foreach ( $ values as $ value ) { $ stmt -> bindValue ( $ idx , $ value ) ; $ idx ++ ; } } }
Bind values to a prepared statement.

If an associative array of values is provided, the data type to use when
binding will be inferred by looking for a "<type>_" prefix at the
beginning of the array key. This can come in very handy if you are using
parameters in places like LIMIT clauses where binding as a string (the
default type for PDO binds) will cause a syntax error.

@param \PDOStatement $stmt Previously prepared statement
@param array $values Values to bind
Bind values to a prepared statement .