src/Charcoal/Source/DatabaseSource.php
public function dbQuery($query, array $binds = [], array $types = [])
    {
        $this->logger->debug($query, $binds);
        $sth = $this->db()->prepare($query);
        if (!$sth) {
            return false;
        }

        if (!empty($binds)) {
            foreach ($binds as $key => $val) {
                if ($binds[$key] === null) {
                    $types[$key] = PDO::PARAM_NULL;
                } elseif (!is_scalar($binds[$key])) {
                    $binds[$key] = json_encode($binds[$key]);
                }
                $type  = (isset($types[$key]) ? $types[$key] : PDO::PARAM_STR);
                $param = ':'.$key;
                $sth->bindParam($param, $binds[$key], $type);
            }
        }

        $result = $sth->execute();
        if ($result === false) {
            return false;
        }

        return $sth;
    }
public function dbQuery($query, array $binds = [], array $types = [])
    {
        $this->logger->debug($query, $binds);
        $sth = $this->db()->prepare($query);
        if (!$sth) {
            return false;
        }

        if (!empty($binds)) {
            foreach ($binds as $key => $val) {
                if ($binds[$key] === null) {
                    $types[$key] = PDO::PARAM_NULL;
                } elseif (!is_scalar($binds[$key])) {
                    $binds[$key] = json_encode($binds[$key]);
                }
                $type  = (isset($types[$key]) ? $types[$key] : PDO::PARAM_STR);
                $param = ':'.$key;
                $sth->bindParam($param, $binds[$key], $type);
            }
        }

        $result = $sth->execute();
        if ($result === false) {
            return false;
        }

        return $sth;
    }
public function dbQuery ( $ query , array $ binds = [ ] , array $ types = [ ] ) { $ this -> logger -> debug ( $ query , $ binds ) ; $ sth = $ this -> db ( ) -> prepare ( $ query ) ; if ( ! $ sth ) { return false ; } if ( ! empty ( $ binds ) ) { foreach ( $ binds as $ key => $ val ) { if ( $ binds [ $ key ] === null ) { $ types [ $ key ] = PDO :: PARAM_NULL ; } elseif ( ! is_scalar ( $ binds [ $ key ] ) ) { $ binds [ $ key ] = json_encode ( $ binds [ $ key ] ) ; } $ type = ( isset ( $ types [ $ key ] ) ? $ types [ $ key ] : PDO :: PARAM_STR ) ; $ param = ':' . $ key ; $ sth -> bindParam ( $ param , $ binds [ $ key ] , $ type ) ; } } $ result = $ sth -> execute ( ) ; if ( $ result === false ) { return false ; } return $ sth ; }
Execute a SQL query, with PDO, and returns the PDOStatement.

If the query fails, this method will return false.

@param  string $query The SQL query to executed.
@param  array  $binds Optional. Query parameter binds.
@param  array  $types Optional. Types of parameter bindings.
@return \PDOStatement|false The PDOStatement, otherwise FALSE.
Execute a SQL query with PDO and returns the PDOStatement .