本文整理汇总了PHP中R::trashAll方法的典型用法代码示例。如果您正苦于以下问题:PHP R::trashAll方法的具体用法?PHP R::trashAll怎么用?PHP R::trashAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::trashAll方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nav_save
function nav_save()
{
G2_User::init();
if (G()->logged_in() && !empty($_POST)) {
if (!empty($_POST['items']) && !empty($_POST['identity'])) {
// Delete all current navigation details
$navitems = R::findAll('navitem', 'identity=:id', ['id' => $_POST['identity']]);
R::trashAll($navitems);
foreach ($_POST['items'] as $new_item) {
$nav = R::dispense('navitem');
$nav->identity = $_POST['identity'];
$nav->label = $new_item['label'];
$nav->href = !$new_item['href'] ? null : $new_item['href'];
$nav->order = $new_item['order'];
//@todo parent node support
R::store($nav);
}
echo json_encode(['success' => true, 'message' => 'Content Saved Successfully']);
} else {
echo json_encode(['success' => false, 'message' => 'Data sent not correct']);
}
} else {
echo json_encode(['success' => false, 'message' => 'Not Logged in']);
}
die;
}
示例2: makecode
/**
* Make a confirmation code and store it in the database
*
* @param object $context The context bean
* @param object $bn A User bean
* @param string $kind
*
* @return string
*/
private function makecode($context, $bn, $kind)
{
R::trashAll(R::find('confirm', 'user_id=?', array($bn->getID())));
$code = hash('sha256', $bn->getID . $bn->email . $bn->login . uniqid());
$conf = R::dispense('confirm');
$conf->code = $code;
$conf->issued = $context->utcnow();
$conf->kind = $kind;
$conf->user = $bn;
R::store($conf);
return $code;
}
示例3: get_areas
function get_areas($html)
{
//Load the html into a dom document
// $dom = new DOMDocument("4.0", 'UTF-8');
// $dom->loadHTML($html);
$dom = HtmlPageCrawler::create($html);
//Look for html nodes that has the mvc:edit attribute
// $nodes = $this->find_editable($dom);
$nodes = $dom->filter('[mvc-edit]');
$instance =& $this;
$area_beans = $nodes->each(function ($node) use($nodes_c, $instance) {
$field_name = $node->getAttribute('mvc-edit');
/* @var $node HtmlPageCrawler */
$field_type = $node->getAttribute('mvc-type');
$starting_html = $node->saveHTML();
return $instance->load_area($instance->page->id, $field_name, $field_type, $starting_html);
});
// Delete all areas that are not relevant but connected to this page
$areas = R::findAll('area', 'page_id = :page', ['page' => $this->page->id]);
$not_loaded = [];
foreach ($areas as $area) {
$bid = $area->id;
foreach ($area_beans as $area_b) {
if ($area_b->id == $bid) {
$found = true;
break;
}
}
if (!$found) {
$not_loaded[] = $area;
}
}
R::trashAll($not_loaded);
// Convert these nodes to area beens
// $area_beans = $this->nodes_to_beans($nodes);
return $area_beans;
}
示例4: authenticate
/**
* Authenticate
*
* @param string $username The HTTP Authentication username
* @param string $password The HTTP Authentication password
*
*/
public function authenticate($username, $password)
{
if (!ctype_alnum($username)) {
return false;
}
if (isset($username) && isset($password)) {
$user = R::findOne('users', 'login="' . $username . '" AND password="' . sha1($password) . '"');
if ($user) {
/*
* Deleting all beans older then 5mn
*/
$date2 = time() - 60;
$date = date('Y-m-d h:i:s', $date2);
$beans = R::findAll('log', 'date<"' . $date . '"');
R::trashAll($beans);
/*
* checking if the users can do more requests
*/
$number = R::count('log', 'user_id= ?', [$user->id]);
if ($number > 250) {
return false;
} else {
/*
* saving the logs in the database
*/
$log = R::dispense('log');
$log->date = date('Y-m-d h:i:s');
$log->user = $user;
R::store($log);
return true;
}
}
} else {
return false;
}
}
示例5: delete
function delete($f3)
{
if (!($user = \R::findOne('users', 'username=?', array(strtolower($f3->get('POST.username')))))) {
throw new \Exception('Could not find user');
}
if (!($tool = \R::findOne('tools', 'name=?', array(strtolower($f3->get('POST.tool')))))) {
throw new \Exception('Could not find tool');
}
if (!($records = \R::find('trainings', 'users_id=? AND tools_id=? AND level=?', array($user->id, $tool->id, strtoupper($f3->get('POST.level')))))) {
throw new \Exception('Could not any training records for this user on this tool at this level.');
}
\R::trashAll($records);
$f3->set('messages', array('All Records of User ' . $user->username . ' on Tool ' . $tool->name . ' at Level ' . strtoupper($f3->get('POST.level')) . ' deleted.'));
show_page($f3, 'messages');
}
示例6: ini_set
<?php
ini_set('display_errors', 'ON');
require_once '../autoload.php';
date_default_timezone_set('GMT');
// -- get requested url --
$currentEnv = realpath('.currentEnv') ? file_get_contents('.currentEnv') : 'production';
$baseUrl = $currentEnv == 'production' ? '/btcapi/' : '/';
$baseDir = __DIR__;
define("APPLICATION_BASE", $baseUrl);
define("APPLICATION_DIR", $baseDir);
$objEventsModel = new models\Events();
$timeToDeleteBeans = time();
$beansToDelete = \R::findAll('events', 'end_time+(24*60*60) <= :time', array(':time' => $timeToDeleteBeans));
\R::trashAll($beansToDelete);
示例7: sec_session_start
<?php
include_once 'phpcode/secureSession.php';
include_once 'phpcode/config.php';
sec_session_start();
check_logged();
?>
<?php
if (isset($_GET['id']) && intval($_GET['id']) > 0) {
//delete the album
$album = R::dispense('albums');
$album = R::load('albums', $_GET['id']);
R::trash($album);
$dirname = 'UploadedImages/' . preg_replace('/\\s+/', '', $album['name']);
deleteDir($dirname . '/' . 'thumb');
deleteDir($dirname);
//delete images from db
$images = R::dispense('images');
$images = R::find('images', 'album_id=?', array($_GET['id']));
R::trashAll($images);
redirect("editAlbum.php");
} else {
//go back
redirect("editAlbum.php");
}
示例8: deleteBeans
/**
* deletes beans with transactions
* @param object $beans
*/
public static function deleteBeans($beans)
{
R::begin();
try {
R::trashAll($beans);
R::commit();
} catch (Exception $e) {
R::rollback();
}
}
示例9: deletePairByUserId
/**
* Delete pairs with user
* @param int $user_id
* @return boolean $res
*/
public function deletePairByUserId($user_id)
{
// No pair - we thrash all pairs with user
//return;
$pairs = R::findAll('pair', 'user_a = ? OR user_b = ?', [$user_id, $user_id]);
R::trashAll($pairs);
$this->deleteHalvFromUserId($user_id);
}
示例10: testMultiDeleteUpdate
/**
* Test trashAll().
*/
public function testMultiDeleteUpdate()
{
testpack('test multi delete and multi update');
$beans = R::dispenseLabels('bean', array('a', 'b'));
$ids = R::storeAll($beans);
asrt((int) R::count('bean'), 2);
R::trashAll(R::batch('bean', $ids));
asrt((int) R::count('bean'), 0);
testpack('test assocManager check');
$rb = new RedBean_OODB(R::$writer);
try {
$rb->getAssociationManager();
fail();
} catch (RedBean_Exception_Security $e) {
pass();
}
}
示例11: checksession
function checksession()
{
global $systemURL;
$sessions = R::find('sessions', 'timestamp<=?', [time()]);
R::trashAll($sessions);
if (isset($_COOKIE["loguserid"]) and isset($_COOKIE["logsession"])) {
$session = R::findOne('sessions', 'userid=:userid AND sessionid=:sessionid AND timestamp>:timestamp', [':userid' => $_COOKIE["loguserid"], ':sessionid' => $_COOKIE["logsession"], ':timestamp' => time()]);
if (!empty($session)) {
$session->timestamp = time() + 86400 * 14;
R::store($session);
R::commit();
R::begin();
} else {
$sessions = R::find('sessions', 'userid=:userid OR sessionid=:sessionid', [':userid' => $_COOKIE["loguserid"], ':sessionid' => $_COOKIE["logsession"]]);
R::trashAll($sessions);
R::commit();
setcookie("loguserid", "", time() - 86400);
setcookie("logsession", "", time() - 86400);
header("HTTP/1.1 301 Moved permanently");
header("Location: " . $systemURL . "?error=2&time=" . time());
header("Connection: close");
exit;
}
} else {
header("HTTP/1.1 301 Moved permanently");
header("Location: " . $systemURL . "?error=2&time=" . time());
header("Connection: close");
exit;
}
}