本文整理汇总了PHP中DatabaseBase::selectSQLText方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::selectSQLText方法的具体用法?PHP DatabaseBase::selectSQLText怎么用?PHP DatabaseBase::selectSQLText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::selectSQLText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLatestRevisionsQuery
/**
* @param int $limit limit number of results.
* @param array $namespaces list of namespaces to filter by. No filter applied if null
* @return ResultWrapper
*/
public function getLatestRevisionsQuery($limit, $namespaces)
{
$namespaces = $this->sqlSanitizeArray($namespaces);
$tables = ['recentchanges'];
$joinConditions = [];
$conditions = [];
$options = ['LIMIT' => $limit, 'ORDER BY' => 'rc_id DESC'];
// clear out the bots
$conditions[] = "rc_bot=0";
// filter by namespaces if provided
if ($namespaces != null) {
$conditions[] = "page_namespace in (" . implode(",", $namespaces) . ")";
$tables[] = 'page';
$joinConditions['page'] = ["JOIN", "rc_cur_id=page_id"];
}
$query = $this->databaseConnection->selectSQLText($tables, 'rc_id as id, page_id as pageId, rc_timestamp as timestamp, rc_user as userId', $conditions, __METHOD__, $options, $joinConditions);
$result = $this->databaseConnection->query($query);
return $result;
}
示例2: selectSQLText
/**
* SELECT wrapper
*
* @param mixed $table Array or string, table name(s) (prefix auto-added)
* @param mixed $vars Array or string, field name(s) to be retrieved
* @param mixed $conds Array or string, condition(s) for WHERE
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @param array $options Associative array of options (e.g. array('GROUP BY' => 'page_title')),
* see Database::makeSelectOptions code for list of supported stuff
* @param array $join_conds Associative array of table join conditions (optional)
* (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
* @return string The SQL text
*/
public function selectSQLText($table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array())
{
if (isset($options['EXPLAIN'])) {
unset($options['EXPLAIN']);
}
$sql = parent::selectSQLText($table, $vars, $conds, $fname, $options, $join_conds);
// try to rewrite aggregations of bit columns (currently MAX and MIN)
if (strpos($sql, 'MAX(') !== false || strpos($sql, 'MIN(') !== false) {
$bitColumns = array();
if (is_array($table)) {
foreach ($table as $t) {
$bitColumns += $this->getBitColumns($this->tableName($t));
}
} else {
$bitColumns = $this->getBitColumns($this->tableName($table));
}
foreach ($bitColumns as $col => $info) {
$replace = array("MAX({$col})" => "MAX(CAST({$col} AS tinyint))", "MIN({$col})" => "MIN(CAST({$col} AS tinyint))");
$sql = str_replace(array_keys($replace), array_values($replace), $sql);
}
}
return $sql;
}
示例3: selectSQLText
/**
* Change the FOR UPDATE option as necessary based on the join conditions. Then pass
* to the parent function to get the actual SQL text.
*
* In Postgres when using FOR UPDATE, only the main table and tables that are inner joined
* can be locked. That means tables in an outer join cannot be FOR UPDATE locked. Trying to do
* so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly.
*
* MySQL uses "ORDER BY NULL" as an optimization hint, but that syntax is illegal in PostgreSQL.
* @see DatabaseBase::selectSQLText
*/
function selectSQLText($table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array())
{
if (is_array($options)) {
$forUpdateKey = array_search('FOR UPDATE', $options, true);
if ($forUpdateKey !== false && $join_conds) {
unset($options[$forUpdateKey]);
foreach ($join_conds as $table_cond => $join_cond) {
if (0 === preg_match('/^(?:LEFT|RIGHT|FULL)(?: OUTER)? JOIN$/i', $join_cond[0])) {
$options['FOR UPDATE'][] = $table_cond;
}
}
}
if (isset($options['ORDER BY']) && $options['ORDER BY'] == 'NULL') {
unset($options['ORDER BY']);
}
}
return parent::selectSQLText($table, $vars, $conds, $fname, $options, $join_conds);
}
示例4: selectSQLText
/**
* SELECT wrapper
*
* @param $table Mixed: Array or string, table name(s) (prefix auto-added)
* @param $vars Mixed: Array or string, field name(s) to be retrieved
* @param $conds Mixed: Array or string, condition(s) for WHERE
* @param $fname String: Calling function name (use __METHOD__) for logs/profiling
* @param $options Array: Associative array of options (e.g. array('GROUP BY' => 'page_title')),
* see Database::makeSelectOptions code for list of supported stuff
* @param $join_conds Array: Associative array of table join conditions (optional)
* (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') )
* @return string, the SQL text
*/
function selectSQLText($table, $vars, $conds = '', $fname = 'DatabaseMssql::select', $options = array(), $join_conds = array())
{
if (isset($options['EXPLAIN'])) {
unset($options['EXPLAIN']);
}
return parent::selectSQLText($table, $vars, $conds, $fname, $options, $join_conds);
}