/** * Efface l'entité en base de donnée * @return boolean */ public function remove() { $field = $this->_storage->get($this->_config->getPrimaryKey()); $value = $field->getValue(); // Si la valeur est vide if (empty($value)) { return FALSE; } // Exécute la requête return $this->db()->where($field->getName(), $value)->delete($this->_config->getTable()); }
/** * Créer une jointure en SQL * @param \Origami\Entity $entity * @param string|null $cond * @param string|null $type * @param string|null $escape * @return \Origami\Entity\Manager\Query */ public function join($entity, $cond = NULL, $type = NULL, $escape = NULL) { if ($cond === NULL) { $cond = "{$entity::table()}.{$this->config->getTable()}_{$this->config->getPrimaryKey()} = {$this->config->getTable()}.{$this->config->getPrimaryKey()}"; } if ($type === NULL) { $type = ""; } \Origami\DB::get($this->config->getDataBase())->join($entity::table(), $cond, $type, $escape); return $this; }
/** * Modifie le nom de la clé primaire * @param \Origami\Entity\Manager\Config $config */ public function setName(\Origami\Entity\Manager\Config &$config) { $this->name = $config->getPrimaryKey(); }