public function deleteAction() { if (!$this->hasACL('edit_people')) { $this->doNoAccessError(); } $status = ValidationContainer::instance(); $id = $this->getSanParam('id'); if ($id and !Person::isReferenced($id)) { $trainer = new Trainer(); $rows = $trainer->find($id); $row = $rows->current(); if ($row) { $trainer->delete('person_id = ' . $row->person_id); } $person = new Person(); $rows = $person->find($id); $row = $rows->current(); if ($row) { $person->delete('id = ' . $row->id); } $status->setStatusMessage(t('That person was deleted.')); } else { if (!$id) { $status->setStatusMessage(t('That person could not be found.')); } else { $status->setStatusMessage(t('That person is an active') . ' ' . t('participant') . ' ' . t('or') . ' ' . t('trainer') . ' ' . t('and could not be deleted.')); } } //validate $this->view->assign('status', $status); }
public function delete() { try { $model = new Person($this->data->id); $model->delete(); $go = "!\$('#formObject_dialog').dialog('close');"; $this->renderPrompt('information', _M("Record [%s] removed.", $model->getDescription()), $go); } catch (\Exception $e) { $this->renderPrompt('error', _M("Deletion denied.")); } }
function delete($supplier_id) { $success = false; //Run these queries as a transaction, we want to make sure we do all or nothing $this->db->trans_start(); //delete from customers table if ($this->db->delete('suppliers', array('person_id' => $supplier_id))) { //delete from Person table $success = parent::delete($supplier_id); } $this->db->trans_complete(); return $success; }
public function testDeleteCriteria() { $this->prepareDB(true); $oDriver = DBDriver::get_instance('sqlite', array('filename' => dirname(__FILE__) . '/unittest.db')); $mRes = Person::delete('Person')->where('lastName', 'Piochet')->exec($oDriver); $mRes = Person::select('Person')->where('lastName', 'Piochet')->exec($oDriver); $this->assertEquals(0, $mRes->numRows()); }
public function delete_person($person_id = NULL) { if (is_null($person_id)) { add_error_flash_message('Osoba sa nenašla.'); redirect(site_url('persons')); } $person = new Person(); $person->get_by_id((int) $person_id); if (!$person->exists()) { add_error_flash_message('Osoba sa nenašla.'); redirect(site_url('persons')); } if ($person->id == auth_get_id()) { add_error_flash_message('Nemôžete vymazať vlastný účet.'); redirect(site_url('persons')); } $success_message = 'Osoba <strong>' . $person->name . ' ' . $person->surname . '</strong> s loginom <strong>' . $person->login . '</strong>, a s ID <strong>' . $person->id . '</strong> bola úspešne vymazaná.'; $error_message = 'Osobu <strong>' . $person->name . ' ' . $person->surname . '</strong> s loginom <strong>' . $person->login . '</strong>, a s ID <strong>' . $person->id . '</strong> sa nepodarilo vymazať.'; if ($person->delete()) { unlink_recursive('user/photos/data/' . (int) $person_id . '/', TRUE); add_success_flash_message($success_message); } else { add_error_flash_message($error_message); } redirect(site_url('persons')); }
<?php // require_once 'common.php'; // use Javanile\SchemaDB\Storable; // class Person extends Storable { // public $id = self::PRIMARY_KEY; // public $name = ""; // public $age = 0; } // remove Person table and complete items list Person::drop('confirm'); // import Persons from array-of-array Person::import([['name' => 'Francesco', 'age' => 10], ['name' => 'Paolo', 'age' => 12], ['name' => 'Piero', 'age' => 10], ['name' => 'Antonio', 'age' => 13]]); // printout table record before delete Person::dump(); // delete Person with 10 years old Person::delete(['age' => 10]); // printout table record after delete Person::dump();
public function testDeleteMultiple() { $oDriver = DBDriver::get_instance('mongo'); // Clean up database Person::delete('Person')->where('firstName', 'Jerome')->exec($oDriver); $iCount = 10; for ($i = 0; $i < $iCount; $i++) { $oPerson = new Person(); $oPerson->firstName = 'Jerome'; $oPerson->lastName = 'Poichet'; $mRes = $oPerson->insert()->exec($oDriver); } $oRes = Person::select('Person')->where('firstName', 'Jerome')->exec($oDriver); $this->assertEquals($iCount, $oRes->numRows()); Person::delete('Person')->where('firstName', 'Jerome')->exec($oDriver); $oRes = Person::select('Person')->where('firstName', 'Jerome')->exec($oDriver); $this->assertEquals(0, $oRes->numRows()); }
} // require_once '../data.php'; // require_once '../../SchemaDB.php'; // use SourceForge\SchemaDB\SchemaDB; // use SourceForge\SchemaDB\Storable; // new SchemaDB(array('host' => $host, 'user' => $user, 'pass' => $pass, 'name' => $name, 'pref' => $pref)); // class Person extends Storable { // public $id = self::PRIMARY_KEY; // public $name = ""; // public $age = 0; } // remove Person table and complete items list Person::drop('confirm'); // import Persons from array-of-array Person::import(array(array('name' => 'Francesco', 'age' => 10), array('name' => 'Paolo', 'age' => 12), array('name' => 'Piero', 'age' => 10), array('name' => 'Antonio', 'age' => 13))); // printout table record before delete Person::dump(); // delete Person with 10 years old Person::delete(array('age' => 10)); // printout table record after delete Person::dump();
public function testDelete() { $person = new Person(); $person->setPersonKindID(1); $person->setUsername("timmy"); $person->setName("Timothy"); $person->setPhone("000-101-1010"); $person->save(); $this->assertTrue(Person::personExists($person->getUsername()) != false); $person->delete(); $this->assertTrue(!Person::personExists($person->getUsername())); }
public function testDeleteBypassTrash() { // Cleanup Person::deleteAll(); // Insert $person = new Person(); $person->first_name = 'John'; $person->last_name = 'Doe'; $person->email = '*****@*****.**'; $person->post_title = 'John Doe'; $post_id = $person->save(); // Delete to trash $person = new Person(); $this->assertTrue($person->load($post_id)); $this->assertTrue(is_object($person->delete(true))); // Load shouldn't work $person = new Person(); $this->assertFalse($person->load($post_id)); }
function delete($employee_id) { $success = false; //Don't let employee delete their self if ($employee_id == $this->get_logged_in_employee_info()->person_id) { return false; } //Run these queries as a transaction, we want to make sure we do all or nothing $this->db->trans_start(); //Delete permissions if ($this->db->delete('permissions', array('person_id' => $employee_id))) { //delete from employee table if ($this->db->delete('employees', array('person_id' => $employee_id))) { //delete from person table $success = parent::delete($employee_id); } } $this->db->trans_complete(); return $success; }
/** * @test */ public function shouldBeAbleToDeleteRecord() { // given $p = new Person(); $p->setFirstname('John'); $p->commit(); // when $p2 = new Person($p->getId()); $id = $p2->getId(); $p2->delete(); $p3 = new Person($p->getId()); // then $this->assertEquals(null, $p2->getId()); $this->assertEquals(null, $p3->getId()); }
$p->save(); $p = new Person(); $p->firstname = "John"; $p->lastname = "Smith"; $p->save(); $p = new Person(); $p->firstname = "Jane"; $p->lastname = "Doe"; $p->save(); $p = new Person(); $p->firstname = "Barney"; $p->lastname = "Riff"; $p->save(); $p = new Person(); $p->firstname = "Jerry"; $p->lastname = "Calabria"; $p->save(); dbm_debug('Heading', 'Done creating entries'); displayEveryone(); dbm_debug('Heading', 'Deleting the entry with ID=4'); $p = new Person(4); $p->delete(); displayEveryone(); dbm_debug('Heading', 'Deleting the Smiths'); $p = new Person(); $p->deleteByLastName("Smith"); displayEveryone(); dbm_debug('Heading', 'Deleting all entries'); $p = new Person(); $p->deleteAll(); displayEveryone();