本文整理汇总了PHP中UserMapper::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::delete方法的具体用法?PHP UserMapper::delete怎么用?PHP UserMapper::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$mapper = new UserMapper($this->adapter);
$user = new \Cactus\Entity(array('name' => 'Mr. Test', 'password' => "testingpassword", 'create_date' => date("Y-m-d H:i:s")));
list($id, $num) = $mapper->save($user);
// Dont do this for real, but I need to clean up for testing
$mapper->delete($user);
return $num === 1;
}
示例2: testDeleteUser
public function testDeleteUser()
{
$user = getUserInstance('deleteUser');
$umapper = new UserMapper(self::$pdo);
$umapper->insert($user);
$umapper->delete($user);
$allUsers = $umapper->findAll()->fetchAll();
$this->assertEmpty($allUsers);
}
示例3: deleteAction
public function deleteAction($I_id)
{
// On vérifie si l'utilisateur connecté est bien un admin
$this->isAdmin();
// On appelle le modele UserMapper et on lui demande de supprimer le user qui a l'$I_id
$O_userMapper = new UserMapper();
$O_userMapper->delete($I_id);
die(header('Location:/'));
}
示例4: eliminar
public function eliminar()
{
$currentuser = $this->view->getVariable("currentusername");
$user = $this->userMapper->findById($currentuser);
// Does the post exist?
if ($user == NULL) {
throw new Exception(i18n("Username does not exist"));
}
// Delete the Jurado Popular object from the database
$this->userMapper->delete($user);
$this->view->setFlash(i18n("Deleted user"));
session_unset();
session_destroy();
$this->view->redirect("preguntas", "index");
}
示例5: sizeof
//get user by username
$user = $userMapper->findOne(array("conditions" => array('username = ? ', "john doe")));
echo "Username: " . $user->username;
echo "<br />Articles of this user:<br />";
foreach ($user->articles as $article) {
echo $article->title . '<br />';
}
//edit the user
$user->username = "johnny doe";
$userMapper->update($user);
//add a new user
$newUser = new User();
$newUser->username = "my username 2";
$userMapper->insert($newUser);
//delete a user
$userMapper->delete(4);
//get users with their articles
//get all users limited by 2, sorted by username ascending and eager load the article relationship
//only 2 queries - one for fetching the users and one for coupling the related articles
$users = $userMapper->findMany(array("limit" => 3, "sort" => array("username", "asc"), "relations" => array("Article")));
//4 queries: one for retrieving the users and 1 per user lazy loading the articles.
$users = $userMapper->findMany(array("limit" => 3, "sort" => array("username", "asc")));
echo sizeof($users) . " users found<br />";
foreach ($users as $user) {
echo "<br />Username:" . $user->username . "<br />";
if (sizeof($user->articles) > 0) {
echo "Articles of this user:<br />";
foreach ($user->articles as $article) {
echo $article->title . "<br />";
}
} else {