Ejemplo n.º 1
0
 /**
  * Overrides setWarning() in order to also write the warning  message to the log file
  *
  * @param   string $warning The warning message
  *
  * @codeCoverageIgnore
  *
  * @return  void
  */
 public function setWarning($warning)
 {
     parent::setWarning($warning);
     Factory::getLog()->log(LogLevel::WARNING, $warning);
 }
Ejemplo n.º 2
0
 /**
  * Overrides setError() in order to also write the error message to the log file
  *
  * @param   string $error The error message
  *
  * @codeCoverageIgnore
  *
  * @return  void
  */
 public function setError($error)
 {
     parent::setError($error);
     Factory::getLog()->log(LogLevel::ERROR, $error);
 }
Ejemplo n.º 3
0
 /**
  * Resets the error condition in the driver. Useful to reset the error state after handling a thrown exception.
  *
  * @return $this for chaining
  */
 public function resetErrors()
 {
     $this->errorNum = 0;
     $this->errorMsg = '';
     parent::resetErrors();
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Creates or updates the statistics record of the current backup attempt
  *
  * @param int                        $id     Backup record ID, use null for new record
  * @param array                      $data   The data to store
  * @param \Akeeba\Engine\Base\Object $caller The calling object
  *
  * @return int|null|bool The new record id, or null if this doesn't apply, or false if it failed
  */
 public function set_or_update_statistics($id = null, $data = array(), &$caller)
 {
     // No valid data?
     if (!is_array($data)) {
         return null;
     }
     // No data at all?
     if (empty($data)) {
         return null;
     }
     $db = Factory::getDatabase($this->get_platform_database_options());
     $tableFields = $db->getTableColumns($this->tableNameStats);
     $tableFields = array_keys($tableFields);
     if (is_null($id)) {
         // Create a new record
         $sql_fields = array();
         $sql_values = '';
         foreach ($data as $key => $value) {
             if (!in_array($key, $tableFields)) {
                 continue;
             }
             $sql_fields[] = $db->qn($key);
             $sql_values .= (!empty($sql_values) ? ',' : '') . $db->Quote($value);
         }
         $sql = $db->getQuery(true)->insert($db->quoteName($this->tableNameStats))->columns($sql_fields)->values($sql_values);
         $db->setQuery($sql);
         try {
             $db->query();
         } catch (\Exception $exc) {
             $caller->setError($exc->getMessage());
             return false;
         }
         return $db->insertid();
     } else {
         $sql_set = array();
         foreach ($data as $key => $value) {
             if ($key == 'id') {
                 continue;
             }
             $sql_set[] = $db->qn($key) . '=' . $db->q($value);
         }
         $sql = $db->getQuery(true)->update($db->qn($this->tableNameStats))->set($sql_set)->where($db->qn('id') . '=' . $db->q($id));
         $db->setQuery($sql);
         try {
             $db->query();
         } catch (\Exception $exc) {
             $caller->setError($exc->getMessage());
             return false;
         }
         return null;
     }
 }