执行传入的sql，prepare、execute。并返$stmt
@param array $parameters 绑定参数
@return bool|\PDOStatement
@throws \Exception
3516
public function execute($parameters = [])
    {
        $this->_fields = "*"; //重置 select
        if(X_DEBUG){
            $sql = $this->sql;
            foreach ($parameters as $k=>$v){
                $sql = str_replace(':'.$k,$v,$sql);
            }
            $this->queries[] = $sql;
        }
        try {
            $stmt = $this->pdo->prepare($this->sql);
            $stmt->execute($parameters);
            $stmt->setFetchMode(\PDO::FETCH_ASSOC);
            return $stmt;
        } catch (\PDOException $e) {
            X::app()->exception($e, $this->sql);
        }
        return false;
    }
534479
public function execute($params = null) {
		if ($params === null) {
			$params = [];
		}

		try {
			$this->stmt->execute($params);

			return new QueryResult($this->stmt, $this->pdo);
		} catch (PDOException $e) {
			throw $this->exAdapter->adapt($e, $this->stmt, $params);
		}
	}
695620
public static void fillParameters(PreparedStatement stmt, List<Object> params) throws SQLException {

        int i = 1;
        for (Object param : params) {
            if (param instanceof String) {
                stmt.setString(i, (String)param);
            } else if (param instanceof Integer) {
                stmt.setInt(i, ((Integer)param).intValue());
            } else if (param instanceof Long) {
                stmt.setLong(i, ((Long)param).longValue());
            } else {
                throw new IllegalArgumentException();
            }
            i += 1;
        }
    }
380950
public static function exec($sql, $params = [])
    {
        BLLog::log('[SQL] ' . $sql);
        BLLog::log('[Params] ' . var_export($params, true));
        $stmt = self::getHandle()->prepare($sql);
        $stmt->execute($params);
        return $stmt;
    }
1352699
public function query($database, $query, $parameters = [])
    {
        $driver = $this->getDriver();

        if (!$driver instanceof QueryDriverInterface) {
            throw new Exception('The currently configured driver does not support query operations');
        }

        if ($database) {
            $parameters['db'] = $database;
        }

        $parameters = [
            'url' => 'query?' . http_build_query(array_merge(['q' => $query], $parameters)),
            'database' => $database,
            'method' => 'get'
        ];

        // add authentication to the driver if needed
        if (!empty($this->username) && !empty($this->password)) {
            $parameters += ['auth' => [$this->username, $this->password]];
        }

        $driver->setParameters($parameters);

        try {
            // store the last query sent
            static::$lastQuery = $query;

            // perform the query and return the resultset
            return $driver->query();

        } catch (\Exception $e) {
            throw new Exception('Query has failed', $e->getCode(), $e);
        }
    }
510259
public function execute($params = null)
    {
        if (is_array($params)) {
            $hasZeroIndex = array_key_exists(0, $params);

            foreach ($params as $key => $val) {
                if ($hasZeroIndex && is_int($key)) {
                    $this->bindValue($key + 1, $val);
                } else {
                    $this->bindValue($key, $val);
                }
            }
        }

        if (! sasql_stmt_execute($this->stmt)) {
            throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
        }

        $this->result = sasql_stmt_result_metadata($this->stmt);

        return true;
    }
273156
public function execute($input_parameters = null) {
		if (is_array($input_parameters)) $this->boundValues = $input_parameters;
		
		try {
			$mtime = microtime(true);
			$return = parent::execute($input_parameters);
			if (isset($this->logger)) {
				$this->logger->addPreparedExecution($this->queryString, $this->boundValues, (microtime(true) - $mtime));
			}
			
			if (!$return) {
				$err = error_get_last();
				throw new \PDOException($err['message']);
			}
			
			return $return;
		} catch (\PDOException $e) {
			throw new PdoPreparedExecutionException($e, $this->queryString, $this->boundValues);
		}
	}
223716
public function execute($array, $stmt = 'stmt'): Database
    {
        $this->values = [];
        $this->lastid = null;
        $stmt         = 'prepare_' . $stmt;
        try {
            $sth = $this->$stmt->execute($array);
        } catch (PDOException $e) {
            throw new CoreException(
                __CLASS__.'::execute()->PDOStatement::execute() : '.$e->getMessage()
            );
        }
        if ($sth instanceof PDOStatement) {
            try {
                $this->values = $sth->fetchAll($this->configs['fetch_mode']);
            } catch (PDOException $e) {
                throw new CoreException(
                    __CLASS__.'::execute()->PDOStatement::fetchAll() : '
                    . $e->getMessage()
                );
            }
        }

        $store_sql = $stmt . '_sql';
        if (false !== strpos($this->$store_sql, 'insert')) {
            try {
                $this->lastid = $this->connection->lastInsertId();
            } catch (PDOException $e) {
                throw new CoreException(
                    __CLASS__.'::execute()->PDO::lastInsertId() : '.$e->getMessage()
                );
            }
        }

        return $this;
    }
960888
public function execute(array $params, $stmt = null)
    {
        try {
            if (!is_null($stmt)) {
                $this->stmt = $stmt->execute($params);
            } else {
                if (!$this->stmt) {
                    throw new \Exception("Prepared stetement not found.");
                }
                $this->stmt->execute($params);
            }
            return $this;
        } catch (\PDOException $e) {
            die("Error: " . $e->getMessage());
        } catch (\Exception $e) {
            die("Error: " . $e->getMessage());
        }
    }
578424
public function query($sql, array $parameters = [])
    {
        $parameters = $this->prepareArguments($sql, $parameters);
        $this->sendNotification(
            'query:pre',
            [
                'sql'           => $sql,
                'parameters'    => $parameters,
                'session_stamp' => $this->getSession()->getStamp(),
            ]
        );
        $start    = microtime(true);
        $resource = $this->doQuery($sql, $parameters);
        $end      = microtime(true);

        $iterator = new ConvertedResultIterator(
            $resource,
            $this->getSession()
        );
        $this->sendNotification(
            'query:post',
            [
                'result_count' => $iterator->count(),
                'time_ms'      => sprintf("%03.1f", ($end - $start) * 1000),
            ]
        );

        return $iterator;
    }
554846
protected function insert(array $parameters)
    {
        $query = sprintf(
            "INSERT INTO `{$this->table}` (%s) VALUES (%s)",
            implode(', ', array_values($parameters['c'])),
            implode(', ', array_fill(0, count($parameters['c']), '?'))
        );

        $statement = $this->adapter->getDriver()->prepare($query);

        foreach ($parameters['c'] as $index => $name) {
            $statement->bind($index, $this->properties[$name]['value'], $this->properties[$name]['type']);
        }

        $statement->execute();

        $this->modified = null;
        $this->uid = $this->adapter->getDriver()->getLastInsertId();
    }
269667
public function prepareExecute(string $sql, array $params): ?PDOStatement
	{
		$this->statement = $this->prepareQuery($sql, $params);
		$this->statement->execute();

		return $this->statement;
	}
1071192
protected function bindParameters(\PDOStatement $statement, array $parameters, $prefix = '')
    {
        foreach ($parameters as $key => $value) {
            // In case of multiple rows are given for insert statement
            if (is_array($value)) {
                $statement = $this->bindParameters($statement, $value, $prefix . $key);
            } else {
                switch (true) {
                    case is_int($value):
                        $type = \PDO::PARAM_INT;
                        break;
                    case is_bool($value):
                        $type = \PDO::PARAM_BOOL;
                        break;
                    case $value === null:
                        $type = \PDO::PARAM_NULL;
                        break;
                    case $value instanceof \DateTimeInterface:
                        $type  = \PDO::PARAM_STR;
                        $value = $value->format('Y-m-d H:i:s.u');
                        break;
                    default:
                        $type = \PDO::PARAM_STR;
                }

                $statement->bindValue($prefix . $key, $value, $type);
            }
        }

        return $statement;
    }
1160697
public function execute($query, $parameters = [])
    {
        $startTimestamp = time();

        $exception = null;

        try {
            $result = $this->internalAdapter->execute($query, $parameters);
        } catch (\Exception $e) {
            $exception = $e;
        } finally {
            //log
            $this->log(
                $query,
                $parameters,
                $startTimestamp,
                $exception
            );

            if ($exception) {
                throw $exception;
            }
        }

        return $result;
    }
684792
protected function bindParams(PDOStatement &$stmt, array $values){
		$param_no = 1;

		foreach($values as $v){
			$t    = gettype($v);
			$type = PDO::PARAM_STR;

			if($t === 'boolean'){
				$type = PDO::PARAM_BOOL; // @codeCoverageIgnore
			}
			elseif($t === 'integer'){
				$type = PDO::PARAM_INT;
			}
			elseif($t === 'NULL'){
				$type = PDO::PARAM_NULL; // @codeCoverageIgnore
			}

			$stmt->bindValue($param_no, $v, $type);
			$param_no++;
		}
	}
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;
    }
1332433
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
    {
        if ($cMap->isTemporal()) {
            $value = $this->formatTemporalValue($value, $cMap);
        } elseif (is_resource($value) && $cMap->isLob()) {
            // we always need to make sure that the stream is rewound, otherwise nothing will
            // get written to database.
            rewind($value);
            // pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
            // driver option can be utilized. This requires a unique blob parameter because the bindParam
            // value is passed by reference and if we didn't do this then the referenced parameter value
            // would change on the next loop
            $blob = "blob" . $position;
            $$blob = $value;

            return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
        }

        return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
    }