本文整理汇总了PHP中RedBeanPHP\R::find方法的典型用法代码示例。如果您正苦于以下问题:PHP R::find方法的具体用法?PHP R::find怎么用?PHP R::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\R
的用法示例。
在下文中一共展示了R::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyAction
public function notifyAction()
{
$id = 1;
$settings = R::load('settings', $id);
$time_before = c::now()->modify('+' . $settings->time_before)->toDateString();
$transport = \Swift_SmtpTransport::newInstance($settings->mail_host, $settings->mail_port)->setUsername($settings->mail_username)->setPassword($settings->mail_password);
$mailer = \Swift_Mailer::newInstance($transport);
$client = new \Services_Twilio($settings->twilio_sid, $settings->twilio_token);
$recepients = R::findAll('recepients');
$events = R::find("events", "is_enabled = 1 AND date = '{$time_before}'");
foreach ($events as $event) {
foreach ($recepients as $recepient) {
$subject = preg_replace(array('/{title}/', '/{date}/'), array($event->title, $event->date), $settings->subject);
$end_date = c::parse($event->date)->modify('+' . $event->days . ' days')->toDateString();
$body_patterns = array('/{name}/', '/{title}/', '/{start_date}/', '/<!(\\w+) ({\\w+})>/');
$body_replacements = array($settings->name, $event->title, $event->date, "\$1 {$end_date}");
if ($event->days == 1) {
$body_replacements[3] = '';
}
$body = preg_replace($body_patterns, $body_replacements, $settings->msg_template);
if ($recepient->email && $settings->mail_username && $settings->mail_password) {
$message = \Swift_Message::newInstance()->setSubject($subject)->setBody($body)->setFrom(array($settings->email => $settings->name))->setTo(array($recepient->email => $recepient->name));
try {
$response = $mailer->send($message);
} catch (\Exception $e) {
//todo: log error
}
} else {
if ($recepient->phone_number && $settings->twilio_sid && $settings->twilio_token && $settings->twilio_phonenumber) {
$message = $client->account->messages->sendMessage($settings->twilio_phonenumber, $recepient->phone_number, $body);
}
}
}
}
}
示例2: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('user', 'level=2 LIMIT ?,?', [$start, $perPage]);
$count = R::count('user');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("user/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage]);
}
示例3: edit
public function edit($roomId, $id)
{
$room = R::findOne('room', 'id = ?', [$roomId]);
$item = R::findOne('room_pattern', 'id = ?', [$id]);
$item = $item->getProperties();
$this->build($item);
$products = R::find('product');
$form = new PatternForm($item);
$form->error = FlashSession::getInstance()->get("edit_room_pattern_form_error", false);
$this->slim->render("room/pattern/add.php", ['products' => $products, 'room' => $room, 'form' => $form]);
}
示例4: makeUnique
public function makeUnique()
{
$items = R::find($this->table, 'ORDER BY sort_order');
// $items = R::exportAll($items);
$i = 0;
foreach ($items as $key => $item) {
$i++;
$item->sort_order = $i;
R::store($item);
}
}
示例5: editChapter
/**
* @RequestMapping(url="account/chapter/{chapter_id}",type="template",auth=true)
* @RequestParams(true)
* @Role(USER)
* @Role(ADMIN)
*/
function editChapter($model, $chapter_id = null, $action = null, $title = null)
{
Service::DBSetup();
$chapter = R::load("chapter", $chapter_id);
$comic = R::load("comic", $chapter->comic_id);
$pages = R::find("page", "chapter_id = :chapter_id ORDER BY inorder, time asc", array(":chapter_id" => $chapter_id));
$model->assign("pages", $pages);
$model->assign("chapter", $chapter);
$model->assign("comic", $comic);
return "member/chapter";
}
示例6: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('news', ' ORDER BY sort_order LIMIT ?,?', [$start, $perPage]);
$itemsAll = R::find('news', 'ORDER BY sort_order');
$itemsAll = R::exportAll($items);
$count = R::count('news');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("news/list.php", ['items' => $items, 'itemsAll' => $itemsAll, 'page' => $page, 'maxPage' => $maxPage]);
}
示例7: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('room', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('room');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
$this->slim->render("room/list.php", ['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage]);
}
示例8: getPost
public function getPost($request, $response, $args)
{
$route = $request->getAttribute('route');
$slug = $route->getArgument('slug');
$post = array_shift(R::find('post', ' slug = ? ', [$slug]));
if (!$post->id) {
$this->apiJson->addAlert('error', 'No post found for slug ' . $slug . '.');
return $this->jsonResponse($response);
}
$this->apiJson->setSuccess();
$this->apiJson->addData($post->export());
return $this->jsonResponse($response);
}
示例9: status
function status()
{
$sender = \app\run('input', 'post', 'sender');
$recipient = \app\run('input', 'post', 'recipient');
$emails = R::find('email', ' sender = ? or recipient = ? ', [$sender, $recipient]);
$result = '<dl>';
foreach ($emails as $email) {
$result .= '<dt>' . $email->subject . '</dt>';
$result .= '<dd>' . $email->body_plain . '</dd>';
}
$result .= '</dl>';
return $result;
}
示例10: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('room', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('room');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
header('Content-Type: application/json');
echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例11: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('contactdealer', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('contactdealer');
foreach ($items as &$item) {
$item->ownProvince = R::getRow('SELECT * FROM provinces WHERE province_id=?', [$item->province_id]);
$item->ownGeography = R::getRow('SELECT * FROM geography WHERE geo_id=?', [$item->geo_id]);
// var_dump($item); exit();
}
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("contactdealer/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage]);
}
示例12: __construct
/**
* ManyToOne constructor.
* @param string $tableName
* @param string $clause
* @param array $data
* @param callable $nameClosure
* @param string $valueField The field name that used to be value. The default field is "id".
* @param bool $nullOption
*/
public function __construct($tableName, $clause = null, $data = [], $nameClosure = null, $valueField = "id", $nullOption = true)
{
$beans = R::find($tableName, $clause, $data);
$options = [];
if ($nullOption) {
$options[LouisCRUD::NULL] = "--";
}
foreach ($beans as $bean) {
if ($nameClosure != null) {
$options[$bean->{$valueField}] = $nameClosure($bean);
} else {
$options[$bean->{$valueField}] = $bean->name;
}
}
parent::__construct($options);
}
示例13: updateRss
public function updateRss()
{
$blog = R::load('blog', 1);
$posts = R::find('post', ' is_published = 1 ORDER BY publish_date DESC ');
$xml = $this->getChannelXml($blog);
$count = 1;
foreach ($posts as $post) {
if ($count == 10) {
break;
}
$xml .= $this->getItemXml($post);
$count++;
}
$xml .= "\n\t</channel>" . "\n</rss>";
try {
file_put_contents('../rss/rss.xml', $xml);
} catch (Exception $ex) {
}
}
示例14: index
public function index()
{
$perPage = 999999;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$where = [];
$whereParam = [];
if (!empty($_GET['room_id'])) {
$where[] = "room_id = ?";
$whereParam[] = $_GET['room_id'];
}
$whereString = implode("AND", $where);
$items = R::find('room_pattern', $whereString . ' LIMIT ?,?', array_merge($whereParam, [$start, $perPage]));
$count = R::count('room_pattern', $whereString, $whereParam);
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
header('Content-Type: application/json');
echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例15: search
public function search()
{
$page = $this->getAttr("page");
$perPage = $this->getAttr("perPage");
$start = ($page - 1) * $perPage;
$query = "";
$bindParam = [];
$keyword = $this->getAttr("keyword");
$keyword = trim($keyword);
if (!empty($keyword)) {
$query .= "first_name LIKE :keyword OR last_name LIKE :keyword";
$bindParam["keyword"] = '%' . $keyword . '%';
}
$this->count = R::count('employee', $query, $bindParam);
$page = floor($this->count / $perPage);
$this->maxPage = $page + ($this->count % $perPage == 0 ? 0 : 1);
$query .= " LIMIT :start,:perPage";
$bindParam["start"] = $start;
$bindParam["perPage"] = $perPage;
$this->items = R::find('employee', $query, $bindParam);
$this->injectsUser($this->items);
}