添加一条sql查询的调试信息
public static addSqlInfo ( $sql, integer $type = self::SQL_TYPE_NORMAL, integer $other ) | ||
$sql | ||
$type | integer | sql类型 参考常量声明SQL_TYPE_NORMAL、SQL_TYPE_FROM_CACHE、SQL_TYPE_SLOW |
$other | integer | type = SQL_TYPE_SLOW时带上执行时间 |
/** * Debug模式记录查询语句显示到控制台 * * @param int $type * @param int $other $other type = SQL_TYPE_SLOW时带上执行时间 */ private function debugLogSql($type = Debug::SQL_TYPE_NORMAL, $other = 0) { Debug::addSqlInfo($this->buildDebugSql(), $type, $other); }
/** * Debug模式记录查询语句显示到控制台 * * @param string $type 查询的类型 * @param string $tableName 查询的Collection * @param array $condition 条件 * @param array $options 额外参数 */ private function debugLogSql($type = 'Query', $tableName, $condition = [], $options = []) { if (Cml::$debug) { Debug::addSqlInfo(sprintf("[MongoDB {$type}] Collection: %s, Condition: %s, Other: %s", $this->getDbName() . ".{$tableName}", json_encode($condition, JSON_UNESCAPED_UNICODE), json_encode($options, JSON_UNESCAPED_UNICODE))); } }