本文整理汇总了PHP中R::count方法的典型用法代码示例。如果您正苦于以下问题:PHP R::count方法的具体用法?PHP R::count怎么用?PHP R::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countApplications
public function countApplications()
{
if (isset($this->_job_id)) {
$apps = R::count('applications', ' job_id=:job_id ORDER BY created DESC ', array(':job_id' => $this->_job_id));
} else {
$apps = R::count('applications', ' ORDER BY created DESC ');
}
return $apps;
}
示例2: deleteCity
public function deleteCity()
{
$count = R::count('jobs', " city=:city ", array(':city' => $this->_id));
if (!$count) {
$city = R::load('cities', $this->_id);
R::trash($city);
return true;
}
return false;
}
示例3: getCLientesTotal
function getCLientesTotal()
{
$app = \Slim\Slim::getInstance();
$total = R::dispense('total');
$total->total = R::count('clientes');
$app->response()->header('Content-Type: text/html; charset=utf-8');
$app->response()->header('Content-Type', 'application/json');
//TODO: Buscar un modo elegante de hacer lo siguiente:
echo json_encode(R::exportAll($total)[0]);
}
示例4: deleteCategory
public function deleteCategory()
{
$count = R::count('jobs', " category=:category ", array(':category' => $this->_id));
if (!$count) {
$category = R::load('categories', $this->_id);
R::trash($category);
return true;
}
return false;
}
示例5: getWisdom
public static function getWisdom($id)
{
$information = R::load('information', $id);
$typeData = self::getType($information);
$wisdomTypeArray = [1 => 1, 2 => 2, 3 => 3];
$out = '';
$autor = self::getAuthorName($id);
// if ($typeData[3]->id == 6) {
//
// $out = R::load('lesson', $id)->text . "Автор:<a href='?ctrl=user&action=UserInfo&id=" . $autor['id'] . "'> " . $autor['surname'] .
// " " . $autor['name'] . " " . $autor['andername'] . " </a></div>";
// return $out;
// }
if ($typeData[3]->id == 1) {
$count_modul = R::count("education", " education.information_id = ? and education.block = 1", [$id]);
} elseif ($typeData[3]->id == 5) {
$count_modul = R::count("lesson", "lesson.information_id = ? and lesson.block = 1", [$id]);
}
$out .= "<ol class=\"breadcrumb\">\r\n <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&page=1\">" . $typeData[3]->name . "</a></li>\r\n <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&page=1\">" . $typeData[2]->name . "</a></li>\r\n <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&category=" . $typeData[1]->id . "&page=1\">" . $typeData[1]->name . "</a></li>\r\n <li><a href=\"?ctrl=wisdom&action=WisdomType&type=" . $typeData[3]->id . "&subtype=" . $typeData[2]->id . "&category=" . $typeData[1]->id . "&subcategory=" . $typeData[0]->id . "&page=1\">" . $typeData[0]->name . "</a></li>\r\n\r\n </ol>";
$out .= "<h2>" . $information->name . "</h2>";
$out .= "<div style='margin-bottom: 15px;'>" . $information->description . "</div>";
if ($typeData[3]->id == 6) {
return $out;
}
if ($count_modul == 0) {
$out .= "<h2 class='text-center'>Совсем скоро!</h2>";
return $out;
}
$out .= "<ul class=\"list-group\">\r\n <li class=\"list-group-item active\">Дополнительная информация</li>\r\n <li class=\"list-group-item \">Автор:\r\n <a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'>" . $autor['login'] . "</a> |\r\n <a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'> " . $autor['surname'] . " " . $autor['name'] . " " . $autor['andername'] . " </a></li>\r\n <li class=\"list-group-item\"> Кол-во модулей: " . $count_modul . "</li></ul>";
// print_r($information);
if ($typeData[3]->id == 1) {
$education = $information->withCondition('education.information_id = ? and education.block = 1', [$id])->ownEducationList;
} elseif ($typeData[3]->id == 5) {
$education = $information->withCondition('lesson.information_id = ? and lesson.block = 1', [$id])->ownLessonList;
}
$out .= "<ul class=\"list-group\"><li class=\"list-group-item active\">Изучаемые модули</li>";
foreach ($education as $item) {
$out .= "<li class=\"list-group-item \"><h4 class=\"list-group-item-heading\">" . $item->name . "</h4>\r\n <p class=\"list-group-item-text\">{$item->description}</p>\r\n </li>";
}
$out .= "</ul>";
$requirements = $information->withCondition('block = 1')->ownRequirementsList;
$out .= "<ul class=\"list-group\"><li class=\"list-group-item active\">Требования</li>";
if (empty($requirements)) {
$out .= "<li class=\"list-group-item\"><strong>Без дополнительных требований</strong></li></ul>";
} else {
foreach ($requirements as $item) {
$information_requirements = R::getRow("SELECT information.id,information.name from information WHERE information.id = ?", [$item->requirements]);
$out .= "<li class=\"list-group-item\"><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $information_requirements['id'] . "'>" . $information_requirements['name'] . "</a></li>";
}
$out .= "</ul>";
}
$out .= "</div><div class=\"col-sm-3\"></div>\r\n <div class=\"col-sm-6\">\r\n <a href=\"?ctrl=subscription&action=SubscriptionById&id=" . $id . "\"><button style='margin-top:15px;' class=\"btn btn-success btn-block\">Записаться!</button></a>\r\n </div>\r\n <div class=\"col-sm-3\"></div>";
return $out;
}
示例6: handle
/**
* Handle publication recent results operations /
*
* @param object $context The context object for the site
*
* @return string A template name
*/
public function handle($context)
{
$pagesize = 5;
$amount = R::count('publication');
$page = $context->getpar('page', 1);
# Find all publications and paginate them.
$pubs = R::findAll('publication', 'ORDER BY Id desc limit ?,?', [($page - 1) * $pagesize, $pagesize]);
# Get the URL for the paginator.
$url = $context->action() . '?';
# Delegate the publishement bean to the results handler.
return (new Results($pubs, $url, $pagesize, $amount, $page))->handle($context);
}
示例7: testDependency4
/**
* Tests dependencies (variation).
*
* @return void
*/
public function testDependency4()
{
R::dependencies(array('bean' => array('can')));
$can = $this->createCanForBean();
asrt(R::count('bean'), 1);
R::trash($can);
asrt(R::count('bean'), 0);
R::dependencies(array());
$can = $this->createCanForBean();
asrt(R::count('bean'), 1);
R::trash($can);
asrt(R::count('bean'), 1);
}
示例8: __construct
public function __construct()
{
// Check for pre-existing fields in db
$gnl_count = R::count('fields', ' service=? ', array('gnl'));
$sf_count = R::count('fields', ' service=? ', array('sf'));
$mapped_count = R::count('fields', ' service=? ', array('mapped'));
// If no GNL keys mapped, use the following array and store in db
if ($gnl_count < 1) {
$key_items = '0,1,caller_city,caller_name,caller_number,caller_postal_code,caller_state,classification,comments,date,duration,email,first_name,help,how_can_we_help,id,im_budget,interested_in,name,notes,phone,seogroup-form-email,seogroup-form-keyword,seogroup-form-name,source,status,trackable_number,type,website_budget,website_url';
$w = R::dispense('fields');
$w->service = 'gnl';
$w->key = $key_items;
R::store($w);
} else {
$leads = R::find('fields', 'service = ?', array('gnl'));
foreach ($leads as $key => $value) {
$key_items .= $value->key;
}
}
$gnl_fields = explode(',', $key_items);
unset($key_items);
// If no SF keysk call GetSFKey which grabs the keys from SF
if ($sf_count < 1) {
$leads = new GetSFKey();
$sf_fields = $leads->sf_fields;
foreach ($sf_fields as $key => $value) {
$key_items .= $value->name . ',';
}
$sf_fields = explode(',', $key_items);
} else {
$leads = R::find('fields', 'service = ?', array('sf'));
foreach ($leads as $key => $value) {
$key_items = $value->key;
}
$sf_fields = explode(',', $key_items);
}
// Mapped field
if ($mapped_count > 0) {
$mapped = R::find('fields', 'service = ?', array('mapped'));
foreach ($mapped as $key => $value) {
$mapped_keys .= $value->key;
}
$mapped_fields = explode(',', $mapped_keys);
}
$this->gnl_fields = $gnl_fields;
$this->sf_fields = $sf_fields;
$this->mapped_fields = $mapped_fields;
}
示例9: manageView
public function manageView()
{
/*
* Loading libraries
*/
$this->load->library(array('rb', 'session'));
$this->load->helper(array('form'));
/*
* Verify if user has autority to view the ic's
*/
if (!parent::_hasAuth('view_ic', $this->session->userdata('user_ic'))) {
echo "Você não tem permissão para realizar este procedimento.";
exit;
}
/*
* Setting allowed functions of user for manage information center
*/
$allow = '';
if (parent::_hasAuth('edit_ic', $this->session->userdata('user_ic'))) {
$allow .= 'E';
}
if (parent::_hasAuth('create_ic', $this->session->userdata('user_ic'))) {
$allow .= 'C';
}
if (parent::_hasAuth('remove_ic', $this->session->userdata('user_ic'))) {
$allow .= 'R';
}
/*
* Verify if the user is logged in MASTER IC or not. If it's the MASTER IC
* then it shows all the IC's, otherwise, only show the actual IC.
*/
$ics = null;
if (R::count('ic', 'id=? AND master="yes" ', array($this->session->userdata('user_ic')))) {
$ics = R::find('ic', ' active!="no" ');
} else {
$ics = R::find('ic', ' id=? AND active!="no" ', array($this->session->userdata('user_ic')));
}
/*
* Loading views
*/
$this->load->view('dashboard/template/header');
$this->load->view('dashboard/template/menu', array('menu' => parent::_getMenu(parent::_getIc()->id), 'ics' => parent::_getIcs(), 'ic' => parent::_getIc()));
$this->load->view('dashboard/ic/manage', array('ics' => $ics, 'gauth' => R::find('gauth'), 'allow' => $allow));
$this->load->view('dashboard/template/footer');
}
示例10: create
public function create($email, $firstname, $lastname, $password, $passwordConfirm)
{
//echo "create called";
// exit();
$errors = array('email' => false, 'firstname' => false, 'lastname' => false, 'password' => false);
$fixes = array();
if ('' == $email || '' == $firstname || '' == $lastname || '' == $password) {
$fixes[] = "All fields are required.";
}
if (0 != \R::count(self::TABLENAME, 'email = ?', [$email])) {
$errors['email'] = true;
$fixes[] = 'That email address is already in use. Please click Sign In below and try again.';
}
/* if (0 != \R::count(self::TABLENAME, 'email = ?', [$email]))
{
$errors['email'] = true;
$fixes[] = 'That email is already in use.';
}
*/
if ($password != $passwordConfirm) {
$errors['password'] = true;
$fixes[] = 'The passwords entered do not match.';
}
if (0 == count($fixes)) {
$date = date(self::DATE_FORMAT);
$user = $this->bean;
$user->email = $email;
$user->first_name = $firstname;
$user->last_name = $lastname;
$user->salt = password_hash($email . $date, PASSWORD_BCRYPT);
$user->password = password_hash($password, PASSWORD_BCRYPT, array('salt' => $user->salt));
$user->created_at = $date;
$user->last_login = null;
$user->loginAttempts = 0;
$user->active = true;
// Add any other attributes you want a User to have here (or not,
// Redbean will add them when you use them if the DB isn't frozen).
\R::store($user);
$this->bean = $user;
$_SESSION['user'] = $user;
}
return array($errors, $fixes);
}
示例11: testCountAndWipe
/**
* Test count and wipe.
*
* @return void
*/
public function testCountAndWipe()
{
testpack("Test count and wipe");
$page = R::dispense("page");
$page->name = "ABC";
R::store($page);
$n1 = R::count("page");
$page = R::dispense("page");
$page->name = "DEF";
R::store($page);
$n2 = R::count("page");
asrt($n1 + 1, $n2);
R::wipe("page");
asrt(R::count("page"), 0);
asrt(R::$redbean->count("page"), 0);
asrt(R::$redbean->count("kazoo"), 0);
// non existing table
R::freeze(TRUE);
asrt(R::$redbean->count("kazoo"), 0);
// non existing table
R::freeze(FALSE);
$page = R::dispense('page');
$page->name = 'foo';
R::store($page);
$page = R::dispense('page');
$page->name = 'bar';
R::store($page);
asrt(R::count('page', ' name = ? ', array('foo')), 1);
// Now count something that does not exist, this should return 0. (just be polite)
asrt(R::count('teapot', ' name = ? ', array('flying')), 0);
asrt(R::count('teapot'), 0);
$currentDriver = $this->currentlyActiveDriverID;
// Some drivers don't support that many error codes.
if ($currentDriver === 'mysql' || $currentDriver === 'postgres') {
try {
R::count('teaport', ' for tea ');
fail();
} catch (RedBean_Exception_SQL $e) {
pass();
}
}
}
示例12: 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;
}
}
示例13: updateDo
public function updateDo()
{
/*
* Loading libraries and helpers
*/
$this->load->library(array('rb', 'form_validation', 'session'));
$this->load->helper(array('security'));
/*
* User is logged ?
*/
if (!parent::_isLogged()) {
redirect('dashboard');
exit;
}
/*
* Getting post variables
*/
$id = $this->input->post('id');
$name = $this->input->post('name');
$email = $this->input->post('email');
$pass = $this->input->post('passre');
$cpf = $this->input->post('cpf');
$phone = $this->input->post('phone');
$permissions = $this->input->post('permissions');
/*
* Has permissions?
*/
$canEditPermissions = parent::_hasAuth('edit_user_permission', $this->session->userdata('user_ic'));
if ($canEditPermissions && !count($permissions)) {
$this->session->set_flashdata('error', 'O usuário precisa ter permissões para ser atualizado.');
$this->session->set_flashdata('popform', array('name' => $name, 'email' => $email, 'cpf' => $cpf, 'phone' => $phone));
redirect('dashboard/user/edit/' . $id);
}
/*
* Resolving permissions
*/
$permissionsFinal = array();
foreach ($permissions as $p) {
$ar = explode('-', $p);
$permissionsFinal[] = array('ic' => R::findOne('ic', ' id=? ', array($ar[0])), 'group' => R::findOne('group', ' id=? ', array($ar[1])));
}
/*
* Setting rules
*/
$this->form_validation->set_rules('name', 'Nome', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('cpf', 'CPF', 'required');
$this->form_validation->set_rules('phone', 'Telefone', 'required');
if ($canEditPermissions) {
$this->form_validation->set_rules('permissions[]', 'Permissões', 'required');
}
/*
* Normally, user wiil never see what makes this true, just for security issues
*/
if (!$this->form_validation->run()) {
$this->session->set_flashdata('error', $this->form_validation->error_string());
if ($canEditPermissions) {
$this->session->set_flashdata('popform', array('name' => $name, 'email' => $email, 'cpf' => $cpf, 'phone' => $phone, 'permissions' => $user->ownPermissionList));
} else {
$this->session->set_flashdata('popform', array('name' => $name, 'email' => $email, 'cpf' => $cpf, 'phone' => $phone));
}
redirect('dashboard/user/edit/' . $id);
exit;
}
/*
* User has auth to do this?
*/
if (!parent::_hasAuth('edit_user', $this->session->userdata('user_ic'))) {
$this->session->set_flashdata('error', 'Você não tem permissão para realizar este procedimento.');
redirect('dashboard/user');
exit;
}
/*
* User has auth to do this?
*/
$user = R::findOne('user', 'id=? AND active!="no" ', array($id));
/*
* Verifying if user exists
*/
if ($user == NULL) {
$this->session->set_flashdata('error', 'O usuário solicitado para atualização não existe.');
redirect('dashboard/user');
}
/*
* CPF already exists ?
*/
if ($user->cpf != $cpf && R::count('user', 'cpf=?', array($cpf))) {
$this->session->set_flashdata('error', 'Já existe um usuário cadastrado com este CPF.');
redirect('dashboard/user');
exit;
}
/* begin clone to log */
$user->ownPermissionList;
$aprex0 = json_encode($user->export());
/* end clone to log */
$user->name = $name;
$user->email = $email;
if ($pass != '') {
$user->password = do_hash($pass, 'md5');
}
//.........这里部分代码省略.........
示例14: testMultiAssociationDissociation
/**
* Test multiple assiociation.
*
* @return void
*/
public function testMultiAssociationDissociation()
{
$wines = R::dispense('wine', 3);
$cheese = R::dispense('cheese', 3);
$olives = R::dispense('olive', 3);
R::associate($wines, array_merge($cheese, $olives));
asrt(R::count('cheese'), 3);
asrt(R::count('olive'), 3);
asrt(R::count('wine'), 3);
asrt(count($wines[0]->sharedCheese), 3);
asrt(count($wines[0]->sharedOlive), 3);
asrt(count($wines[1]->sharedCheese), 3);
asrt(count($wines[1]->sharedOlive), 3);
asrt(count($wines[2]->sharedCheese), 3);
asrt(count($wines[2]->sharedOlive), 3);
R::unassociate($wines, $olives);
asrt(count($wines[0]->sharedCheese), 3);
asrt(count($wines[0]->sharedOlive), 0);
asrt(count($wines[1]->sharedCheese), 3);
asrt(count($wines[1]->sharedOlive), 0);
asrt(count($wines[2]->sharedCheese), 3);
asrt(count($wines[2]->sharedOlive), 0);
R::unassociate(array($wines[1]), $cheese);
asrt(count($wines[0]->sharedCheese), 3);
asrt(count($wines[0]->sharedOlive), 0);
asrt(count($wines[1]->sharedCheese), 0);
asrt(count($wines[1]->sharedOlive), 0);
asrt(count($wines[2]->sharedCheese), 3);
asrt(count($wines[2]->sharedOlive), 0);
R::unassociate(array($wines[2]), $cheese);
asrt(count($wines[0]->sharedCheese), 3);
asrt(count($wines[0]->sharedOlive), 0);
asrt(count($wines[1]->sharedCheese), 0);
asrt(count($wines[1]->sharedOlive), 0);
asrt(count($wines[2]->sharedCheese), 0);
asrt(count($wines[2]->sharedOlive), 0);
}
示例15: json_encode
if ($vehiculo) {
$app->response()->header('Content-Type', 'application/json');
echo json_encode(R::exportAll($vehiculo)[0]);
} else {
throw new ResourceNotFoundException();
}
} catch (ResourceNotFoundException $e) {
$app->response()->status(404);
} catch (Exception $e) {
$app->response()->status(400);
$app->response()->header('X-Status-Reason', $e->getMessage());
}
});
$app->get('/vehiculos/total/', function () use($app) {
$total = R::dispense('total');
$total->total = R::count('vehiculos');
$app->response()->header('Content-Type: text/html; charset=utf-8');
$app->response()->header('Content-Type', 'application/json');
//TODO: Buscar un modo elegante de hacer lo siguiente:
echo json_encode(R::exportAll($total)[0]);
});
$app->get('/vehiculos/page/:pagenumber', function ($pagenumber) use($app) {
$vehiculos = R::findAll('vehiculos', 'ORDER BY economico LIMIT ?,8', array($pagenumber * 8 - 8));
$app->response()->header('Content-Type: text/html; charset=utf-8');
$app->response()->header('Content-Type', 'application/json');
foreach ($vehiculos as $vehiculo) {
$vehiculo->tipo_vehiculos = $vehiculo->tipo_vehiculos;
}
echo json_encode(R::exportAll($vehiculos));
});
// Handle GET by vehiculo name