本文整理汇总了PHP中Character::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Character::delete方法的具体用法?PHP Character::delete怎么用?PHP Character::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDelete
/**
*
* @expectedException StatusCodeException
*/
public function testDelete()
{
require __DIR__ . '/config/database_test.php';
$db = new DatabaseConnection($host, $database, $user, $password);
$character1 = ['name' => 'Lion Woods', 'description' => 'A wonderful zombie that plays golf better than Tiger Woods', 'type' => 'zombie', 'dead' => '1', 'stage' => '2', 'hp' => '67'];
$id1 = Character::insert($db, $character1);
$this->assertTrue(is_array(Character::find($db, $id1)), 'testDelete could not be done cause Character could not be inserted to be deleted.');
Character::delete($db, $id1);
$this->assertFalse(is_array(Character::find($db, $id1)), 'Character::delete not worked properly.');
}
示例2: deleteCharacter
/**
* Update a character with that ID
*
* @param DatabaseConnection database class instance
* @param mixed $id number, could be a string or an int
* @return string '{}'
*/
public function deleteCharacter(DatabaseConnection $db, $id)
{
Character::find($db, $id);
Character::delete($db, $id);
return '{}';
}
示例3: Character
function character_delete()
{
if (!$this->delete('id')) {
$this->response('', 400);
}
// Are we logged in?
if (!$this->user->exists()) {
$this->response(NULL, 401);
}
$character = new Character($this->delete('id'));
// Only allow deleting of your own characters
if ($this->user->id != $character->player_id) {
$this->response(NULL, 401);
}
$character->delete();
$this->response('Character deleted', 200);
}