本文整理汇总了PHP中TYPO3\CMS\Core\Database\DatabaseConnection::exec_SELECT_queryArray方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::exec_SELECT_queryArray方法的具体用法?PHP DatabaseConnection::exec_SELECT_queryArray怎么用?PHP DatabaseConnection::exec_SELECT_queryArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Database\DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::exec_SELECT_queryArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collectItemsForColumn
/**
* Collects tt_content data from a single tt_content element
*
* @param PageLayoutView $parentObject : The paren object that triggered this hook
* @param int $colPos : The column position to collect the items for
* @param array $row : The current data row for the container item
* @param string $showHidden : query String containing enable fields
* @param string $deleteClause : query String to check for deleted items
*
* @return array collected items for the given column
*/
public function collectItemsForColumn(PageLayoutView $parentObject, &$colPos, &$row, &$showHidden, &$deleteClause)
{
// Due to the pid being "NOT USED" in makeQueryArray we have to set pidSelect here
$originalPidSelect = $parentObject->pidSelect;
$specificIds = $this->helper->getSpecificIds($row);
$parentObject->pidSelect = 'pid = ' . $row['pid'];
if (!$parentObject->tt_contentConfig['languageMode']) {
$showLanguage = ' AND (sys_language_uid = -1 OR sys_language_uid=' . $parentObject->tt_contentConfig['sys_language_uid'] . ')';
} else {
if ($row['sys_language_uid'] > 0) {
$showLanguage = ' AND sys_language_uid = ' . $row['sys_language_uid'];
} else {
$showLanguage = '';
}
}
$where = '';
if ($this->helper->getBackendUser()->workspace > 0 && $row['t3ver_wsid'] > 0) {
$where .= 'AND t3ver_wsid = ' . $row['t3ver_wsid'];
}
$where .= ' AND colPos = -1 AND tx_gridelements_container IN (' . $row['uid'] . ',' . $specificIds['uid'] . ') AND tx_gridelements_columns = ' . $colPos . $showHidden . $deleteClause . $showLanguage;
$queryParts = $parentObject->makeQueryArray('tt_content', $row['pid'], $where);
// Due to the pid being "NOT USED" in makeQueryArray we have to reset pidSelect here
$parentObject->pidSelect = $originalPidSelect;
$result = $this->databaseConnection->exec_SELECT_queryArray($queryParts);
return $parentObject->getResult($result);
}
示例2: pi_exec_query
/**
* Executes a standard SELECT query for listing of records based on standard input vars from the 'browser' ($this->internal['results_at_a_time'] and $this->piVars['pointer']) and 'searchbox' ($this->piVars['sword'] and $this->internal['searchFieldList'])
* Set $count to 1 if you wish to get a count(*) query for selecting the number of results.
* Notice that the query will use $this->conf['pidList'] and $this->conf['recursive'] to generate a PID list within which to search for records.
*
* @param string $table The table name to make the query for.
* @param bool $count If set, you will get a "count(*)" query back instead of field selecting
* @param string $addWhere Additional WHERE clauses (should be starting with " AND ....")
* @param mixed $mm_cat If an array, then it must contain the keys "table", "mmtable" and (optionally) "catUidList" defining a table to make a MM-relation to in the query (based on fields uid_local and uid_foreign). If not array, the query will be a plain query looking up data in only one table.
* @param string $groupBy If set, this is added as a " GROUP BY ...." part of the query.
* @param string $orderBy If set, this is added as a " ORDER BY ...." part of the query. The default is that an ORDER BY clause is made based on $this->internal['orderBy'] and $this->internal['descFlag'] where the orderBy field must be found in $this->internal['orderByList']
* @param string $query If set, this is taken as the first part of the query instead of what is created internally. Basically this should be a query starting with "FROM [table] WHERE ... AND ...". The $addWhere clauses and all the other stuff is still added. Only the tables and PID selecting clauses are bypassed. May be deprecated in the future!
* @return bool|\mysqli_result|object SQL result pointer
*/
public function pi_exec_query($table, $count = FALSE, $addWhere = '', $mm_cat = '', $groupBy = '', $orderBy = '', $query = '')
{
// Begin Query:
if (!$query) {
// Fetches the list of PIDs to select from.
// TypoScript property .pidList is a comma list of pids. If blank, current page id is used.
// TypoScript property .recursive is a int+ which determines how many levels down from the pids in the pid-list subpages should be included in the select.
$pidList = $this->pi_getPidList($this->conf['pidList'], $this->conf['recursive']);
if (is_array($mm_cat)) {
// This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT
// selected, if they should not! Almost ALWAYS add this to your queries!
$query = 'FROM ' . $table . ',' . $mm_cat['table'] . ',' . $mm_cat['mmtable'] . LF . ' WHERE ' . $table . '.uid=' . $mm_cat['mmtable'] . '.uid_local AND ' . $mm_cat['table'] . '.uid=' . $mm_cat['mmtable'] . '.uid_foreign ' . LF . (strcmp($mm_cat['catUidList'], '') ? ' AND ' . $mm_cat['table'] . '.uid IN (' . $mm_cat['catUidList'] . ')' : '') . LF . ' AND ' . $table . '.pid IN (' . $pidList . ')' . LF . $this->cObj->enableFields($table) . LF;
} else {
// This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT
// selected, if they should not! Almost ALWAYS add this to your queries!
$query = 'FROM ' . $table . ' WHERE pid IN (' . $pidList . ')' . LF . $this->cObj->enableFields($table) . LF;
}
}
// Split the "FROM ... WHERE" string so we get the WHERE part and TABLE names separated...:
list($TABLENAMES, $WHERE) = preg_split('/WHERE/i', trim($query), 2);
$TABLENAMES = trim(substr(trim($TABLENAMES), 5));
$WHERE = trim($WHERE);
// Add '$addWhere'
if ($addWhere) {
$WHERE .= ' ' . $addWhere . LF;
}
// Search word:
if ($this->piVars['sword'] && $this->internal['searchFieldList']) {
$WHERE .= $this->cObj->searchWhere($this->piVars['sword'], $this->internal['searchFieldList'], $table) . LF;
}
if ($count) {
$queryParts = array('SELECT' => 'count(*)', 'FROM' => $TABLENAMES, 'WHERE' => $WHERE, 'GROUPBY' => '', 'ORDERBY' => '', 'LIMIT' => '');
} else {
// Order by data:
if (!$orderBy && $this->internal['orderBy']) {
if (GeneralUtility::inList($this->internal['orderByList'], $this->internal['orderBy'])) {
$orderBy = 'ORDER BY ' . $table . '.' . $this->internal['orderBy'] . ($this->internal['descFlag'] ? ' DESC' : '');
}
}
// Limit data:
$pointer = (int) $this->piVars['pointer'];
$results_at_a_time = MathUtility::forceIntegerInRange($this->internal['results_at_a_time'], 1, 1000);
$LIMIT = $pointer * $results_at_a_time . ',' . $results_at_a_time;
// Add 'SELECT'
$queryParts = array('SELECT' => $this->pi_prependFieldsWithTable($table, $this->pi_listFields), 'FROM' => $TABLENAMES, 'WHERE' => $WHERE, 'GROUPBY' => $this->databaseConnection->stripGroupBy($groupBy), 'ORDERBY' => $this->databaseConnection->stripOrderBy($orderBy), 'LIMIT' => $LIMIT);
}
return $this->databaseConnection->exec_SELECT_queryArray($queryParts);
}
示例3: elseif
/**
* Creates and executes a SELECT query for records from $table and with conditions based on the configuration in the $conf array
* Implements the "select" function in TypoScript
* @param $table
* @param $conf
* @return resource
*/
function exec_getQuery($table, $conf)
{
$error = 0;
// Construct WHERE clause:
if (!$this->conf['dontUsePidList']) {
if (!strcmp($conf['pidInList'], '')) {
$conf['pidInList'] = 'this';
}
}
$queryParts = $this->getWhere($table, $conf, TRUE);
// Fields:
$queryParts['SELECT'] = $conf['selectFields'] ? $conf['selectFields'] : '*';
// Setting LIMIT:
if ($conf['max'] || $conf['begin']) {
if (!$error) {
$conf['begin'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(ceil($this->cObj->calc($conf['begin'])), 0);
if ($conf['begin'] && !$conf['max']) {
$conf['max'] = 100000;
}
if ($conf['begin'] && $conf['max']) {
$queryParts['LIMIT'] = $conf['begin'] . ',' . $conf['max'];
} elseif (!$conf['begin'] && $conf['max']) {
$queryParts['LIMIT'] = $conf['max'];
}
}
}
if (!$error) {
// Setting up tablejoins:
$joinPart = '';
if ($conf['join']) {
$joinPart = 'JOIN ' . trim($conf['join']);
} elseif ($conf['leftjoin']) {
$joinPart = 'LEFT OUTER JOIN ' . trim($conf['leftjoin']);
} elseif ($conf['rightjoin']) {
$joinPart = 'RIGHT OUTER JOIN ' . trim($conf['rightjoin']);
}
// Compile and return query:
$queryParts['FROM'] = trim(($this->addFromTable ? $this->addFromTable . ',' : '') . $table . ' ' . $joinPart);
return $this->db->exec_SELECT_queryArray($queryParts);
} else {
return false;
}
}