本文整理汇总了PHP中R::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP R::findAll方法的具体用法?PHP R::findAll怎么用?PHP R::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCoolUsers
public static function getCoolUsers($goal)
{
$query = 'SELECT id FROM user WHERE cool = 1 ORDER BY RANDOM() LIMIT ?';
$userIds = array_map(function ($x) {
return intval($x['id']);
}, R::getAll($query, [$goal]));
if (empty($userIds)) {
return [];
}
$query = 'id IN (' . R::genSlots($userIds) . ')';
$result = R::findAll('user', $query, $userIds);
return array_map(function ($x) {
return $x->box();
}, $result);
}
示例2: execute
static function execute($number = 5)
{
if (!is_numeric($number)) {
throw new Exception('Number must be numeric');
}
$callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number);
$c = 0;
foreach (array_values($callables) as $index => $calleble) {
$c++;
if ($calleble->done) {
$c--;
continue;
}
if ($c >= $number) {
break;
}
$serializer = new Serializer();
$closure = $serializer->unserialize($calleble->callser);
//// $calleble->status = 'busy';
// R::store($calleble);
$closure();
$calleble->status = 'done';
$calleble->done = true;
$calleble->doneat = time();
R::store($calleble);
}
return;
}
示例3: countJobs
public function countJobs($terms)
{
$terms = splitTerms($terms);
$terms = implode('|', $terms);
$jobs = R::findAll('jobs', " status=1 AND (title REGEXP :title OR description REGEXP :description OR perks REGEXP :perks OR how_to_apply REGEXP :how_to_apply OR company_name REGEXP :company_name)", array(':title' => $terms, ':description' => $terms, ':perks' => $terms, ':how_to_apply' => $terms, ':company_name' => $terms));
return count($jobs);
}
示例4: getEnviosByPage
function getEnviosByPage($pagenumber)
{
//$app->get('/envios/page/:pagenumber', function ($pagenumber) use ($app) {
$app = \Slim\Slim::getInstance();
// query database for all contactos
$envios = R::findAll('envios', 'ORDER BY id LIMIT ?,8', array($pagenumber * 8 - 8));
// send response header for JSON content type
$app->response()->header('Content-Type: text/html; charset=utf-8');
$app->response()->header('Content-Type', 'application/json');
//die(print_r($envios[0]->ubicaciones));
foreach ($envios as $envio) {
$envio->clientes = $envio->clientes;
$envio->segmento = $envio->segmento;
$envio->subsegmento = $envio->subsegmento;
$envio->contactos = $envio->contactos;
$envio->ubicaciones_origen = R::findOne('ubicaciones', 'id=?', array($envio->ubicaciones_origen_id));
$envio->ubicaciones_destino = R::findOne('ubicaciones', 'id=?', array($envio->ubicaciones_destino_id));
$envio->vehiculos = $envio->vehiculos;
$envio->choferes = $envio->choferes;
$envio->statuses = $envio->statuses;
}
// return JSON-encoded response body with query results
echo json_encode(R::exportAll($envios));
//});
}
示例5: unit
protected function unit($arguments)
{
$request = trim($arguments[0]);
$request = rtrim($request, '!@#$%^&*()_-+={}[]:;\'"\\|<>,./?');
foreach ($this->lastRequest as $id => $timeToClear) {
if (time() - $timeToClear >= self::CLEAR_TIME) {
unset($this->lastRequest[$id]);
}
}
parent::RedBeanConnect(self::DB_NAME);
if (preg_match('/^[\\x{30A0}-\\x{30FF}\\x{31F0}-\\x{31FF}]+$/iu', $request)) {
$units = R::findAll(self::TB_NAME, '`orginal` like ?', ["%{$request}%"]);
} else {
$units = R::findAll(self::TB_NAME, '`name` like ?', [$request]);
}
if ($units) {
$linkHolder = [];
foreach ($units as $unit) {
if (!$unit->linkgc || isset($linkHolder[$unit->linkgc]) || isset($this->lastRequest[$unit->id])) {
continue;
}
$linkHolder[$unit->linkgc] = $unit->orginal;
$this->lastRequest[$unit->id] = time();
$text = IRCHelper::colorText('Romanji', IRCHelper::COLOR_ORANGE) . ': ' . $unit->orginal;
$text .= ' ' . IRCHelper::colorText('Link', IRCHelper::COLOR_ORANGE) . ': ' . $unit->linkgc;
$this->reply($text);
}
} else {
$this->reply('Not found ' . $request);
}
R::close();
}
示例6: enviar
public static function enviar()
{
global $request;
$request = R::findAll('request', ' ORDER BY name ');
$user = R::findAll('user');
$lista = [];
$subject = "Lista del super";
$file = fopen('vistas/email/email.ejs', 'r');
$content = fread($file, filesize('vistas/email/email.ejs'));
$message = __($content)->template(array('lista' => $request));
$header = "From:lista@carrito.esy.es\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
foreach ($user as $key => $value) {
if (isset($value->email) && $value->email != "" && $value->rol == 1) {
$lista[] = $value->email;
$to = $value->email;
$retval = mail($to, $subject, $message, $header);
if ($retval == true) {
echo json_encode($lista);
} else {
echo "Message could not be sent...";
}
}
}
}
示例7: recupWines
function recupWines()
{
// Récupération sous forme d'un tableau de tous les vins dans la DB au moyen de l'ORM RedBean
$tabWines = R::findAll('wine');
// On retourne le tableau "tabWines"
return $tabWines;
}
示例8: view
function view($args)
{
$id = array_shift($args);
$permission = R::load('permission', $id);
if (!is_numeric($id) && !$permission->getID()) {
$this->redirect(PACKAGE_URL);
}
$allgroups = R::findAll('group');
foreach ($allgroups as $key => $group) {
foreach ($permission->sharedGroup as $group_c) {
if ($group->id == $group_c->id) {
$allgroups[$key]->checked = true;
}
}
}
// echo $permission->name;exit;
$view = new G2_TwigView('pages/view');
$view->permission = $permission;
$view->allGroups = $allgroups;
$form = new G2_FormMagic($view->get_render());
if ($form->is_posted()) {
$groups = R::loadAll('group', array_keys($form->data()['groups']));
$permission->sharedGroup = $groups;
R::store($permission);
Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
$this->redirect(PACKAGE_URL);
}
echo $form->parse();
}
示例9: 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;
}
示例10: process
public function process(array $documents, &$context)
{
$franchiseIds = [];
$franchiseIds[] = self::mediaToKey($context->media);
foreach ($context->relationData as $relation) {
if ($relation['media'] != $context->media->media) {
continue;
}
if ($relation['type'] == MediaRelation::Character) {
continue;
}
if (BanHelper::isFranchiseCouplingBanned($relation['media'], $relation['mal_id'], $context->media->media, $context->media->mal_id)) {
continue;
}
$franchiseIds[] = self::mediaToKey($relation);
}
foreach (R::findAll('media', 'media||mal_id IN (' . R::genSlots($franchiseIds) . ')', $franchiseIds) as $relatedMedia) {
$franchiseIds[] = $relatedMedia->franchise;
}
$franchiseId = reset($franchiseIds);
$media =& $context->media;
$media->franchise = $franchiseId;
R::store($media);
$query = 'UPDATE media SET franchise = ? WHERE franchise IN (' . R::genSlots($franchiseIds) . ')';
R::exec($query, array_merge([$franchiseId], $franchiseIds));
}
示例11: getAll
public function getAll($isBean = false)
{
if ($isBean) {
return R::findAll('guest', 'ORDER BY modify_date DESC');
} else {
return R::getAll('SELECT * FROM guest ORDER BY modify_date DESC');
}
}
示例12: getAllSubscriptions
public function getAllSubscriptions($start)
{
$users = R::findAll('subscriptions', ' ORDER BY created DESC LIMIT :start, :limit ', array(':start' => $start, ':limit' => LIMIT));
if (isset($users)) {
return $users;
}
return false;
}
示例13: Get
public function Get()
{
$users = R::findAll('user');
$newUsers = array();
foreach ($users as $user) {
$newUsers[] = array("id" => $user->id, "name" => $user->name, "surname" => $user->surname, "email" => $user->email, "isAdmin" => $user->isAdmin === '1' ? true : false, "isTeacher" => $user->isTeacher, "group" => $user->group);
}
return $newUsers;
}
示例14: getUsernames
public function getUsernames()
{
$users = R::findAll('user');
$usernames = array();
foreach ($users as $user) {
array_push($usernames, $user->username);
}
return json_encode($usernames);
}
示例15: getApplications
public function getApplications($start)
{
if (isset($this->_job_id)) {
$apps = R::findAll('applications', " job_id=:job_id ORDER BY created DESC LIMIT :start, :limit ", array(':job_id' => $this->_job_id, ':start' => $start, ':limit' => LIMIT));
} else {
$apps = R::findAll('applications', " ORDER BY created DESC LIMIT :start, :limit ", array(':start' => $start, ':limit' => LIMIT));
}
return $apps;
}