Coverts an SQL statement into PDO statement object and binds all values.

@param string $sqlStatement
@param array $bindingValues
@return \PDOStatement
@throws DatabaseException()
553161
protected function prepareStatement(string $sqlStatement, array $bindingValues): \PDOStatement
    {
        $pdoStatement = $this->connection->prepare($sqlStatement);
        if ($pdoStatement === false) {
            $this->throwError($this->connection->errorInfo());
        }

        foreach ($bindingValues as $key => $value) {
            if (is_int($value)) {
                $pdoStatement->bindValue($key, $value, \PDO::PARAM_INT);
            } elseif (is_bool($value)) {
                $pdoStatement->bindValue($key, $value, \PDO::PARAM_BOOL);
            } elseif (is_null($value)) {
                $pdoStatement->bindValue($key, $value, \PDO::PARAM_NULL);
            } else {
                $pdoStatement->bindValue($key, $value, \PDO::PARAM_STR);
            }
        }

        return $pdoStatement;
    }
581710
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
    {
        return $this->getSpatialPlatform($platform)->convertToDatabaseValueSQL($this, $sqlExpr);
    }
1350718
public function affectingStatement($query, $bindings = array())
	{
		return $this->run($query, $bindings, function($me, $query, $bindings)
		{
			if ($me->pretending()) return 0;

			// For update or delete statements, we want to get the number of rows affected
			// by the statement and return that back to the developer. We'll first need
			// to execute the statement and then we'll use PDO to fetch the affected.
			$statement = $me->getPdo()->prepare($query);

			$statement->execute($me->prepareBindings($bindings));

			return $statement->rowCount();
		});
	}
618927
private function prepareRowLogic(array &$columns, ?string &$operator, array &$values)
    {
        $values = array_values($values);

        foreach ($values as $key => &$value) {
            $value = $this->prepareRow($value);

            $operator = $this->prepareRowOperator($operator, $value, $key);

            if ($operator === 'IN' and count($value) !== count($columns)) {
                throw new SqlException('Wrong row value count in condition on key #' . $key . '.');
            }
        }
        unset($value);

        return $this;
    }
1309658
public function write(string $sql, array $bindings = [], bool $exception = true)
    {
        return $this->transport()->write($sql, $bindings, $exception);
    }
9021
public function bindValues(
        /*# string */ $sql,
        array &$bindings,
        array $settings
    )/*# : string */ {
        // make sure escape function ok
        $this->setEscapeCallable($settings['escapeFunction']);

        // replace each placeholder with corresponding ?/:name/value
        return preg_replace_callback(
            '/\b__PHQUERY_[^_]++__\b/',
            function ($m) use (&$bindings, $settings) {
                return $this->replacePlaceholders($m[0], $bindings, $settings);
            },
            $sql
        );
    }
26054
public function select($query, $bindings = [], $useReadPdo = true) {
    $types = [];

    $rows = $this->run($query, $bindings, function($query, $bindings) use($useReadPdo, &$types) {
      if($this->pretending()) {
        return [];
      }

      $statement = $this->getPdoForSelect($useReadPdo)->prepare($query);
      $statement->execute($this->prepareBindings($bindings));

      for($i = 0; $i < $statement->columnCount(); $i++) {
        $meta = $statement->getColumnMeta($i);

        if($meta !== false) {
          $type = $meta['native_type'];

          if(isset($meta['sqlite:decl_type'])) {
            if($meta['sqlite:decl_type'] === 'datetime') {
              $type = $meta['sqlite:decl_type'];
            }
          }

          $types[$meta['name']] = strtolower($type);
        }
      }

      return $statement->fetchAll(PDO::FETCH_ASSOC);
    });

    foreach($rows as &$row) {
      foreach($row as $col => &$value) {
        if($value !== null) {
          switch($types[$col]) {
            case 'long':
            case 'integer':
              $value = (int)$value;
            break;

            case 'double':
              $value = (float)$value;
            break;

            case 'timestamp':
            case 'datetime':
              if(strpos($value, '.') === false) {
                $value = strtotime($value);
              } else {
                $value = (float)DateTime::createFromFormat('Y-m-d H:i:s.u', $value)->format('U.u');
              }
            break;
          }
        }
      }
    }

    return $rows;
  }
661388
public static function executeStmt($stmt, $types, $inserts) {
        self::init();
        try {
            if(!$stmt) {
                throw new DbException('Statement not established');
            } elseif(!$stmt->bind_param($types, ...$inserts)) {
                throw new DbException('Binding error');
            }
            $stmt->execute();
        } catch(DbException $e) {
            self::$_ops->formatError($inserts, $e->getMessage());
        } finally {
            return self::evaluateQuery($stmt);
        }

    }
176071
public function sql(ValueBinder $generator)
    {
        $parts = [];
        $parts[] = 'CASE';
        foreach ($this->_conditions as $k => $part) {
            $value = $this->_values[$k];
            $parts[] = 'WHEN ' . $this->_compile($part, $generator) . ' THEN ' . $this->_compile($value, $generator);
        }
        if ($this->_elseValue !== null) {
            $parts[] = 'ELSE';
            $parts[] = $this->_compile($this->_elseValue, $generator);
        }
        $parts[] = 'END';

        return implode(' ', $parts);
    }
480421
private static function executePrepareQuery($sqlstatement, array $data = [])
    {
        $pdostatement = static::$adapter
            ->getConnection()
            ->prepare($sqlstatement);

        static::$adapter->bind(
            $pdostatement,
            Sanitize::make($data, true)
        );

        $pdostatement->execute();

        $r = $pdostatement->rowCount();

        return $r;
    }
1365933
public function addBindingsToStatement(PDOStatement $stmt, array $bindings)
    {
        foreach ($bindings as $key => &$binding) {
            $value  = &$binding;
            $type   = PDO::PARAM_STR;
            $length = -1;

            if (is_array($binding)) {
                $value  = &$binding['value'];
                $type   = array_key_exists('type', $binding) ? $binding['type'] : PDO::PARAM_STR;
                $length = array_key_exists('length', $binding) ? $binding['length'] : -1;
            }

            $stmt->bindParam(':' . $key, $value, $type, $length);
        }

        return $stmt;
    }
712039
public function setSqlStatement($sqlStatement, array $SqlBinds = [])
    {
        $this->sqlStatement = $sqlStatement;
        $this->sqlBinds = $SqlBinds;

        return $this;
    }
1068321
public static function statement($sqlstatement)
    {
        static::verifyConnection();

        if (!preg_match(
            "/^((drop|alter|create)\s+(?:(?:temp|temporary)\s+)?table|truncate|call)(\s+)?(.+?);?$/i",
            $sqlstatement
        )) {
            throw new DatabaseException(
                'Syntax Error on the Request',
                E_USER_ERROR
            );
        }

        return static::$adapter
            ->getConnection()
            ->exec($sqlstatement) === 0;
    }
437874
public function statement($query, $bindings = array())
	{
		return $this->run($query, $bindings, function($me, $query, $bindings)
		{
			if ($me->pretending()) return true;

			$bindings = $me->prepareBindings($bindings);

			return $me->getPdo()->prepare($query)->execute($bindings);
		});
	}
434027
public function createStatementFromProcedure($procedureName, array $bindings, $cursorName = false)
    {
        $sql = $this->createSqlFromProcedure($procedureName, $bindings, $cursorName);

        return $this->getPdo()->prepare($sql);
    }
1028364
public static function insert($sqlstatement, array $data = [])
    {
        static::verifyConnection();

        if (!preg_match(
            "/^insert\s+into\s+[\w\d_-`]+\s?(\(.+\))?\s+(values\s?(\(.+\),?)+|\s?set\s+(.+)+);?$/i",
            $sqlstatement
        )) {
            throw new DatabaseException(
                'Syntax Error on the Request',
                E_USER_ERROR
            );
        }

        if (empty($data)) {
            $pdoStement = static::$adapter->getConnection()->prepare($sqlstatement);

            $pdoStement->execute();

            return $pdoStement->rowCount();
        }

        $collector = [];
        
        $r = 0;

        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $r += static::executePrepareQuery($sqlstatement, $value);

                continue;
            }

            $collector[$key] = $value;
        }

        if (!empty($collector)) {
            return static::executePrepareQuery($sqlstatement, $collector);
        }

        return $r;
    }
1347873
public static function selectOne($sqlstatement, array $data = [])
    {
        static::verifyConnection();

        if (!preg_match("/^select\s.+?\sfrom\s.+;?$/i", $sqlstatement)) {
            throw new DatabaseException(
                'Syntax Error on the Request',
                E_USER_ERROR
            );
        }

        // Prepare query
        $pdostatement = static::$adapter
            ->getConnection()
            ->prepare($sqlstatement);

        // Bind data
        static::$adapter->bind($pdostatement, $data);

        // Execute query
        $pdostatement->execute();

        return Sanitize::make($pdostatement->fetch());
    }