Ejemplo n.º 1
0
 protected function debug($sql)
 {
     if (!self::$debug) {
         return;
     }
     if (strtolower(self::$debug) == "firephp") {
         switch (true) {
             case is_numeric(strpos($sql, "UPDATE")):
             case is_numeric(strpos($sql, "DELETE")):
                 LBoxFirePHP::warn(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql));
                 break;
             default:
                 LBoxFirePHP::log(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql));
         }
     } else {
         switch (true) {
             case is_numeric(strpos($sql, "UPDATE")):
             case is_numeric(strpos($sql, "DELETE")):
                 $bg = "#962C2C";
                 break;
             case is_numeric(strpos($sql, "INSERT")):
                 $bg = "#6BC764";
                 break;
             default:
                 $bg = "#5D5D5D";
         }
         $color = "#ffffff";
         $msg = "<table><th bgcolor='{$bg}' align='left'><font color='#C0C0C0'>" . round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . "</font></th><th bgcolor='{$bg}' align='left'><b><font color='{$color}'>" . nl2br(self::$queryCount . ": " . $sql) . "</font></b></th></table>\n";
         echo $msg;
         flush();
     }
 }
Ejemplo n.º 2
0
 /**
  * adds columns by $columns - columns must be defined in $atttributes
  * @param array $columns
  * @throws Exception
  */
 protected function addColumns($columns = array())
 {
     try {
         $tableName = $this->getClassVar("tableName");
         $attributes = $this->getClassVar("attributes");
         $cols = array();
         LBoxFirePHP::log("adding columns into '{$tableName}': " . implode(", ", $columns));
         foreach ($columns as $column) {
             foreach ($attributes as $attribute) {
                 if ($attribute["name"] == $column) {
                     $cols[] = $attribute;
                 }
                 // write empty param for checkAttributesColumnsExists checking
                 $this->params[$column] = "";
             }
         }
         $this->getDb()->initiateQuery($this->getQueryBuilder()->getAddColumns($tableName, $cols));
         $this->resetCache();
         $this->isCacheSynchronized = false;
     } catch (Exception $e) {
         throw $e;
     }
 }