/** * 执行预处理语句 * * @param object $stmt PDOStatement * @param bool $clearBindParams * * @return bool */ public function execute($stmt, $clearBindParams = true) { //empty($param) && $param = $this->bindParams; $this->conf['log_slow_sql'] && ($startQueryTimeStamp = microtime(true)); if (!$stmt->execute()) { $error = $stmt->errorInfo(); throw new \InvalidArgumentException('Pdo execute Sql error!,【Sql : ' . $this->buildDebugSql() . '】,【Error:' . $error[2] . '】'); } $slow = 0; if ($this->conf['log_slow_sql']) { $queryTime = microtime(true) - $startQueryTimeStamp; if ($queryTime > $this->conf['log_slow_sql']) { if (Plugin::hook('cml.mysql_query_slow', ['sql' => $this->buildDebugSql(), 'query_time' => $queryTime]) !== false) { Log::notice('slow_sql', ['sql' => $this->buildDebugSql(), 'query_time' => $queryTime]); } $slow = $queryTime; } } if (Cml::$debug) { $this->debugLogSql($slow > 0 ? Debug::SQL_TYPE_SLOW : Debug::SQL_TYPE_NORMAL, $slow); } $this->currentSql = ''; $clearBindParams && $this->clearBindParams(); return true; }