Exemplo n.º 1
0
 /**
  * Create a new record for the object in database
  *
  * @return boolean
  */
 public function create()
 {
     $this->db->insert("classes", array("name" => $this->model->getName()));
     $this->model->setId($this->db->lastInsertId());
     $this->model->setCreationDate(time());
     $this->model->setModificationDate(time());
     $this->save();
 }
Exemplo n.º 2
0
 public function __destruct()
 {
     // write sql change log for deploying to production system
     if (!empty($this->_sqlChangeLog)) {
         $log = implode("\n\n\n", $this->_sqlChangeLog);
         $filename = "db-change-log_" . time() . "_class-" . $this->model->getName() . ".sql";
         $file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $filename;
         if (defined("PIMCORE_DB_CHANGELOG_DIRECTORY")) {
             $file = PIMCORE_DB_CHANGELOG_DIRECTORY . "/" . $filename;
         }
         $logContent = '';
         if (file_exists($filename) && is_readable($filename)) {
             $logContent = file_get_contents($filename) . "\n\n\n";
         }
         file_put_contents($logContent . $file, $log);
         chmod($file, 0766);
         $this->_sqlChangeLog = array();
     }
 }