本文整理汇总了PHP中Criteria::setLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::setLimit方法的具体用法?PHP Criteria::setLimit怎么用?PHP Criteria::setLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::setLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$limit = $pl->getParameterValue("limit", "MODULE");
if ($limit == null || !is_numeric($limit) || $limit < 1 || $limit > 300) {
$limit = 5;
}
$categoryId = $pl->getParameterValue("categoryId", "MODULE", "AMODULE");
if ($categoryId !== null) {
$category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
if ($category == null || $category->getSiteId() != $site->getSiteId()) {
throw new ProcessException(_("The category can not be found."));
}
}
// get recent forum posts
$c = new Criteria();
$c->add("forum_post.site_id", $site->getSiteId());
if ($category) {
$c->add("forum_post.category_id", $category->getCategoryId());
}
$c->addJoin("thread_id", "forum_thread.thread_id");
$c->addOrderDescending("post_id");
$c->setLimit($limit);
$posts = DB_ForumPostPeer::instance()->select($c);
$runData->contextAdd("posts", $posts);
}
示例2: executeSearchSchools
public function executeSearchSchools(sfWebRequest $request)
{
$this->getResponse()->setContentType('application/json');
if (strlen(trim($q = $request->getParameter('q'))) > 2) {
$c = new Criteria();
$crit = $c->getNewCriterion(OriginSchoolPeer::NAME, "%{$q}%", Criteria::LIKE);
$crit->addOr($c->getNewCriterion(OriginSchoolPeer::ADDRESS, "%{$q}%", Criteria::LIKE));
$crit->addOr($c->getNewCriterion(OriginSchoolPeer::CUE, "%{$q}%", Criteria::LIKE));
$c->add($crit);
$c->setLimit(20);
$results = array();
foreach ($matches = OriginSchoolPeer::doSelect($c) as $match) {
$results[] = array('id' => $match->getId(), 'text' => $match->__toString());
}
return $this->renderText(json_encode(array('results' => $results)));
} else {
if ($request->getParameter('id') !== null) {
$match = OriginSchoolPeer::retrieveByPK($request->getParameter('id'));
$result = null;
if ($match !== null) {
$result = array('id' => $match->getId(), 'text' => strval($match));
}
return $this->renderText(json_encode($result));
}
}
return $this->renderText('{}');
}
示例3: select
/**
* Make a select the database
* @param Criteria $criteria
* @param string $table
* @param bollean $limitOne
* @return bollean
*/
public function select(Criteria $criteria, $table, $limitOne = false)
{
if ($limitOne) {
$criteria->setLimit(1);
} else {
$stdClass = new ArrayObject();
}
if (empty($table)) {
return false;
}
$this->table = $table;
try {
$this->pdo->beginTransaction();
$execute = $this->pdo->prepare($this->mountSqlSelect($criteria));
$execute->execute();
$this->pdo->commit();
if ($execute->rowCount() == 0) {
return false;
}
if ($limitOne) {
$stdClass = $execute->fetch(PDO::FETCH_OBJ);
} else {
for ($i = 0; $i < $execute->rowCount(); $i++) {
$stdClass[] = $execute->fetch(PDO::FETCH_OBJ);
}
}
return $stdClass;
} catch (PDOException $e) {
$this->pdo->rollBack();
return false;
}
}
示例4: myBatchPartnerUsage
public function myBatchPartnerUsage()
{
self::initDb();
$partners_exists = true;
$start_pos = 0;
$bulk_size = 500;
while ($partners_exists) {
$c = new Criteria();
// get only free partners
$c->addAnd(PartnerPeer::PARTNER_PACKAGE, 1);
$c->addAnd(PartnerPeer::MONITOR_USAGE, 1);
$c->setOffset($start_pos);
$c->setLimit($bulk_size);
$partners = PartnerPeer::doSelect($c);
if (!$partners) {
TRACE("No more partners. offset: {$start_pos} , limit: {$bulk_size} .");
$partners_exists = false;
} else {
TRACE("Looping " . ($start_pos + $bulk_size - 1) . " partners, offset: {$start_pos} .");
foreach ($partners as $partner) {
myPartnerUtils::doPartnerUsage($partner, true);
}
}
unset($partners);
$start_pos += $bulk_size;
}
}
示例5: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
# Recently added
$c = new Criteria();
$c->addDescendingOrderByColumn(PluginPeer::CREATED_AT);
$c->setLimit(6);
$this->recent = PluginPeer::doSelect($c);
# Most downloaded
$c = new Criteria();
$c->addDescendingOrderByColumn(PluginPeer::DOWNLOADS_COUNT);
$c->setLimit(3);
$this->hot = PluginPeer::doSelect($c);
# Tags
$c = new Criteria();
$c->addDescendingOrderByColumn(TermPeer::COUNT);
$c->setLimit(10);
$this->terms = TermPeer::retrieveTags($c);
# Authors
$c = new Criteria();
$c->addDescendingOrderByColumn(AuthorPeer::LOGGED_AT);
$c->setLimit(6);
// if ($this->getUser()->isAuthenticated())
// $c->add(AuthorPeer::ID, $this->getUser()->getId(), Criteria::NOT_EQUAL);
$this->authors = AuthorPeer::doSelect($c);
}
示例6: getLastUpdate
public static function getLastUpdate()
{
$c = new Criteria();
$c->addDescendingOrderByColumn(self::CREATED_AT);
$c->setLimit(1);
return self::doSelectOne($c);
}
示例7: getUserTodayQuote
/**
* @return PcQuoteOfTheDay|null|false
*/
public static function getUserTodayQuote()
{
$loggedInUser = PcUserPeer::getLoggedInUser();
$hideableHintsSetting = $loggedInUser->getHideableHintsSetting();
if ($hideableHintsSetting[PcHideableHintsSettingPeer::QUOTE_HINT] === 1) {
return false;
}
$localTimestamp = $loggedInUser->getTime();
$today = date('Ymd', $localTimestamp);
$c = new Criteria();
$c->add(self::SHOWN_ON, $today);
$todayQuote = self::doSelectOne($c);
if (!$todayQuote) {
$c = new Criteria();
$c->add(self::SHOWN_ON, null, Criteria::ISNULL);
$c->addAscendingOrderByColumn('rand()');
$c->setLimit(1);
$todayQuote = self::doSelectOne($c);
if ($todayQuote) {
$todayQuote->setShownOn($today)->save();
} else {
sfErrorNotifier::alert("There are no quotes available anymore.");
}
}
return $todayQuote;
}
示例8: addPermission
function addPermission($permissionCfg)
{
// verify obligatory fields
if (!$permissionCfg->name) {
throw new Exception('Permission name must be set');
}
if ((is_null($permissionCfg->partnerId) || $permissionCfg->partnerId === '') && (is_null($permissionCfg->partnerPackages) || $permissionCfg->partnerPackages === '')) {
throw new Exception('Permission partner id or partner package must be set');
}
if (isset($permissionCfg->partnerId) && $permissionCfg->partnerId != '') {
$partnerIds = explode(",", $permissionCfg->partnerId);
foreach ($partnerIds as $partnerId) {
addPermissionToPartner($permissionCfg, $partnerId);
}
}
if (isset($permissionCfg->partnerPackages) && $permissionCfg->partnerPackages != '') {
$countLimitEachLoop = 100;
$offset = $countLimitEachLoop;
$c = new Criteria();
$c->add(PartnerPeer::ID, 0, Criteria::GREATER_THAN);
$c->add(PartnerPeer::PARTNER_PACKAGE, explode(',', $permissionCfg->partnerPackages), Criteria::IN);
$c->setLimit($countLimitEachLoop);
$partners = PartnerPeer::doSelect($c);
while (count($partners)) {
foreach ($partners as $partner) {
addPermissionToPartner($permissionCfg, $partner->getId());
}
$c->setOffset($offset);
PartnerPeer::clearInstancePool();
$partners = PartnerPeer::doSelect($c);
$offset += $countLimitEachLoop;
sleep(1);
}
}
}
示例9: b_mysearch_last_search_show
function b_mysearch_last_search_show()
{
include_once XOOPS_ROOT_PATH . '/modules/mysearch/include/functions.php';
$mysearch_handler =& xoops_getmodulehandler('searches', 'mysearch');
$visiblekeywords = 0;
$block = array();
$visiblekeywords = mysearch_getmoduleoption('showindex');
if ($visiblekeywords > 0) {
$block['visiblekeywords'] = $visiblekeywords;
$totalcount = $mysearch_handler->getCount();
$start = 0;
$critere = new Criteria('mysearchid', 0, '<>');
$critere->setSort('datesearch');
$critere->setLimit($visiblekeywords);
$critere->setStart($start);
$critere->setOrder('DESC');
$tmpmysearch = new searches();
$elements = $mysearch_handler->getObjects($critere);
foreach ($elements as $oneelement) {
$search = array();
$search['keyword'] = $oneelement->getVar('keyword');
$search['date'] = formatTimestamp(strtotime($oneelement->getVar('datesearch')));
$search['uid'] = $oneelement->getVar('keyword');
$search['uname'] = $tmpmysearch->uname($oneelement->getVar('uid'));
$search['link'] = "<a href='" . XOOPS_URL . '/search.php?query=' . $oneelement->getVar('keyword') . "&action=results' target='_blank'>";
$block['searches'][] = $search;
unset($search);
}
}
return $block;
}
示例10: renderFieldCategory
protected function renderFieldCategory(ConfigFieldCategory $fieldCategory)
{
$str = "";
$fields = $fieldCategory->getConfigFields();
foreach ($fields as $field) {
$str .= "<fieldset>";
$str .= "<legend>" . $field->getName() . "</legend>";
$fieldId = $field->getId();
$cField = new Criteria();
$cField->add(FieldValuePeer::FIELD_ID, $fieldId);
/*$c1 = $cField->getNewCriterion(FieldValuePeer::VALUE, $query.'%', Criteria::LIKE);
$c2 = $cField->getNewCriterion(FieldValuePeer::VALUE, "", Criteria::NOT_EQUAL);
$c1->addAnd($c2);
$cField->addAnd($c1);*/
$cField->add(FieldValuePeer::VALUE, "", Criteria::NOT_EQUAL);
$cField->addGroupByColumn(FieldValuePeer::VALUE);
$cField->addAscendingOrderByColumn(FieldValuePeer::VALUE);
$cField->setLimit(15);
$values = FieldValuePeer::doSelect($cField);
$valueIndex = 0;
foreach ($values as $value) {
$str .= "<label>" . $value->getValue() . "</label>";
$str .= "<input type=\"checkbox\" name=\"fields[" . $field->getId() . "][{$valueIndex}]\" id=\"fields_" . $field->getId() . "_{$valueIndex}\" value=\"" . $value->getValue() . "\" /><br>";
$valueIndex++;
}
$str .= "</fieldset>";
}
return $str;
}
示例11: getTagCloud
public function getTagCloud()
{
$c = new Criteria();
$c->addOrder("searchTimes DESC");
$c->add("banned", "0");
$c->setLimit(Config::get("numberOfTagInTagCloud"));
$tags = $this->findAll($c);
if (count($tags) < min(Config::get("numberOfTagInTagCloud"), Config::get("minNumberOfTagInTagCloud"))) {
return array();
}
usort($tags, array($this, "sortTag"));
$maxSearchTimes = 0;
$minSearchTimes = pow(2, 32);
$minSize = 1;
$maxSize = 10;
foreach ($tags as $tag) {
$maxSearchTimes = max($maxSearchTimes, $tag['searchTimes']);
}
foreach ($tags as $tag) {
$minSearchTimes = min($minSearchTimes, $tag['searchTimes']);
}
$range = $maxSearchTimes - $minSearchTimes;
if ($range == 0) {
$range = 1;
}
$step = ($maxSize - $minSize) / $range;
foreach ($tags as &$tag) {
$tag['size'] = intval($minSize + ($tag['searchTimes'] - $minSearchTimes) * $step);
}
return $tags;
}
示例12: build
public function build($runData)
{
$query = $runData->getParameterList()->getParameterValue("query");
// split the query by ' '
$q = explode(' ', $query);
// escape regex syntax now
for ($i = 0; $i < count($q); $i++) {
$q[$i] = preg_quote($q[$i], '/');
}
$c = new Criteria();
foreach ($q as $q1) {
$c->add("nick_name", $q1, "~*");
}
$c->setLimit(101);
$users = DB_OzoneUserPeer::instance()->select($c);
$runData->contextAdd("users", $users);
// also prepare an array of user_id and nickname
$runData->ajaxResponseAdd("count", count($users));
if (count($users) == 101) {
$runData->ajaxResponseAdd("over100", true);
} else {
$runData->ajaxResponseAdd("over100", false);
}
$userIds = array();
$userNames = array();
foreach ($users as $u) {
$userIds[] = $u->getUserId();
$userNames[$u->getUserId()] = htmlspecialchars($u->getNickName());
}
$runData->ajaxResponseAdd("userIds", $userIds);
$runData->ajaxResponseAdd("userNames", $userNames);
}
示例13: myBatchPartnerUsage
public function myBatchPartnerUsage($partnerId = null)
{
self::initDb();
$partners_exists = true;
$start_pos = 0;
$bulk_size = 500;
while ($partners_exists) {
$c = new Criteria();
if (!is_null($partnerId)) {
$c->addAnd(PartnerPeer::ID, $partnerId);
}
$c->addAnd(PartnerPeer::PARTNER_PACKAGE, 1);
// get only free partners
$c->addAnd(PartnerPeer::MONITOR_USAGE, 1);
$c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_DELETED, CRITERIA::NOT_EQUAL);
$c->setOffset($start_pos);
$c->setLimit($bulk_size);
$partners = PartnerPeer::doSelect($c);
if (!$partners) {
KalturaLog::debug("No more partners. offset: {$start_pos} , limit: {$bulk_size} .");
$partners_exists = false;
} else {
KalturaLog::debug("Looping " . ($start_pos + $bulk_size - 1) . " partners, offset: {$start_pos} .");
foreach ($partners as $partner) {
myPartnerUtils::doPartnerUsage($partner, true);
}
}
unset($partners);
PartnerPeer::clearInstancePool();
$start_pos += $bulk_size;
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:32,代码来源:myBatchPartnerUsage.class.php
示例14: search
/**
* @brief search file
*
* @param query query
* @param limit the maximum number of rows to return
* @param offset the offset of the first row to return
* @param uid user ID
* @return array of item id
*/
function search($query, $limit, $offset, $uid)
{
$msg = false;
$iids = false;
$dummy = false;
$search_cache_id = false;
$_SESSION['XNPSID'] = session_id();
$member_handler =& xoops_gethandler('member');
if (empty($GLOBALS['xoopsUser'])) {
$GLOBALS['xoopsUser'] = $member_handler->getUser($uid);
}
if (xnpSearchExec('quicksearch', $query, 'all', false, $dummy, $dummy, $dummy, $search_cache_id, false, 'file')) {
// search_cache_id -> file_ids
$criteria = new Criteria('search_cache_id', $search_cache_id);
$criteria->setSort('item_id');
$criteria->setStart($offset);
if ($limit) {
$criteria->setLimit($limit);
}
$join = new XooNIpsJoinCriteria('xoonips_search_cache_file', 'file_id', 'file_id', 'LEFT');
$file_handler =& xoonips_getormhandler('xoonips', 'file');
$files =& $file_handler->getObjects($criteria, false, 'item_id', true, $join);
if (false === $files) {
return false;
}
$item_ids = array();
foreach ($files as $file) {
$item_ids[] = $file->get('item_id');
}
return $item_ids;
} else {
return false;
}
}
示例15: reap
public static function reap($set, $try_to_do_multi = true)
{
$items = array();
if (is_array($set)) {
if (count($set) >= sfConfig::get('app_reap_single_clients_min')) {
$items = self::prepareReap($set);
}
}
// test if we should do a multiple client reap
if ($try_to_do_multi) {
// the "3" value is a way to short circuit this
$do_multi = $try_to_do_multi == 3 || time() % sfConfig::get('app_reap_multi_time_mod') == 0;
}
if ($do_multi) {
$criteria = new Criteria();
$criteria->setLimit(sfConfig::get('app_reap_multi_clients_max'));
$criteria->addAscendingOrderByColumn(ClientPeer::UPDATED_AT);
$criteria->add(ClientPeer::UPDATED_AT, time() - sfConfig::get('app_reap_client_age_max'), Criteria::LESS_EQUAL);
// fixme this should be refined more -- perhaps seeds should be even less likely to be reaped etc?
$all = ClientPeer::doSelect($criteria);
$items = array_merge(self::prepareReap($all), $items);
}
if (count($items) > sfConfig::get('app_reap_single_kills_min') || $do_multi) {
if (count($items)) {
self::doDelete($items);
// does do delete actually call the delete method on each?
}
}
// todo: deleted items should be removed from set
return $set;
}