public function remove()
 {
     $sql = "DELETE FROM `" . $this->tableName . "` WHERE 1=1 ";
     $binds = array();
     for ($pkeyNum = 0; count($this->pkeys) > $pkeyNum; $pkeyNum++) {
         $sql .= " AND `" . $this->pkeys[$pkeyNum] . "` = :" . $this->pkeys[$pkeyNum] . " ";
         $binds[$this->pkeys[$pkeyNum]] = $this->{$this->pkeys[$pkeyNum]};
     }
     if (count($binds) > 0) {
         // DB操作実行
         $response = $this->_DBO->execute($sql, $binds);
         if (FALSE === $response) {
             // XXX イレギュラー
             throw new Exception("");
         }
     }
 }
Beispiel #2
0
 /**
  * Fonction permettant de supprimer un utilisateur
  * @param  Int $id_users Id de l'user
  */
 public function deleteUser($id_users)
 {
     $query = 'DELETE FROM users WHERE id_users = :id';
     $tab = array('id' => $id_users);
     $resultat = $this->db->execute($query, $tab);
 }
Beispiel #3
0
 /**
  * Fonction permettant de supprimer des association articles avec categories
  * @param  Int $id_categories Id de la catégorie
  * @param  Int $id_articles   Id de l'article
  */
 public function deleteAsso_Art_Categ($id_categories, $id_articles)
 {
     $query = "DELETE FROM asso_art_categ WHERE id_categories = :id_categories AND id_articles = :id_articles";
     $tab = array('id_categories' => $id_categories, 'id_articles' => $id_articles);
     $this->db->execute($query, $tab);
 }
Beispiel #4
0
 /**
  * Fonction permettant de supprimer un article avec son id
  * @param Int $id_articles ID de l'article
  */
 public function deleteArticle($id_articles)
 {
     $query = 'DELETE FROM articles WHERE id_articles = :id';
     $tab = array('id' => $id_articles);
     $this->db->execute($query, $tab);
 }
 /**
  * alterのマイグレーションを適用する
  * @param instance $argDBO
  * @return boolean
  */
 public function alter($argDBO, $argDescribes)
 {
     $executed = FALSE;
     // ALTERは一行づつ処理
     foreach ($argDescribes as $field => $propaty) {
         $sql = '';
         if ('DROP' === $propaty['alter']) {
             $sql = 'ALTER TABLE `' . $this->tableName . '` DROP COLUMN `' . $field . '`';
         } else {
             $fielPropatyQuerys = $this->_getFieldPropatyQuery(array($field => $propaty));
             $fieldDef = $fielPropatyQuerys['fieldDef'];
             if (strlen($fieldDef) > 0) {
                 $sql = 'ALTER TABLE `' . $this->tableName . '` ' . $propaty['alter'] . ' COLUMN ' . $fieldDef;
                 if (isset($propaty['first']) && TRUE === $propaty['first']) {
                     $sql .= ' FIRST ';
                 } else {
                     if (isset($propaty['after']) && 0 < strlen($propaty['after'])) {
                         $sql .= ' AFTER `' . $propaty['after'] . '`';
                     }
                 }
             }
         }
         if (strlen($sql) > 0) {
             try {
                 debug('migration alter sql=' . $sql);
                 $argDBO->execute($sql);
                 $executed = TRUE;
             } catch (Exception $Exception) {
                 logging($Exception->getMessage(), 'exception');
                 // ALTERのADDは、2重実行でエラーになるので、ここでのExceptionは無視してModfyを実行してみる
                 $sql = str_replace('ALTER TABLE `' . $this->tableName . '` ' . $propaty['alter'] . ' COLUMN ', 'ALTER TABLE `' . $this->tableName . '` MODIFY COLUMN ', $sql);
                 // MODIFYに変えて実行しなおし
                 $argDBO->execute($sql);
                 $executed = TRUE;
                 // XXX それでもダメならException!
             }
         }
     }
     if (TRUE === $executed) {
         $argDBO->commit();
     }
     return TRUE;
 }