Pimcore\Model\Document\Dao::create PHP Метод

create() публичный Метод

Insert a new row to the database.
public create ( )
    public function create()
    {
        try {
            $this->db->insert("documents", ["key" => $this->model->getKey(), "path" => $this->model->getRealPath(), "parentId" => $this->model->getParentId(), "index" => 0]);
            $date = time();
            $this->model->setId($this->db->lastInsertId());
            if (!$this->model->getKey()) {
                $this->model->setKey($this->model->getId());
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }

Usage Example

Пример #1
0
 /**
  * Create a new record for the object in the database
  *
  * @throws \Exception
  */
 public function create()
 {
     try {
         parent::create();
         $this->db->insert("documents_link", ["id" => $this->model->getId()]);
     } catch (\Exception $e) {
         throw $e;
     }
 }