Cml\Debug::addSqlInfo PHP Method

addSqlInfo() public static method

添加一条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时带上执行时间
    public static function addSqlInfo($sql, $type = self::SQL_TYPE_NORMAL, $other = 0)
    {
        switch ($type) {
            case self::SQL_TYPE_FROM_CACHE:
                $sql .= "<span style='color:red;'>[from cache]</span>";
                break;
            case self::SQL_TYPE_SLOW:
                $sql .= "<span style='color:red;'>[slow sql, {$other}]</span>";
                break;
        }
        self::addTipInfo($sql, self::TIP_INFO_TYPE_SQL);
    }

Usage Example

Example #1
0
 /**
  * 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);
 }
All Usage Examples Of Cml\Debug::addSqlInfo