本文整理汇总了PHP中PDOConnect::setTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOConnect::setTimeZone方法的具体用法?PHP PDOConnect::setTimeZone怎么用?PHP PDOConnect::setTimeZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOConnect
的用法示例。
在下文中一共展示了PDOConnect::setTimeZone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DataSetResults
/**
* Data Set Results
* @param <type> $dataSetId
* @param <type> $columnIds
* @param <type> $filter
* @param <type> $ordering
* @param <type> $lowerLimit
* @param <type> $upperLimit
* @return <type>
*/
public function DataSetResults($dataSetId, $columnIds, $filter = '', $ordering = '', $lowerLimit = 0, $upperLimit = 0, $displayId = 0)
{
$blackList = array(';', 'INSERT', 'UPDATE', 'SELECT', 'DELETE', 'TRUNCATE', 'TABLE', 'FROM', 'WHERE');
try {
$dbh = PDOConnect::init();
PDOConnect::setTimeZone($dbh, date('P'));
$params = array('dataSetId' => $dataSetId);
$selectSQL = '';
$outserSelect = '';
$finalSelect = '';
$results = array();
$headings = array();
$allowedOrderCols = array();
$filter = str_replace($blackList, '', $filter);
$filter = str_replace('[DisplayId]', $displayId, $filter);
$columns = explode(',', $columnIds);
// Get the Latitude and Longitude ( might be used in a formula )
if ($displayId == 0) {
$defaultLat = Config::GetSetting('DEFAULT_LAT');
$defaultLong = Config::GetSetting('DEFAULT_LONG');
$displayGeoLocation = "GEOMFROMTEXT('POINT(" . $defaultLat . " " . $defaultLong . ")')";
} else {
$displayGeoLocation = sprintf("(SELECT GeoLocation FROM `display` WHERE DisplayID = %d)", $displayId);
}
// Get all columns for the cross tab
$sth = $dbh->prepare('SELECT DataSetColumnID, Heading, DataSetColumnTypeID, Formula, DataTypeID FROM datasetcolumn WHERE DataSetID = :dataSetId');
$sth->execute(array('dataSetId' => $dataSetId));
$allColumns = $sth->fetchAll();
foreach ($allColumns as $col) {
$heading = $col;
$heading['Text'] = $heading['Heading'];
$allowedOrderCols[] = $heading['Heading'];
$formula = str_replace($blackList, '', htmlspecialchars_decode($col['Formula'], ENT_QUOTES));
// Is this column a formula column or a value column?
if ($col['DataSetColumnTypeID'] == 2) {
// Formula
$formula = str_replace('[DisplayGeoLocation]', $displayGeoLocation, $formula);
$formula = str_replace('[DisplayId]', $displayId, $formula);
$heading['Heading'] = $formula . ' AS \'' . $heading['Heading'] . '\'';
} else {
// Value
$selectSQL .= sprintf("MAX(CASE WHEN DataSetColumnID = %d THEN `Value` ELSE null END) AS '%s', ", $col['DataSetColumnID'], $heading['Heading']);
}
$headings[] = $heading;
}
// Build our select statement including formulas
foreach ($headings as $heading) {
if ($heading['DataSetColumnTypeID'] == 2) {
// This is a formula, so the heading has been morphed into some SQL to run
$outserSelect .= ' ' . $heading['Heading'] . ',';
} else {
$outserSelect .= sprintf(' `%s`,', $heading['Heading']);
}
}
$outserSelect = rtrim($outserSelect, ',');
// For each heading, put it in the correct order (according to $columns)
foreach ($columns as $visibleColumn) {
foreach ($headings as $heading) {
if ($heading['DataSetColumnID'] == $visibleColumn) {
$finalSelect .= sprintf(' `%s`,', $heading['Text']);
$results['Columns'][] = $heading;
}
}
}
$finalSelect = rtrim($finalSelect, ',');
// We are ready to build the select and from part of the SQL
$SQL = "SELECT {$finalSelect} ";
$SQL .= " FROM ( ";
$SQL .= " SELECT {$outserSelect} ,";
$SQL .= " RowNumber ";
$SQL .= " FROM ( ";
$SQL .= " SELECT {$selectSQL} ";
$SQL .= " RowNumber ";
$SQL .= " FROM (";
$SQL .= " SELECT datasetcolumn.DataSetColumnID, datasetdata.RowNumber, datasetdata.`Value` ";
$SQL .= " FROM datasetdata ";
$SQL .= " INNER JOIN datasetcolumn ";
$SQL .= " ON datasetcolumn.DataSetColumnID = datasetdata.DataSetColumnID ";
$SQL .= " WHERE datasetcolumn.DataSetID = :dataSetId ";
$SQL .= " ) datasetdatainner ";
$SQL .= " GROUP BY RowNumber ";
$SQL .= " ) datasetdata ";
if ($filter != '') {
$SQL .= ' WHERE ' . $filter;
}
$SQL .= ' ) finalselect ';
if ($ordering != '') {
$order = ' ORDER BY ';
$ordering = explode(',', $ordering);
foreach ($ordering as $orderPair) {
//.........这里部分代码省略.........