本文整理汇总了PHP中R::getCell方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getCell方法的具体用法?PHP R::getCell怎么用?PHP R::getCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::getCell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show_Data
public function show_Data()
{
$this->output('cash', $this->user->cash);
$this->output('xp', $this->user->xp);
$this->output('level', $this->user->level);
$this->output('players_online', R::getCell('SELECT COUNT(id) FROM session WHERE expires > ?', array(time())));
}
示例2: clean
public static function clean($f3, $filename)
{
$total_filesize = R::getCell('select sum(filesize) as total_filesize from cache');
$cache_total_filesize_limit = $f3->get("UPLOAD.cache_total_size_limit");
$cache_total_filesize_limit = PFH_File_helper::convert_filesize_in_bytes($cache_total_filesize_limit);
if ($total_filesize > $cache_total_filesize_limit) {
$caches = R::find("cache", "ORDER BY datetime");
$count = count($caches);
// 只有一個不刪除
//if ($count < 2) {
// return;
//}
foreach ($caches as $key => $cache) {
//不刪除最後一個
//if ($key > $count - 1) {
// return;
//}
if ($cache->path === $filename) {
continue;
}
//throw new Exception("$key $cache->path");
//echo $cache->path . "<br />";
if (is_file($cache->path)) {
unlink($cache->path);
}
$total_filesize = $total_filesize - $cache->filesize;
R::trash($cache);
if ($total_filesize < $cache_total_filesize_limit) {
break;
}
}
}
}
示例3: testRebuilder
/**
* Test SQLite table rebuilding.
*
* @return void
*/
public function testRebuilder()
{
$toolbox = R::$toolbox;
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
R::dependencies(array('page' => array('book')));
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->ownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPage[] = $page;
$id = R::store($book);
$book = R::load('book', $id);
asrt(count($book->ownPage), 1);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
$book->added = 2;
R::store($book);
$book->added = 'added';
R::store($book);
R::trash($book);
asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
}
示例4: getUserLeaderboardCount
public static function getUserLeaderboardCount($type)
{
$sql = self::makeUserLeaderboardCountSqlQuery($type);
$count = R::getCell($sql);
if ($count === null || is_array($count) && count($count) == 0) {
$count = 0;
}
return $count;
}
示例5: init
public function init()
{
parent::init();
// only works if you are in casino
$ct = R::getCell('SELECT map FROM map_position WHERE user_id = ?', array($this->user->getID()));
if ($ct != "casino") {
Framework::redir("game/index");
exit;
}
}
示例6: player_count
public function player_count()
{
return R::getCell('SELECT
count(poker_player.id)
FROM
poker_player, poker_round, poker_player_poker_round
WHERE
poker_round.id = ? AND
poker_player_poker_round.poker_round_id = poker_round.id AND
poker_player_poker_round.poker_player_id = poker_player.id', array($this->bean->getID()));
}
示例7: init
public function init()
{
parent::init();
$id = $_POST["id"];
// check if npc is valid
if (!is_numeric($id) || $id <= 0) {
$this->error('Invalid ' . $this->_type . '-ID');
}
$this->npc = R::load($this->_type, $id);
if ($this->npc->getID() != $id) {
$this->error($this->_type . ' doesnt exist!');
}
// check if npc has right type
if ($this->npc->type != $this->myType) {
$this->error("This " . $this->_type . " is not of " . $this->myType);
}
// check if user is nearby
$userPos = R::findOne('map_position', ' user_id = ?', array($this->user->getID()));
$dist = sqrt(pow($this->npc->x - $userPos->x, 2) + pow($this->npc->y - $userPos->y, 2));
if ($dist > 3 || $this->npc->map != $userPos->map) {
$this->error('Du bist zu weit entfehrt!');
}
// check if quest availible
$this->myNPCQuest = R::relatedOne($this->user, 'quests_npc', ' complete_time = 0 AND (startnpc_id = ? OR stopnpc_id = ?)', array($this->npc->getID(), $this->npc->getID()));
if ($this->myNPCQuest != null) {
if ($this->myNPCQuest->startnpc_id == $this->npc->getID()) {
if ($this->myNPCQuest->accepted == 0) {
$this->myNPCQuestRole = 'startnpc';
$startnpc = $this->npc->name;
$stopnpc = R::getCell('SELECT `name` FROM map_npc WHERE id = ?', array($this->myNPCQuest->stopnpc_id));
}
} else {
if ($this->myNPCQuest->accepted == 1) {
$this->myNPCQuestRole = 'stopnpc';
$stopnpc = $this->npc->name;
$startnpc = R::getCell('SELECT `name` FROM map_npc WHERE id = ?', array($this->myNPCQuest->startnpc_id));
}
}
if ($this->myNPCQuestRole != 'none') {
$all = Config::getConfig('npc_quests');
$this->myNPCQuestData = $all[$this->myNPCQuest->quest_id][$this->myNPCQuestRole];
$this->myNPCQuestData["text"] = str_replace(array('{startnpc}', '{stopnpc}'), array($startnpc, $stopnpc), $this->myNPCQuestData["text"]);
foreach ($this->myNPCQuestData["items"] as $k => $v) {
$this->myNPCQuestData["items"][$k]["param"] = str_replace(array('{startnpc}', '{stopnpc}'), array($startnpc, $stopnpc), $v["param"]);
}
if ($this->_controllerFunc == 'Interact') {
$this->output('quest', '<br /> <br />
<b>Quest:</b> ' . htmlspecialchars($this->myNPCQuestData["text"]) . ' <br />
<a href="#questing">' . ($this->myNPCQuestRole == 'startnpc' ? 'annehmen' : 'abschließen') . '</a>');
}
}
}
}
示例8: show_Main
public function show_Main()
{
$usersPerPage = 20;
$totalUsers = R::getCell('SELECT count(id) FROM user');
$pages = ceil($totalUsers / $usersPerPage);
$currentPage = is_numeric($this->get(1)) && $this->get(1) > 0 && $this->get(1) <= $pages ? $this->get(1) : 1;
$players = array();
$dbP = R::find('user', ' 1=1 ORDER BY xp DESC LIMIT ?,?', array(($currentPage - 1) * $usersPerPage, $usersPerPage));
$i = $usersPerPage * ($currentPage - 1) + 1;
foreach ($dbP as $p) {
$players[] = array("rank" => $i, "username" => $p->username, "level" => $p->level, "xp" => formatCash($p->xp), "premium" => $p->hasPremium());
$i++;
}
Framework::TPL()->assign('players', $players);
Framework::TPL()->assign('currentPage', $currentPage);
Framework::TPL()->assign('pages', $pages);
}
示例9: sendAnswer
public static function sendAnswer($uid, $qno, $answer, $optional)
{
$id = R::getCell('select id from answer where uid = ? and qno = ? order by id desc limit 1', [$uid, $qno]);
if (empty($id)) {
$ans = R::dispense('answer');
$ans->uid = $uid;
$ans->datetime = new DateTime();
$ans->qno = $qno;
$ans->answer = $answer;
$ans->optional = $optional;
return R::store($ans);
} else {
$ans = R::load('answer', $id);
$ans->answer = $answer;
$ans->optional = $optional;
return R::store($ans);
}
}
示例10: optimize
/**
* Optimize table column types, based on hints
* @param string $table name of the table
* @param string $columnName name of the column
* @param string $datatype
*/
public static function optimize($table, $columnName, $datatype, $length = null)
{
try {
$databaseColumnType = DatabaseCompatibilityUtil::mapHintTypeIntoDatabaseColumnType($datatype, $length);
if (isset(self::$optimizedTableColumns[$table])) {
$fields = self::$optimizedTableColumns[$table];
// It is possible that field is created outside optimizer, so in this case reload fields from database
if (!in_array($columnName, array_keys($fields))) {
$fields = R::$writer->getColumns($table);
}
} else {
$fields = R::$writer->getColumns($table);
}
if (in_array($columnName, array_keys($fields))) {
$columnType = $fields[$columnName];
if (strtolower($columnType) != strtolower($databaseColumnType)) {
if (strtolower($datatype) == 'string' && isset($length) && $length > 0) {
$maxLength = R::getCell("SELECT MAX(LENGTH({$columnName})) FROM {$table}");
if ($maxLength <= $length) {
R::exec("alter table {$table} change {$columnName} {$columnName} " . $databaseColumnType);
}
} else {
R::exec("alter table {$table} change {$columnName} {$columnName} " . $databaseColumnType);
}
}
} else {
R::exec("alter table {$table} add {$columnName} " . $databaseColumnType);
}
} catch (RedBean_Exception_SQL $e) {
//42S02 - Table does not exist.
if (!in_array($e->getSQLState(), array('42S02'))) {
throw $e;
} else {
R::$writer->createTable($table);
R::exec("alter table {$table} add {$columnName} " . $databaseColumnType);
}
}
if (isset($fields)) {
self::$optimizedTableColumns[$table] = $fields;
} else {
self::$optimizedTableColumns[$table] = R::$writer->getColumns($table);
}
self::$optimizedTableColumns[$table][$columnName] = $databaseColumnType;
}
示例11: testSavingNewParentAccountSavesCorrectly
public function testSavingNewParentAccountSavesCorrectly()
{
$oldMetadata = Account::getMetadata();
$newMetadata = $oldMetadata;
$newMetadata['Account']['rules'][] = array('type', 'default', 'value' => 'Customer');
Account::setMetadata($newMetadata);
$account = new Account();
$account->name = 'Account';
$account->type->value = 'Customer';
$account->account = $account;
$saved = $account->save();
$this->assertTrue($saved);
$account->account = null;
$saved = $account->save();
$this->assertTrue($saved);
$count = R::getCell('select count(*) from account');
$this->assertEquals(1, $count);
Account::setMetadata($oldMetadata);
$this->assertTrue($account->delete());
}
示例12: show_Main
public function show_Main()
{
if ($this->get(1) == "login") {
Framework::TPL()->assign('first_login', true);
} else {
Framework::TPL()->assign('first_login', false);
}
$session_expired = false;
if ($this->get(1) == "session_expired") {
$session_expired = true;
}
Framework::TPL()->assign('session_expired', $session_expired);
$count = R::getCell('select count(id) from user');
Framework::TPL()->assign("playercount", $count);
// assign news
$news = array();
$dbNews = R::find('homepage_posts', ' 1=1 ORDER BY id DESC LIMIT 3');
foreach ($dbNews as $n) {
$author = R::relatedOne($n, 'user');
$news[] = array('id' => $n->id, 'title' => $n->title, 'author' => $author->username, 'time' => $n->time);
}
Framework::TPL()->assign("news", $news);
}
示例13: date
?>
<div class="uiv2-form-row">
<span class="uiv2-form-label">Registered on</span>
<span class="uiv2-form-label" style="text-align: left; ">
<?php
echo date('d-m-Y', strtotime($user["date_of_registration"]));
?>
</span>
</div>
<?php
}
?>
</fieldset>
<?php
$sql = "select count(*) from userservices where userid=?";
$services_count = R::getCell($sql, array($id));
if ($services_count > 0) {
?>
<h2>Services offered</h2>
<?php
$sql = "select distinct c.id as id, category from categories c " . "join services s on c.id = s.category_id " . "join userservices us on s.id = us.serviceid " . "where userid=?";
$categories = R::getAll($sql, array($id));
foreach ($categories as $category) {
?>
<fieldset>
<div class="legend"><?php
echo $category["category"];
?>
</div>
<div style="padding: 20px;">
示例14: header
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
die;
}
R::close();
// Save frequent people
R::addDatabase('supportsr', $GLOBALS['db_supportsr_url'], $GLOBALS['db_supportsr_user'], $GLOBALS['db_supportsr_pass']);
R::selectDatabase('supportsr');
if (!R::testConnection()) {
exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
R::begin();
foreach ($people_array as $people) {
$person_old = R::getCell(' SELECT id ' . ' FROM supportsr.esr_frequent_people ' . ' WHERE name = :name ' . ' AND paper_number = :p_number ', [':name' => $people->pname, ':p_number' => $people->pidval]);
if (empty($person_old) || $person_old == "") {
$person_new = R::getRedBean()->dispense('esr_frequent_people');
$person_new->name = $people->pname;
$person_new->paper_type = $people->ptype == '身份证' ? '身份证/Id card' : ($people->ptype == '台胞证' ? '台胞证/Efficiency certificate' : ($people->ptype == '护照' ? '护照/Passport' : ($people->ptype == '港澳通行证' ? '港澳通行证/Hong Kong-Macau passport' : ($people->ptype == '驾驶证' ? '驾驶证/Driving license' : ''))));
$person_new->paper_number = $people->pidval;
$person_new->comid = $user['organizationname'] . '|*|' . $user['userorganizationid'];
$person_new_id = R::store($person_new);
}
}
R::commit();
} catch (Exception $e) {
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
R::rollback();
die;
示例15: COUNT
}
if (empty($staff_rate_score) || $staff_rate_score == NULL) {
$staff_rate_score = 4.0;
}
if (!empty($staff_id) && is_numeric($staff_id)) {
try {
$staff_experience_count = R::getCell(' SELECT ' . ' COUNT(DISTINCT p.ticketid) ' . ' FROM ' . ' kayako_fusion.swticketposts p ' . ' WHERE ' . ' p.staffid = :staff_id ', [':staff_id' => $staff_id]);
_log(json_encode(['staff_experience_count' => $staff_experience_count]));
} catch (Exception $e) {
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'failed', 'error' => 'db error portal', 'details' => $e->getMessage()]);
die;
}
} else {
try {
$staff_experience_count = R::getCell(' SELECT COUNT(*) AS experience_count' . ' FROM supportsr.esr_ticketworkorder_interface p' . ' INNER JOIN supportsr.esr_ticketworkorder_interface pp' . ' ON p.wo_assignee = pp.wo_assignee' . ' AND p.wo_category = pp.wo_category' . ' WHERE p.kayako_ticket_id = :ticket_id', [':ticket_id' => $ticket_id]);
_log(json_encode(['staff_experience_count' => $staff_experience_count]));
} catch (Exception $e) {
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'failed', 'error' => 'db error portal', 'details' => $e->getMessage()]);
die;
}
}
R::close();
// Merge
$staff_skills['rate_score'] = $staff_rate_score;
$staff_skills['experience_count'] = $staff_experience_count;
// Return
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'staff' => $staff_skills], JSON_UNESCAPED_UNICODE);
die;