本文整理汇总了PHP中RedBeanPHP\R::trashAll方法的典型用法代码示例。如果您正苦于以下问题:PHP R::trashAll方法的具体用法?PHP R::trashAll怎么用?PHP R::trashAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\R
的用法示例。
在下文中一共展示了R::trashAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: merge
public static function merge($name, array $names)
{
$index = array_search($name, $names);
if ($index > -1) {
array_splice($names, $index, 1);
}
$into = (new self($name))->bean();
$trash = [];
$records = $into->ownRecordList ?: [];
if ($into === null) {
throw new \Exception('merge into publisher does not exist');
}
foreach ($names as $_name) {
$trash[] = $publisherBean = (new Publisher($_name))->bean();
if ($publisherBean === null) {
throw new \Exception('merge from publisher does not exist');
}
foreach ($publisherBean->ownRecordList as $bean) {
$records[] = $bean;
}
$publisherBean->ownRecordList = [];
}
$into->ownRecordList = $records;
R::trashAll($trash);
return R::store($into);
}
示例2: function
});
// Remove a board.
$app->post('/boards/remove', function () use($app, $jsonResponse) {
$data = json_decode($app->environment['slim.input']);
if (validateToken(true)) {
$board = R::load('board', $data->boardId);
if ($board->id == $data->boardId) {
$before = $board->export();
foreach ($board->sharedUser as $user) {
if ($user->defaultBoard == $data->boardId) {
$user->defaultBoard = null;
R::store($user);
}
}
R::trashAll($board->xownLane);
R::trashAll($board->xownCategory);
R::trash($board);
R::exec('DELETE from board_user WHERE board_id = ?', [$data->boardId]);
$jsonResponse->addAlert('success', 'Removed board ' . $board->name . '.');
$actor = getUser();
logAction($actor->username . ' removed board ' . $board->name, $before, null);
}
$jsonResponse->addBeans(getBoards());
$jsonResponse->users = R::exportAll(getUsers());
}
$app->response->setBody($jsonResponse->asJson());
});
$app->post('/autoactions', function () use($app, $jsonResponse) {
$data = json_decode($app->environment['slim.input']);
if (validateToken(true)) {
$board = R::load('board', $data->boardId);
示例3: deleteBeans
/**
* Shorthand method that will delete a collection of beans with *commit* and *rollback* transactions
* @param object $beans
*/
public static function deleteBeans($beans)
{
R::begin();
try {
R::trashAll($beans);
R::commit();
} catch (Exception $e) {
R::rollback();
}
}
示例4: removePerms
public function removePerms()
{
if ($this->name !== 'Administrator') {
$beans = R::findAll('perm', ' group_name = ? ', [$this->name]);
R::trashAll($beans);
}
return $this;
}
示例5: foreach
$customer->website = (string) $input->website;
}
if (isset($input->ownOptions)) {
foreach ($input->ownOptions as $option) {
$customerOption = \RedBeanPHP\R::dispense("options", 1);
foreach ($option as $key => $val) {
$customerOption->{$key} = $val;
}
$customer->ownOptions[] = $customerOption;
}
}
\RedBeanPHP\R::store($customer);
$app->response()->header('Content-Type', 'application/json');
echo json_encode(\RedBeanPHP\R::exportAll($customer));
} else {
$app->response()->status(404);
}
});
// handle DELETE requests
$app->delete('/customers/:id', function ($id) use($app) {
//\RedBeanPHP\R::dependencies(array('options'=>array('customers')));
// retrieve specified element record
$customer = \RedBeanPHP\R::findOne('customers', 'id = ?', array($id));
if ($customer) {
\RedBeanPHP\R::trashAll($customer->ownOptions);
\RedBeanPHP\R::trash($customer);
$app->response()->status(204);
} else {
$app->response()->status(404);
}
});