本文整理汇总了PHP中jqgrid::constructWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP jqgrid::constructWhere方法的具体用法?PHP jqgrid::constructWhere怎么用?PHP jqgrid::constructWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jqgrid
的用法示例。
在下文中一共展示了jqgrid::constructWhere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: schedulegrid
public function schedulegrid()
{
$page = $this->get->page;
// get the requested page
$limit = $this->get->rows;
// get how many rows we want to have into the grid
$sidx = $this->get->sidx;
// get index row - i.e. user click to sort
$sord = $this->get->sord;
// get the direction
if (!$sidx) {
$sidx = 1;
}
# http://dev.phpvms.net/admin/action.php/operations/
# ?_search=true&nd=1270940867171&rows=20&page=1&sidx=flightnum&sord=asc&searchField=code&searchString=TAY&searchOper=eq
/* Do the search using jqGrid */
$where = array();
if ($this->get->_search == 'true') {
$searchstr = jqgrid::strip($this->get->filters);
$where_string = jqgrid::constructWhere($searchstr);
# Append to our search, add 1=1 since it comes with AND
# from above
$where[] = "1=1 {$where_string}";
}
Config::Set('SCHEDULES_ORDER_BY', "{$sidx} {$sord}");
# Do a search without the limits so we can find how many records
$count = SchedulesData::countSchedules($where);
if ($count > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) {
$page = $total_pages;
}
$start = $limit * $page - $limit;
// do not put $limit*($page - 1)
if ($start < 0) {
$start = 0;
}
# And finally do a search with the limits
$schedules = SchedulesData::findSchedules($where, $limit, $start);
if (!$schedules) {
$schedules = array();
}
# Form the json header
$json = array('page' => $page, 'total' => $total_pages, 'records' => $count, 'rows' => array());
# Add each row to the above array
foreach ($schedules as $row) {
if ($row->route != '') {
$route = '<a href="#" onclick="showroute(\'' . $row->id . '\'); return false;">View</a>';
} else {
$route = '-';
}
$edit = '<a href="' . adminurl('/operations/editschedule?id=' . $row->id) . '">Edit</a>';
$delete = '<a href="#" onclick="deleteschedule(' . $row->id . '); return false;">Delete</a>';
$tmp = array('id' => $row->id, 'cell' => array($row->code, $row->flightnum, $row->depicao, $row->arricao, $row->aircraft, $row->registration, $route, Util::GetDaysCompact($row->daysofweek), $row->distance, $row->timesflown, $edit, $delete));
$json['rows'][] = $tmp;
}
header("Content-type: text/x-json");
echo json_encode($json);
}
示例2: getpilotsjson
public function getpilotsjson()
{
$page = $this->get->page;
// get the requested page
$limit = $this->get->rows;
// get how many rows we want to have into the grid
$sidx = $this->get->sidx;
// get index row - i.e. user click to sort
$sord = $this->get->sord;
// get the direction
if (!$sidx) {
$sidx = 1;
}
/* Do the search using jqGrid */
$where = array();
if ($this->get->_search == 'true') {
$searchstr = jqgrid::strip($this->get->filters);
$where_string = jqgrid::constructWhere($searchstr);
# Append to our search, add 1=1 since it comes with AND
# from above
$where[] = "1=1 {$where_string}";
}
Config::Set('PILOT_ORDER_BY', "{$sidx} {$sord}");
# Do a search without the limits so we can find how many records
$count = count(PilotData::findPilots($where));
if ($count > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) {
$page = $total_pages;
}
$start = $limit * $page - $limit;
// do not put $limit*($page - 1)
if ($start < 0) {
$start = 0;
}
# And finally do a search with the limits
$allpilots = PilotData::findPilots($where, $limit, $start);
if (!$allpilots) {
$allpilots = array();
}
# Form the json header
$json = array('page' => $page, 'total' => $total_pages, 'records' => $count, 'rows' => array());
# Add each row to the above array
foreach ($allpilots as $row) {
$pilotid = PilotData::getPilotCode($row->code, $row->pilotid);
$status = $row->retired == 0 ? 'Active' : 'Retired';
$location = '<img src="' . Countries::getCountryImage($row->location) . '" alt="' . $row->location . '" />';
$edit = '<a href="' . adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid=' . $row->pilotid) . '">Edit</a>';
$tmp = array('id' => $row->id, 'cell' => array($row->id, $pilotid, $row->firstname, $row->lastname, $row->email, $location, $status, $row->rank, $row->totalflights, $row->totalhours, $row->lastip, $edit));
$json['rows'][] = $tmp;
}
header("Content-type: text/x-json");
echo json_encode($json);
}