Ejemplo n.º 1
0
 /**
  * Write a record to the database.
  * @param array $record
  */
 protected function write(array $record)
 {
     $currentDatabase = DatabaseConnectionFactory::getActiveDatabaseId();
     try {
         DatabaseConnectionFactory::select(static::DATABASE);
         $values = ['message' => $record['message'], 'context' => print_r($record['context'], true), 'level' => $record['level_name']];
         static::$table->insert()->values($values)->execute();
     } catch (\Exception $e) {
         // Fail silently, as logging a logging error results in an infinite loop
     } finally {
         DatabaseConnectionFactory::select($currentDatabase);
     }
 }
Ejemplo n.º 2
0
 public function getDatatypeList()
 {
     $list = parent::getDatatypeList();
     $list['serial'] = 'serial';
     $list['longtext'] = 'text';
     $list['mediumtext'] = 'text';
     return $list;
 }
Ejemplo n.º 3
0
 /**
  * Loads a datatype into the passed Table object based on settings in the
  * current Variable object.
  *
  * @param \Database\Table $table
  * @return \Database\Datatype
  * @throws \Exception Error is varname is not set
  */
 public function loadDataType(\Database\Table $table)
 {
     $column_type = empty($this->column_type) ? 'Varchar' : $this->column_type;
     if (empty($this->varname)) {
         throw \Exception('Variable name is not set');
     }
     $dt = $table->addDataType($this->varname, $this->column_type);
     if (isset($this->value)) {
         $dt->setDefault($this->toDatabase());
     } else {
         $dt->setDefault(null);
     }
     if ($this->allowNull()) {
         $dt->setIsNull(true);
     }
     return $dt;
 }
Ejemplo n.º 4
0
 public function insert()
 {
     $row_count = parent::insert();
     if ($this->hasPearSequenceTable()) {
         $tname = $this->getPearSequenceName();
         $this->db->query("update {$tname} set id = id + 1");
     }
     return $row_count;
 }