예제 #1
0
 /**
  * Write to the log
  *
  * @param  array $logEntry
  * @return Db
  */
 public function writeLog(array $logEntry)
 {
     $columns = [];
     $params = [];
     $i = 1;
     foreach ($logEntry as $column => $value) {
         $placeholder = $this->sql->getPlaceholder();
         if ($placeholder == ':') {
             $placeholder .= $column;
         } else {
             if ($placeholder == '$') {
                 $placeholder .= $i;
             }
         }
         $columns[$column] = $placeholder;
         $params[$column] = $value;
         $i++;
     }
     $this->sql->insert($columns);
     $this->sql->db()->prepare((string) $this->sql)->bindParams($params)->execute();
     return $this;
 }
예제 #2
0
파일: Db.php 프로젝트: popphp/pop-log
 /**
  * Write to a custom log
  *
  * @param  string $content
  * @return Db
  */
 public function writeCustomLog($content)
 {
     $fields = ['timestamp' => date('Y-m-d H:i:s'), 'level' => -1, 'name' => 'CUSTOM', 'message' => $content, 'context' => ''];
     $columns = [];
     $params = [];
     $i = 1;
     foreach ($fields as $column => $value) {
         $placeholder = $this->sql->getPlaceholder();
         if ($placeholder == ':') {
             $placeholder .= $column;
         } else {
             if ($placeholder == '$') {
                 $placeholder .= $i;
             }
         }
         $columns[$column] = $placeholder;
         $params[$column] = $value;
         $i++;
     }
     $this->sql->insert($columns);
     $this->sql->db()->prepare((string) $this->sql)->bindParams($params)->execute();
     return $this;
 }