Exemple #1
0
 /**
  * Overrides setError() in order to also write the error message to the log file
  *
  * @param   string  $error  The error message
  *
  * @return  void
  *
  * @see  AEAbstractObject#setError($error)
  */
 public function setError($error)
 {
     parent::setError($error);
     AEUtilLogger::WriteLog(_AE_LOG_ERROR, $error);
 }
Exemple #2
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 AEAbstractObject $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)
 {
     if (!is_array($data)) {
         return null;
     }
     // No valid data?
     if (empty($data)) {
         return null;
     }
     // No data at all?
     $db = AEFactory::getDatabase($this->get_platform_database_options());
     if (is_null($id)) {
         // Create a new record
         $sql_fields = array();
         $sql_values = '';
         foreach ($data as $key => $value) {
             $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;
     }
 }