Пример #1
0
 /**
  * Delete entries
  * 
  * @param  array|string $where SQL WHERE clause(s)
  * @return int|string
  */
 public function delete($id)
 {
     $table = $this->getTable();
     // Get the parent_role from the role will delete
     $role = $this->fetchEntry($id);
     //Zend_Debug::dump($role["role_parent"], "rol que eliminamos");
     //find the roles have the parent role of the role will delete
     $rolsongs = $this->fetchParentRoles($id);
     // Zend_Debug::dump($rolsongs["0"]["id"], "el hijo del rol que eliminaremos");
     //chance the parent_role of the songs
     foreach ($rolsongs as $value) {
         $data["role_parent"] = (int) $role["role_parent"];
         $data["id"] = $value["id"];
         $this->update($data, 'id =' . (int) $value["id"]);
     }
     //find the users with the role will delete
     $users = new User_Model_Users();
     $users->getTable();
     $arrayusers = $users->fetchUsers($id);
     //Zend_Debug::dump($arrayusers,"users with role will delete");
     // chance the role to the users
     foreach ($arrayusers as $value) {
         $data["role_id"] = (int) $rolsongs["0"]["id"];
         $data["id"] = $value["id"];
         Zend_Debug::dump($data, "data1");
         $users->update($data, 'id =' . (int) $value["id"]);
     }
     $table->delete('id =' . (int) $id);
 }