本文整理汇总了PHP中Parse\ParseQuery::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseQuery::limit方法的具体用法?PHP ParseQuery::limit怎么用?PHP ParseQuery::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseQuery
的用法示例。
在下文中一共展示了ParseQuery::limit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* @inheritdoc
*/
public function process(array $settings = [])
{
$this->processOrders($settings);
$this->processFilters($settings);
$this->source->limit($settings['limit']);
$this->source->skip(($settings['page'] - 1) * $settings['limit']);
// run queries
$gridData = new Grid\Data($this->source->find());
// get all records to set grid total
// @todo: cache result of total query for few minutes
$this->source = new ParseQuery($this->collectionName);
$this->processOrders($settings);
$this->processFilters($settings);
$gridData->setTotal(sizeof($this->source->limit(1000)->find()));
return $gridData;
}
示例2: find
public function find($className, $equalToArray = array(), $ascending = null, $desceding = null, $limit = null, $skip = null, $includeArray = array())
{
$query = new ParseQuery($className);
if ($equalToArray) {
foreach ($equalToArray as $key => $value) {
$query->equalTo($key, $value);
}
}
if ($ascending) {
$query->ascending($ascending);
}
if ($desceding) {
$query->descending($descending);
}
if ($limit) {
$query->limit($limit);
}
if ($skip) {
$query->skip($skip);
}
if ($includeArray) {
foreach ($includeArray as $include) {
$query->includeKey($include);
}
}
return $query->find();
}
示例3: indexAction
/**
* Lists all ProjectsAdmin entities.
*
* @Route("/index/{page}", name="admin_projects", defaults={ "page" = 1 })
* @Method("GET")
* @Template()
*/
public function indexAction($page)
{
$query = new ParseQuery('Project');
$query->ascending("label");
$query->limit(12);
$query->skip(12 * ($page - 1));
$entities = $query->find();
return array('entities' => $entities, 'hits' => ceil($query->count() / 12), 'page' => $page, 'csrf' => $this->get('form.csrf_provider'));
}
开发者ID:leonardobarrientosc,项目名称:4046-PUCV-ICC-FICHAS-OBRAS-CIVILES,代码行数:16,代码来源:ProjectsAdminController.php
示例4: near
/**
* @param $column
* @param $latitude
* @param $longitude
* @param $limit
* @param array $keyToInclude
*
* @return Collection|ParseObject[]
*/
public function near($column, $latitude, $longitude, $limit = 10, $keyToInclude = [])
{
$location = new ParseGeoPoint($latitude, $longitude);
$this->query->near($column, $location);
$this->query->limit($limit);
for ($i = 0; $i < count($keyToInclude); $i++) {
$this->query->includeKey($keyToInclude[$i]);
}
return Collection::make($this->query->find($this->useMasterKey));
}
示例5: getStolenBikes
function getStolenBikes()
{
$query = new ParseQuery("Bikes");
$query->exists("sessionStartTime");
$query->limit(1000);
$results = $query->find();
$count = count($results);
$listOfBikes = array();
$stolenBikes = 0;
for ($i = 0; $i < $count; $i++) {
$startDate = $results[$i]->get("sessionStartTime");
$startDate = $startDate->format('Y-m-d H:i:s');
$startDate = strtotime($startDate);
$currentDate = new DateTime('now');
$currentDate = $currentDate->format('Y-m-d H:i:s');
$currentDate = strtotime($currentDate);
$subtractedDate = $currentDate - $startDate;
$expiredTime = 200 * 60;
if ($subtractedDate >= $expiredTime * 60) {
$stolenBikes++;
$bike = $results[$i];
try {
$lostBike = new ParseObject("LostBikes");
$lostBike->set("bikeId", $bike->getObjectId());
$user = $bike->get("currentUser");
$user->fetch();
$customerID = $user->get("stripeID");
$amount = 200 * 100;
$charge = \Stripe\Charge::create(array('customer' => $customerID, 'amount' => $amount, 'currency' => 'usd'));
$lostBike->set("currentUser", $user);
$lostBike->set("lastLocation", $bike->get("lastLocation"));
$lostBike->set("condition", $bike->get("condition"));
$lostBike->save();
$bike->destroy();
} catch (\Parse\ParseException $ex) {
return 'Failed to create LostBikes object and destroy Bikes object ' . $ex->getMessage();
} catch (\Stripe\Error\InvalidRequest $e) {
return $e->getMessage();
} catch (\Stripe\Error\Authentication $e) {
return $e->getMessage();
} catch (\Stripe\Error\ApiConnection $e) {
return $e->getMessage();
} catch (\Stripe\Error\Base $e) {
return $e->getMessage();
} catch (Exception $e) {
return $e->getMessage();
}
}
}
$rString = 0;
if ($stolenBikes > 0) {
$rString = "Successfully removed " . $stolenBikes . " stolen bikes.";
}
return $rString;
}
示例6: showHome
public function showHome(Request $request)
{
$current_user = ParseUser::getCurrentUser();
if (!$current_user) {
return redirect()->route('login');
}
$query = ParseUser::query();
$current_user = $query->get($current_user->getObjectId());
Html\Assets::addLink(Html\Link::Css(elixir('css/default.css')));
Html\Assets::addMetaTag(Html\Meta::Tag('description', ''));
$query = new ParseQuery("ChatRoom");
$query->equalTo('members', $current_user);
try {
$chatRooms = $query->find();
$query = new ParseQuery("Messages");
$query->containedIn("chatRoom", $chatRooms);
$query->descending('createdAt');
$query->includeKey('chatRoom');
$query->includeKey('user');
$query->limit(20);
$messages = $query->find();
$data = [];
foreach ($messages as $message) {
$chatRoom = $message->get('chatRoom');
$event = $chatRoom->get('event');
$evQuery = new ParseQuery('Events');
$evQuery->includeKey('group');
$event = $evQuery->get($event->getObjectId());
$group = $event->get('group');
$relation = $message->getRelation("asset");
$aqry = $relation->getQuery();
$assets = $aqry->find();
$temp = ['group' => $group, 'event' => $event, 'chatRoom' => $chatRoom, 'message' => ['msg' => $message, 'assets' => $assets], 'user' => $message->get('user')];
$data[] = $temp;
}
} catch (ParseException $ex) {
// The object was not retrieved successfully.
// error is a ParseException with an error code and message.
echo $ex->getMessage();
}
$renderData = $this->getRenderData($request);
$renderData['user'] = $current_user;
$renderData['activeBarTab'] = "dashboard";
$renderData['data'] = $data;
return view('home', $renderData);
}
示例7: testQueryDataUnt
public function testQueryDataUnt()
{
$department = "ACCT";
$course = "2010";
$section = "001";
$obj = ParseObject::create('TestObject');
$obj->set('department', $department);
$obj->set('course', $course);
$obj->set('section', $section);
$obj->save();
$query = new ParseQuery('TestObject');
$query->startsWith('department', $department);
$query->equalTo('course', $course);
$query->startsWith('section', $section);
$query->limit(1);
$response = $query->find();
$this->assertTrue(count($response) == 1);
}
示例8: queryDataUnt
function queryDataUnt($department, $course, $section = "001")
{
$query = new ParseQuery("Book");
$query->startsWith("department", $department);
$query->equalTo("course", $course);
//$query->startsWith("section", $section);
$query->limit(1);
try {
$result = $query->find();
if (isset($result[0])) {
$object = $result[0];
$GLOBALS['isbn'] = $object->get("isbn");
$GLOBALS['name'] = $object->get("name");
$GLOBALS['priceNewUnt'] = $object->get("priceNew");
}
} catch (ParseException $ex) {
echo "Book not found in database.";
}
}
示例9: toExcel
public function toExcel()
{
$con = new Connect();
$var = $con->connect_to_db();
//iniciamos una consulta para recibir todos los usuarios ausentes de la sede del mentor logueado
$query = new ParseQuery("Asistencia");
$query->limit(1000);
$query->includeKey('Usuario_FK');
$results = $query->find();
$listado = array();
for ($i = 0; $i < count($results); $i++) {
$object = $results[$i];
$usuario = $object->get('Usuario_FK');
$sede = $object->get('Sede');
$persona = array('Nombre' => $usuario->get("Nombre"), "Apellido" => $usuario->get("Apellido"), "Presente" => $object->get("Presente"));
array_push($listado, $persona);
}
//"Fecha" => $object->get("fecha"),
//definimos una función para ordenar el array con nuestros parámetros
function custom_sort($a, $b)
{
return $a['Nombre'] > $b['Nombre'];
}
//ordenamos el array
usort($listado, "custom_sort");
//transformamos a json
//$json = json_encode($listado);
//echo $json;
$filename = "asistencia.csv";
$delimiter = ";";
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="' . $filename . '";');
// open the "output" stream
// see http://www.php.net/manual/en/wrappers.php.php#refsect2-wrappers.php-unknown-unknown-unknown-descriptioq
$f = fopen('php://output', 'w');
foreach ($listado as $line) {
fputcsv($f, $line, $delimiter);
}
}
示例10: testEachFailsWithLimit
public function testEachFailsWithLimit()
{
$total = 50;
$count = 25;
$this->saveObjects($total, function ($i) {
$obj = new ParseObject("Object");
$obj->set("x", $i + 1);
return $obj;
});
$query = new ParseQuery("Object");
$query->lessThanOrEqualTo("x", $count);
$query->limit(5);
$this->setExpectedException('\\Exception', 'limit');
$query->each(function ($obj) {
});
}
示例11: limitQuery
public function limitQuery()
{
$query = new ParseQuery("Test");
try {
ParseClient::$THROW_RESPONSE = true;
$query->limit(10);
$results = $query->find();
} catch (\Exception $ex) {
$msg = json_decode($ex->getMessage(), true);
return $msg ? $msg : $ex->getMessage();
}
}
示例12: search
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function search()
{
$user = Auth::user();
if ($user) {
$input = Input::all();
//get used paramater and set it to a boolean
$used = $input['used'] == 'true' ? true : false;
$search = $input['search'];
$query = new ParseQuery("Transaction");
$query->limit(1000);
//only Get results from that sponsor
$query->equalTo("sponsor", $user->sponsor);
$query->equalTo("deployment", env("DEPLOYMENT"));
$query->equalTo("studentID", $search);
$query->equalTo("used", $used);
$data = $query->find();
if ($used) {
return View::make('manage.used', $data)->with('data', $data);
//)->with($query->find());
} elseif (condition) {
return View::make('manage.unused', $data)->with('data', $data);
//)->with($query->find());
}
} else {
return Redirect::to('login');
}
}
示例13: user_register_report
function user_register_report($first, $last, $pass, $email, $report_id)
{
$response = new Response();
$name = $first . "_" . $last;
$user = new ParseUser();
$user->set("username", strtolower($name));
$user->set("email", $email);
$user->set("password", $pass);
try {
$user->signUp();
$_SESSION['user'] = $user;
$_SESSION['notification'] = true;
$query = new ParseQuery("_Session");
$query->equalTo("user", $user);
$query->includeKey("user");
$query->descending("createdAt");
$query->limit(1);
$new = $query->find(true);
$_SESSION['last_date'] = date_format($new[0]->getCreatedAt(), 'Y-m-d\\TH:i:s.u\\Z');
echo add_user_report($report_id, $user);
} catch (ParseException $ex) {
$response->success = false;
$response->message = 'Error: Failed to register: ' . $error;
echo json_encode($response);
}
}
示例14: ParseQuery
/**
* Same code from analytics.php Should need a ajax-Php function in order to call those methods...
* Copied the code for quickness
*/
$x = $_GET['q'];
ParseClient::initialize('P60EfTUuOZoeZyD2qSLpOrc8DWwUk2YjEqU2HY1R', 's3b2cfGtQhSFYM16ZIJQ7yXioTjt35Um5mn9SyP8', '3jz6CONqt5psS4UlGu3RB28ldIw311Iv2I8eA3Mh');
$query = new ParseQuery("Reading");
if ($x < 32) {
$period = date('Y-m-d\\TH:i:s.u\\Z', strtotime("-" . $x . "day"));
} else {
$period = date('Y-m-d\\TH:i:s.u\\Z', strtotime("-7 day"));
$x = 7;
}
$results = array();
$query->greaterThan("createdAt", $period);
$query->limit(10000);
$results = $query->find();
$weeklyTraffic = array();
$currentDay = $results[0]->getCreatedAt()->format('d');
$weeklyTraffic[$currentDay] = 0;
$labelsString = "";
$data = "";
for ($i = 0; $i < count($results); $i++) {
if ($currentDay == $results[$i]->getCreatedAt()->format('d')) {
$weeklyTraffic[$results[$i]->getCreatedAt()->format('d') . ""] = $weeklyTraffic[$results[$i]->getCreatedAt()->format('d') . ""] + 1;
} else {
/*
* Prepare strings for x axis in javascript
*/
$labelsString .= $currentDay . ',';
$data .= $weeklyTraffic[$currentDay] . ',';
示例15: ParseObject
$users->limit(1000);
$users->equalTo("objectId", $_GET['objectId']);
$results = $users->find();
if (count($results['results']) > 0) {
//$dataObject = json_decode(file_get_contents("php://input"), true);
$user = ParseUser::logIn($results['results'][0]['username'], $results['results'][0]['passwordNew']);
$deleteUser = new ParseObject('_User', $_GET['objectId']);
$deleteUser->destroy();
$deleteUser->save();
}
$returnData = json_encode(array("code" => 1));
break;
case "assignUser":
$dataObject = json_decode(file_get_contents("php://input"), true);
$users = new ParseQuery("_User");
$users->limit(1000);
$users->equalTo("objectId", $_GET['objectId']);
$results = $users->find();
$user = ParseUser::logIn($results['results'][0]['username'], $results['results'][0]['passwordNew']);
$userObject = new ParseObject("_User", $_GET['objectId']);
$userObject->set("refemployerid", $dataObject['refemployerid']);
$userObject->save();
$returnData = json_encode(array("code" => 1));
break;
case "addEmployee":
$dataObject = json_decode(file_get_contents("php://input"), true);
$addEmployee = new ParseObject('Employers');
$addEmployee->set("name", $dataObject['name']);
$addEmployee->set("primaryColor", $dataObject['primaryColor']);
$addEmployee->set("secondaryColor", $dataObject['secondaryColor']);
$addEmployee->set("agencyId", $dataObject['agencyId']);