本文整理汇总了PHP中Person::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::delete方法的具体用法?PHP Person::delete怎么用?PHP Person::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person::delete方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAction
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);
}
示例2: delete
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."));
}
}
示例3: delete
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;
}
示例4: testDeleteCriteria
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());
}
示例5: delete_person
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'));
}
示例6:
<?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();
示例7: testDeleteMultiple
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());
}
示例8: SchemaDB
}
//
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();
示例9: testDelete
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()));
}
示例10: testDeleteBypassTrash
public function testDeleteBypassTrash()
{
// Cleanup
Person::deleteAll();
// Insert
$person = new Person();
$person->first_name = 'John';
$person->last_name = 'Doe';
$person->email = 'johndoe@test.com';
$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));
}
示例11: delete
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;
}
示例12: shouldBeAbleToDeleteRecord
/**
* @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());
}
示例13: Person
$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();