本文整理汇总了PHP中RedBeanPHP\R::getRow方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getRow方法的具体用法?PHP R::getRow怎么用?PHP R::getRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\R
的用法示例。
在下文中一共展示了R::getRow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($email)
{
$passwordReset = R::getRow('SELECT `users`.`id` AS `userId`, `passwordResets`.`id`, `passwordResets`.`token`, `passwordResets`.`created`
FROM ( `users` )
LEFT JOIN `passwordResets`
ON ( `passwordResets`.`userId` = `users`.`id` )
WHERE `users`.`email` = :email', [':email' => $email]);
return !empty($passwordReset) ? $passwordReset : false;
}
示例2: login
public static function login($username, $password)
{
$row = R::getRow("SELECT * FROM `user` WHERE username = ? ", array($username));
if ($row != null && password_verify($password, $row["password"])) {
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
return true;
} else {
unset($_SESSION["username"]);
unset($_SESSION["password"]);
return false;
}
}
示例3: 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]);
}
示例4: save
public function save()
{
if (!$this->emptyAttr('id')) {
$contactDealer = R::findOne('contactdealer', 'id=?', [$this->getAttr('id')]);
$contactDealer->updated_at = date('Y-m-d H:i:s');
} else {
$contactDealer = R::dispense('contactdealer');
$contactDealer->created_at = date('Y-m-d H:i:s');
$contactDealer->updated_at = date('Y-m-d H:i:s');
}
$contactDealer->name = $this->getAttr('name');
$contactDealer->address = $this->getAttr('address', '');
$contactDealer->phone = $this->getAttr('phone', '');
$contactDealer->province_id = $this->getAttr('province_id', '');
$contactDealer->geo_id = $this->getAttr('geo_id', '');
$contactDealer->lat = $this->getAttr('lat', '');
$contactDealer->lng = $this->getAttr('lng', '');
$province = R::getRow('SELECT * FROM provinces WHERE province_id = ?', [$contactDealer->province_id]);
if ($province) {
$contactDealer->geo_id = $province['geo_id'];
}
$success = R::store($contactDealer);
return $success;
}
示例5: addRoomUse
public function addRoomUse()
{
$productId = $this->slim->request->post()['product_id'];
$roomName = $this->slim->request->post()['room_name'];
$item = R::findOne('product', 'id=?', [$productId]);
if (!$item) {
header('Content-Type: application/json');
echo json_encode(['error' => 'NOT_FOUND_PRODUCT'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
$dateStr = date('Y-m-d');
$productView = R::getRow('SELECT * FROM product_room WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
if (!$productView) {
R::exec('INSERT INTO product_room SET product_id=?, room_name=? , view_date=?', [$productId, $roomName, $dateStr]);
}
R::exec('UPDATE product_room SET view_count = view_count+1 WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
header('Content-Type: application/json');
echo json_encode(['successs' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例6: productAddStat
public function productAddStat($productId)
{
$dateStr = date('Y-m-d');
$productView = R::getRow('SELECT * FROM product_add WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
if (!$productView) {
R::exec('INSERT INTO product_add SET product_id=?, add_date=?', [$productId, $dateStr]);
}
R::exec('UPDATE product_add SET add_count = add_count+1 WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
header('Content-Type: application/json');
echo json_encode(['success' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例7: build
public function build(&$item)
{
$item['province'] = R::getRow('SELECT * FROM provinces WHERE province_id=?', [$item['province_id']]);
$item['geography'] = R::getRow('SELECT * FROM geography WHERE geo_id=?', [$item['geo_id']]);
}