public static function bindToStatement(PDOStatement $statement, array $bindings=[])
    {
        foreach ($bindings as $key=>$value) {

            $casted = is_bool($value) ? (int)$value : $value;

            $statement->bindValue(
                is_string($key) ? $key : $key + 1,
                $casted,
                is_int($casted) ? PDO::PARAM_INT : ($casted === null ? PDO::PARAM_NULL : PDO::PARAM_STR)
            );

        }
    }
public static function bindToStatement(PDOStatement $statement, array $bindings=[])
    {
        foreach ($bindings as $key=>$value) {

            $casted = is_bool($value) ? (int)$value : $value;

            $statement->bindValue(
                is_string($key) ? $key : $key + 1,
                $casted,
                is_int($casted) ? PDO::PARAM_INT : ($casted === null ? PDO::PARAM_NULL : PDO::PARAM_STR)
            );

        }
    }
public static function bindToStatement ( PDOStatement $ statement , array $ bindings = [ ] ) { foreach ( $ bindings as $ key => $ value ) { $ casted = is_bool ( $ value ) ? ( int ) $ value : $ value ; $ statement -> bindValue ( is_string ( $ key ) ? $ key : $ key + 1 , $ casted , is_int ( $ casted ) ? PDO :: PARAM_INT : ( $ casted === null ? PDO :: PARAM_NULL : PDO :: PARAM_STR ) ) ; } }
Add bindings to a statement. Cast integers, null, bool and string.

@param PDOStatement $statement
@param array $bindings
Add bindings to a statement . Cast integers null bool and string .