本文整理汇总了PHP中SmartyPaginate::setLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP SmartyPaginate::setLimit方法的具体用法?PHP SmartyPaginate::setLimit怎么用?PHP SmartyPaginate::setLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartyPaginate
的用法示例。
在下文中一共展示了SmartyPaginate::setLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewlist
function viewlist($parameter = null, $layout = true, $model = false)
{
$options = array();
$assigns = array();
$model = $model ? $model : $this->getDefaultModel();
$this->page_title = Inflector::humanize($this->name);
$this->auto_render = false;
$this->base_dir = APP_DIR;
$assigns['TITLE'] = Inflector::humanize($this->name);
if ($model) {
$this->get_search_field($model, $options);
$this->get_viewlist_options($model, $options);
$this->get_sort_options($model, $options);
$this->set_pagination($model);
$model->find($options);
$page_content =& NController::singleton('page_content');
$page_content_model =& $page_content->getDefaultModel();
$pk = $model->primaryKey();
$models = array();
$headline = $model->getHeadline() ? $model->getHeadline() : 'cms_headline';
$i = 0;
while ($model->fetch()) {
$arr = $model->toArray();
$arr['_headline'] = isset($arr['cms_headline']) && $arr['cms_headline'] ? $arr['cms_headline'] : $model->makeHeadline();
$arr['_remove_delete'] = $page_content_model->isWorkflowContent($this->name, $arr[$pk]) ? 1 : 0;
// Remove delete for models that have specified this.
$arr['_remove_delete'] = isset($model->remove_delete) && $model->remove_delete == true ? 1 : 0;
$models[] = $arr;
unset($arr);
}
// Override standard paging limit if chosen in the model file.
$paging = isset($model->paging) ? $model->paging : $this->paging;
// If paging is not disabled in the model AND the records are > than the paging size AND not searching.
if ($paging > 0 && count($models) > $paging && !$options['is_search']) {
SmartyPaginate::connect($this->name);
SmartyPaginate::setLimit($paging, $this->name);
SmartyPaginate::setTotal(count($models), $this->name);
$view =& NView::singleton($this);
SmartyPaginate::assign($view, 'paginate', $this->name);
// TODO: Could be more efficient and only get records it needs to.
$models = array_slice($models, SmartyPaginate::getCurrentIndex($this->name), SmartyPaginate::getLimit($this->name));
$this->set('paging', true);
}
$this->set(array('rows' => $models, 'asset' => $this->name, 'asset_name' => $this->page_title));
unset($models);
}
$this->render(array('layout' => 'default'));
}
示例2: getProjectLog
function getProjectLog($project, $lim = 25)
{
global $conn;
$project = (int) $project;
$lim = (int) $lim;
$sel = $conn->query("SELECT COUNT(*) FROM log WHERE project = {$project} ");
$num = $sel->fetch();
$num = $num[0];
if ($num > 200) {
$num = 200;
}
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$sql = "SELECT * FROM log WHERE project = {$project} ORDER BY ID DESC LIMIT {$start},{$lim}";
$sel2 = $conn->query($sql);
$mylog = array();
while ($log = $sel2->fetch()) {
if (!empty($log)) {
$sel3 = $conn->query("SELECT name FROM projekte WHERE ID = {$log['project']}");
$proname = $sel3->fetch();
$proname = $proname[0];
$log["proname"] = $proname;
$log["proname"] = stripslashes($log["proname"]);
$log["username"] = stripslashes($log["username"]);
$log["name"] = stripslashes($log["name"]);
array_push($mylog, $log);
}
}
if (!empty($mylog)) {
return $mylog;
} else {
return false;
}
}
示例3: getSearchResults
<?php
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(5);
#set url for links
SmartyPaginate::setUrl('./index.php?path=./main/news/tm0.news.display_news.php');
SmartyPaginate::setPrevText('PREV');
SmartyPaginate::setNextText('NEXT');
function getSearchResults(&$dbcon)
{
$X = SmartyPaginate::getCurrentIndex();
$Y = SmartyPaginate::getLimit();
$searchSQL = "SELECT * FROM sionapros_news WHERE 1 ORDER BY news_no DESC LIMIT {$X},{$Y}";
$result = $dbcon->execute($searchSQL);
foreach ($result as $row) {
// collect each record into $_data
$data[] = $row;
}
// now we get the total number of records from the table
$rowsSQL = "SELECT COUNT(*) FROM sionapros_news WHERE 1";
$dbcon->query($rowsSQL);
#$rowNo = $rows[0];
SmartyPaginate::setTotal($dbcon->getValue());
$dbcon->free();
return $data;
}
$results = getSearchResults($db);
if (sizeof($results) == 0) {
$searchMsg = 'NO ARTICLES WERE FOUND';
$smarty->assign('searchMsg', $searchMsg);
示例4: getSearchResults
<?php
#reset session data
SmartyPaginate::reset();
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(10);
#set url for links
SmartyPaginate::setUrl('./index.php?path=./main/faqs/faqs.show_faqs.php');
SmartyPaginate::setPrevText('PREV');
SmartyPaginate::setNextText('NEXT');
function getSearchResults(&$dbcon)
{
$X = SmartyPaginate::getCurrentIndex();
$Y = SmartyPaginate::getLimit();
$searchSQL = "SELECT fq.*,C.value FROM sionapros_faqs AS fq INNER JOIN sionapros_categories";
$searchSQL .= " AS C ON fq.category = C.id ORDER BY C.id,fq.id LIMIT {$X},{$Y}";
$result = $dbcon->execute($searchSQL);
echo $dbcon->error;
foreach ($result as $row) {
// collect each record into $_data
$data[] = $row;
}
// now we get the total number of records from the table
$rowsSQL = "SELECT COUNT(*) FROM sionapros_faqs WHERE 1";
$dbcon->query($rowsSQL);
#$rowNo = $rows[0];
SmartyPaginate::setTotal($dbcon->getValue());
$dbcon->free();
return $data;
示例5: getProjectMembers
/**
* Lists all the users in a project
*
* @param int $project Eindeutige Projektnummer
* @param int $lim Maximum auszugebender Mitglieder
* @return array $members Projektmitglieder
*/
function getProjectMembers($project, $lim = 10, $paginate = true)
{
global $conn;
$project = (int) $project;
$lim = (int) $lim;
$project = (int) $project;
$lim = (int) $lim;
$members = array();
if ($paginate) {
$num = $conn->query("SELECT COUNT(*) FROM projekte_assigned WHERE projekt = {$project}")->fetch();
$num = $num[0];
$lim = (int) $lim;
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
} else {
$start = 0;
}
$sel1 = $conn->query("SELECT user FROM projekte_assigned WHERE projekt = {$project} LIMIT {$start},{$lim}");
$usr = new user();
while ($user = $sel1->fetch()) {
$theuser = $usr->getProfile($user[0]);
array_push($members, $theuser);
}
if (!empty($members)) {
return $members;
} else {
return false;
}
}
示例6: getSearchResults
}
if ($_POST['lname']) {
$searchSpec .= "AND lastname LIKE '%" . $_POST['lname'] . "%' ";
}
#if($_POST['dob']) $searchSpec .= "AND date_of_birth LIKE '%".$_POST['dob']."%' ";
if ($_POST['Search'] || $_GET['l']) {
$_SESSION['search'] = $searchSpec;
}
#check if its a new search
if ($_POST['Search']) {
#reset session data
SmartyPaginate::reset();
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($_POST['results']);
} else {
SmartyPaginate::connect();
}
#set url for links
SmartyPaginate::setUrl('./index.php?path=./main/user/user.show_user.php');
SmartyPaginate::setPrevText('PREV');
SmartyPaginate::setNextText('NEXT');
function getSearchResults(&$dbcon)
{
$X = SmartyPaginate::getCurrentIndex();
$Y = SmartyPaginate::getLimit();
$searchSQL = "SELECT firstname,lastname,identifier FROM sionapros_users";
$searchSQL .= " WHERE 1 {$_SESSION['search']} ORDER BY identifier ASC LIMIT {$X},{$Y}";
$result = $dbcon->execute($searchSQL);
foreach ($result as $row) {
示例7: getProjectFiles
/**
* List all files associated to a given project
*
* @param string $id Project ID
* @param int $lim Limit
* @param int $folder Folder
* @return array $files Found files
*/
function getProjectFiles($id, $lim = 5000, $folder = "")
{
global $conn;
$id = (int) $id;
$lim = (int) $lim;
$folder = (int) $folder;
// If folder is given, return files from this folder, otherwise return files from root folder
if ($folder > 0) {
$fold = "files/" . CL_CONFIG . "/{$id}/{$folder}/";
$sel = $conn->query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC");
} else {
$sel = $conn->query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC");
}
$num = $sel->fetch();
$num = $num[0];
// Set items per page
SmartyPaginate::connect();
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$files = array();
if ($folder > 0) {
$sql = "SELECT ID FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC LIMIT {$start},{$lim}";
$sel2 = $conn->query($sql);
} else {
$sel2 = $conn->query("SELECT ID FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC LIMIT {$start},{$lim}");
}
while ($file = $sel2->fetch()) {
if (!empty($file)) {
array_push($files, $this->getFile($file["ID"]));
}
}
if (!empty($files)) {
return $files;
} else {
return false;
}
}
示例8: getAllUsers
/**
* Returns all users
*
* @param int $lim Limit
* @return array $users Registrierte Mitglieder
*/
function getAllUsers($lim = 10)
{
global $conn;
$lim = (int) $lim;
$num = $conn->query("SELECT COUNT(*) FROM `user`")->fetch();
$num = $num[0];
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$sel2 = $conn->query("SELECT ID FROM `user` ORDER BY ID DESC LIMIT {$start},{$lim}");
$users = array();
while ($user = $sel2->fetch()) {
array_push($users, $this->getProfile($user["ID"]));
}
if (!empty($users)) {
return $users;
} else {
return false;
}
}
示例9: getSearchResults
}
if ($_POST['title']) {
$searchSpec .= "AND p.title LIKE '%" . $_POST['title'] . "%' ";
}
#store where clause in the session
if ($_REQUEST['Search']) {
$_SESSION['search'] = $searchSpec;
}
#check if its a new search
if ($_REQUEST['Search']) {
#reset session data
SmartyPaginate::reset();
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($_REQUEST['results']);
} else {
SmartyPaginate::connect();
}
#set url for links
SmartyPaginate::setUrl('./index.php?path=./main/pubs/pubs.show_pubs.php');
SmartyPaginate::setPrevText('PREV');
SmartyPaginate::setNextText('NEXT');
function getSearchResults(&$dbcon, $proj_no)
{
$X = SmartyPaginate::getCurrentIndex();
$Y = SmartyPaginate::getLimit();
$searchSQL = "SELECT p.*,c.value FROM sionapros_pubs AS p INNER JOIN sionapros_categories AS c";
$searchSQL .= " ON p.category = c.id WHERE 1 {$_SESSION['search']} ORDER BY id DESC LIMIT {$X},{$Y}";
$result = $dbcon->execute($searchSQL);
foreach ($result as $row) {
示例10: getProjectTrack
function getProjectTrack($project, $user = 0, $task = 0, $start = 0, $end = 0, $lim = 50)
{
global $conn;
$project = (int) $project;
$user = (int) $user;
$lim = (int) $lim;
// make sure task is an array - this needs to be refactored
if (!is_array($task)) {
$task = array($task);
}
// make sure all the fields are ints
for ($index = 0; $index < count($task); $index++) {
$task[$index] = (int) $task[$index];
}
$task = join(',', $task);
// $start = (int) $start; // those are strings, not numbers
// $end = (int) $end; // those are strings, not numbers
if ($user > 0) {
$sql = "SELECT * FROM timetracker WHERE project = {$project} AND user = {$user}";
$num = "SELECT COUNT(*) FROM timetracker WHERE project = {$project} AND user = {$user}";
$order = " ORDER BY ended ASC";
} else {
$sql = "SELECT * FROM timetracker WHERE project = {$project}";
$num = "SELECT COUNT(*) FROM timetracker WHERE project = {$project}";
$order = " ORDER BY ended ASC";
}
if ($task > 0) {
$sql .= " AND task in ({$task})";
$num .= " AND task in ({$task})";
}
if ($start > 0 and $end > 0) {
$start = strtotime($start);
$end = strtotime($end . " +1 day");
$end = $end - 1;
$sql .= " AND ended >={$start} AND ended<={$end} ";
$num .= " AND ended >={$start} AND ended<={$end} ";
}
if ($num) {
$num = $conn->query($num)->fetch();
$num = $num[0];
} else {
$num = 0;
}
$sql = $sql . $order;
// needs to be refactored
if ($lim > 0) {
SmartyPaginate::connect();
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$limi = " LIMIT {$start},{$lim} ";
$sql = $sql . $limi;
}
$sel = $conn->query($sql);
$track = array();
$ttask = new task();
if (isset($sel)) {
while ($data = @$sel->fetch()) {
$endstring = date("H:i", $data["ended"]);
$startstring = date("H:i", $data["started"]);
$daystring = date(CL_DATEFORMAT, $data["ended"]);
$tasks = $ttask->getTask($data["task"]);
if (!empty($tasks)) {
$tasks = $tasks["title"];
$data["tname"] = $tasks;
}
$pname = $conn->query("SELECT name FROM projekte WHERE ID = {$data['project']}")->fetch();
$pname = stripslashes($pname[0]);
$uname = $conn->query("SELECT name FROM user WHERE ID = {$data['user']}")->fetch();
$uname = stripslashes($uname[0]);
$data["endstring"] = $endstring;
$data["startstring"] = $startstring;
$data["daystring"] = $daystring;
$data["uname"] = $uname;
$data["pname"] = $pname;
$data["comment"] = stripslashes($data["comment"]);
$data["comment"] = nl2br($data["comment"]);
array_push($track, $data);
}
}
if (!empty($track)) {
return $track;
} else {
return false;
}
}
示例11: getAllUsers
/**
* Returns all users
*
* @param int $lim Limit
* @return array $users Registrierte Mitglieder
*/
function getAllUsers($lim = 10)
{
$lim = (int) $lim;
$sel = mysql_query("SELECT COUNT(*) FROM `user`");
$num = mysql_fetch_row($sel);
$num = $num[0];
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$sel2 = mysql_query("SELECT * FROM `user` ORDER BY ID DESC LIMIT {$start},{$lim}");
$users = array();
while ($user = mysql_fetch_array($sel2)) {
$user["name"] = stripslashes($user["name"]);
$user["company"] = stripslashes($user["company"]);
$user["adress"] = stripslashes($user["adress"]);
$user["adress2"] = stripslashes($user["adress2"]);
$user["state"] = stripslashes($user["state"]);
$user["country"] = stripslashes($user["country"]);
array_push($users, $user);
}
if (!empty($users)) {
return $users;
} else {
return false;
}
}
示例12: getProjectFiles
/**
* List all files associated to a given project
*
* @param string $id Project ID
* @param int $lim Limit
* @param int $folder Folder
* @return array $files Found files
*/
function getProjectFiles($id, $lim = 25, $folder = "")
{
$id = (int) $id;
$lim = (int) $lim;
$folder = (int) $folder;
if ($folder > 0) {
$fold = "files/" . CL_CONFIG . "/{$id}/{$folder}/";
$sel = mysql_query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC");
} else {
$sel = mysql_query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC");
}
$num = mysql_fetch_row($sel);
$num = $num[0];
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$files = array();
if ($folder > 0) {
$sql = "SELECT ID FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC LIMIT {$start},{$lim}";
$sel2 = mysql_query($sql);
} else {
$sel2 = mysql_query("SELECT ID FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC LIMIT {$start},{$lim}");
}
while ($file = mysql_fetch_array($sel2)) {
if (!empty($file)) {
array_push($files, $this->getFile($file["ID"]));
}
}
if (!empty($files)) {
return $files;
} else {
return false;
}
}
示例13: Functions
$obj = new Functions();
$deleted = R::exec("delete from tip where id=" . $id);
$obj->insertAuditTrail($_SESSION['login'], 'DELETE_TIP', 'Health tip deleted');
if ($deleted) {
$info = "Item Deleted!";
}
}
$smarty = new Smarty();
/*$smarty ->template_dir = './templates';
$smarty ->compile_dir = './templates_c';
$smarty ->cache_dir = './cache';
$smarty ->config_dir = '.configs'; */
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(200);
//$smarty->assign('tips', $tips);
$link = mysql_connect('197.253.10.27:3306', 'm_health', 'm_health') or die("Impossible to connect");
mysql_select_db('mhealth') or die("Could not select database");
// assign {$paginate} var
// display results
//$smarty->display('tips_user.tpl');
/*function get_db_results() {
//$tips = range(1,count($tips));
return array_slice($tips, SmartyPaginate::getCurrentIndex(),
SmartyPaginate::getLimit());
} */
$categorys = R::getAll("select id, name from category");
if (isset($_REQUEST['submit'])) {
$c = urldecode($_REQUEST['category']);
示例14: htmlspecialchars
if (strlen($filter_ip)) {
$filter .= '&filter_ip=' . htmlspecialchars($filter_ip, ENT_QUOTES, 'cp1251');
}
if (strlen($filter_hwid)) {
$filter .= '&filter_hwid=' . htmlspecialchars($filter_hwid, ENT_QUOTES, 'cp1251');
}
if (strlen($filter_nonparsed)) {
$filter .= '&filter_nonparsed=' . htmlspecialchars($filter_nonparsed, ENT_QUOTES, 'cp1251');
} elseif (strlen($filter_has_passwords)) {
$filter .= '&filter_has_passwords=' . htmlspecialchars($filter_has_passwords, ENT_QUOTES, 'cp1251');
}
SmartyPaginate::disconnect();
SmartyPaginate::connect();
SmartyPaginate::setURL($self_file . "?token=" . $token . "&action=reports" . $filter);
SmartyPaginate::setTotal($total_items_count);
SmartyPaginate::setLimit($max_results);
SmartyPaginate::setPageLimit(50);
SmartyPaginate::setPrevText($lang['Previous']);
SmartyPaginate::setNextText($lang['Next']);
SmartyPaginate::assign($smarty);
smarty_assign_common_vars($smarty, $pony_db);
$smarty->assign("report_list", $report_list);
$smarty->display('report_list.tpl');
}
} else {
if ($admin_action == 'admin') {
// ---------------------------------------------------------------------------------------
// User management
if ($admin_routine == 'rebuild_tables') {
if ($pony_db->priv_is_admin()) {
if ($pony_db->drop_table(CPONY_FTP_TABLE) && $pony_db->drop_table(CPONY_REPORT_TABLE) && $pony_db->drop_table(CPONY_REPORT_DATA_TABLE) && $pony_db->drop_table(CPONY_LOG_TABLE) && $pony_db->drop_table(CPONY_CERT_TABLE) && $pony_db->drop_table(CPONY_WALLET_TABLE) && $pony_db->drop_table(CPONY_EMAIL_TABLE) && $pony_db->drop_table(CPONY_DOMAINLIST_TABLE) && $pony_db->create_data_tables() && $pony_db->state) {
示例15: getProjectTrack
function getProjectTrack($project, $user = 0, $task = 0, $start = 0, $end = 0, $lim = 50)
{
$start = mysql_real_escape_string($start);
$end = mysql_real_escape_string($end);
$project = (int) $project;
$user = (int) $user;
$lim = (int) $lim;
if ($user > 0)
{
$sql = "SELECT * FROM timetracker WHERE project = $project AND user = $user";
$num = "SELECT COUNT(*) FROM timetracker WHERE project = $project AND user = $user";
$order = " ORDER BY ended ASC";
}
else
{
$sql = "SELECT * FROM timetracker WHERE project = $project";
$num = "SELECT COUNT(*) FROM timetracker WHERE project = $project";
$order = " ORDER BY ended ASC";
}
if ($task > 0)
{
$sql .= " AND task = $task";
$num .= " AND task = $task";
}
if ($start > 0 and $end > 0)
{
$start = strtotime($start);
$end = strtotime($end . " +1 day");
$end = $end - 1;
$sql .= " AND ended >=$start AND ended<=$end ";
$num .= " AND ended >=$start AND ended<=$end ";
}
if ($num)
{
$num = mysql_fetch_row(mysql_query($num));
$num = $num[0];
}
else
{
$num = 0;
}
$sql = $sql . $order;
SmartyPaginate::connect();
SmartyPaginate::setLimit($lim);
SmartyPaginate::setTotal($num);
$start = SmartyPaginate::getCurrentIndex();
$lim = SmartyPaginate::getLimit();
$limi = " LIMIT $start,$lim ";
$sql = $sql . $limi;
$sel = mysql_query($sql);
$track = array();
$ttask = new task();
if (isset($sel))
{
while ($data = @mysql_fetch_array($sel))
{
$endstring = date("H:i", $data["ended"]);
$startstring = date("H:i", $data["started"]);
$daystring = date("d.m.y", $data["ended"]);
$tasks = $ttask->getTask($data["task"]);
if (!empty($tasks))
{
$tasks = $tasks["title"];
$data["tname"] = $tasks;
}
$pname = mysql_query("SELECT name FROM projekte WHERE ID = $data[project]");
$pname = mysql_fetch_row($pname);
$pname = stripslashes($pname[0]);
$uname = mysql_query("SELECT name FROM user WHERE ID = $data[user]");
$uname = mysql_fetch_row($uname);
$uname = stripslashes($uname[0]);
$data["endstring"] = $endstring;
$data["startstring"] = $startstring;
$data["daystring"] = $daystring;
$data["uname"] = $uname;
$data["pname"] = $pname;
$data["comment"] = stripslashes($data["comment"]);
$data["comment"] = nl2br($data["comment"]);
array_push($track, $data);
}
}
if (!empty($track))
{
return $track;
}
//.........这里部分代码省略.........