本文整理汇总了PHP中DatabaseBase::makeList方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::makeList方法的具体用法?PHP DatabaseBase::makeList怎么用?PHP DatabaseBase::makeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::makeList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateRevision
public function updateRevision(DatabaseBase $dbw, $continue = null)
{
$rows = $dbw->select('flow_revision', array('rev_id', 'rev_user_id', 'rev_user_text', 'rev_mod_user_id', 'rev_mod_user_text', 'rev_edit_user_id', 'rev_edit_user_text'), array('rev_id > ' . $dbw->addQuotes($continue), $dbw->makeList(array('rev_user_id' => 0, 'rev_mod_user_id' => 0, 'rev_edit_user_id' => 0), LIST_OR)), __METHOD__, array('LIMIT' => $this->mBatchSize, 'ORDER BY' => 'rev_id'));
$continue = null;
foreach ($rows as $row) {
$continue = $row->rev_id;
$updates = array();
if ($row->rev_user_id == 0) {
$updates['rev_user_ip'] = $row->rev_user_text;
}
if ($row->rev_mod_user_id == 0) {
$updates['rev_mod_user_ip'] = $row->rev_mod_user_text;
}
if ($row->rev_edit_user_id == 0) {
$updates['rev_edit_user_ip'] = $row->rev_edit_user_text;
}
if ($updates) {
$dbw->update('flow_revision', $updates, array('rev_id' => $row->rev_id), __METHOD__);
}
}
return $continue;
}
示例2: getWamIndexConditions
/**
* @param Array $options
* @param DatabaseBase $db
* @return array
*/
protected function getWamIndexConditions($options, $db)
{
$conds = array('fw1.time_id = FROM_UNIXTIME(' . $options['currentTimestamp'] . ')');
if ($options['wikiId']) {
$conds['fw1.wiki_id'] = $options['wikiId'];
}
if (!is_null($options['wikiWord'])) {
$conds[] = "dw.url like '%" . $db->strencode($options['wikiWord']) . "%' " . "OR dw.title like '%" . $db->strencode($options['wikiWord']) . "%'";
}
if ($options['verticalId']) {
$verticals = $options['verticalId'];
} else {
$verticals = $this->verticalIds;
}
$conds['fw1.vertical_id'] = $verticals;
if (!is_null($options['wikiLang'])) {
$conds['dw.lang'] = $db->strencode($options['wikiLang']);
}
if (!empty($options['excludeBlacklist']) || !empty($options['excludeNonCommercial'])) {
$bannedIds = !empty($options['excludeBlacklist']) ? $this->getIdsBlacklistedWikis() : [];
$nonCommercialIds = !empty($options['excludeNonCommercial']) ? $this->getNonCommercialWikis() : [];
$blacklistIds = array_merge($bannedIds, $nonCommercialIds);
if (!empty($blacklistIds)) {
$conds[] = 'fw1.wiki_id NOT IN (' . $db->makeList($blacklistIds) . ')';
}
}
return $conds;
}
示例3: writePropertyTableRowUpdates
/**
* Update one property table by inserting or deleting rows, and compute
* the changes that this entails for the property usage counts. The
* given rows are inserted into the table if $insert is true; otherwise
* they are deleted. The property usage counts are recorded in the
* call-by-ref parameter $propertyUseIncrements.
*
* The method assumes that all of the given rows are about the same
* subject. This is ensured by callers.
*
* @since 1.8
* @param array $propertyUseIncrements
* @param SMWSQLStore3Table $propertyTable
* @param array $rows array of rows to insert/delete
* @param boolean $insert
* @param DatabaseBase $dbw used for writing
*/
protected function writePropertyTableRowUpdates(array &$propertyUseIncrements, SMWSQLStore3Table $propertyTable, array $rows, $insert, DatabaseBase $dbw)
{
if (empty($rows)) {
//print "Nothing to " . ( $insert ? 'insert' : 'delete' ) . " for table {$propertyTable->getName()}.\n"; //DEBUG
return;
}
//print ( $insert ? 'Inserting ' : 'Deleting ' ) . count( $rows ) . " row(s) in table {$propertyTable->getName()}.\n"; //DEBUG
//print var_export( $rows, true ) . "\n"; //DEBUG
if (!$propertyTable->usesIdSubject()) {
// does not occur, but let's be strict
throw new InvalidArgumentException('Operation not supported for tables without subject IDs.');
}
if ($insert) {
$dbw->insert($propertyTable->getName(), array_values($rows), "SMW::writePropertyTableRowUpdates-insert-{$propertyTable->getName()}");
} else {
$condition = '';
// We build a condition that mentions s_id only once,
// since it must be the same for all rows. This should
// help the DBMS in selecting the rows (it would not be
// easy for to detect that all tuples share one s_id).
$sid = false;
foreach ($rows as $row) {
if ($sid === false) {
$sid = $row['s_id'];
// 's_id' exists for all tables with $propertyTable->usesIdSubject()
}
unset($row['s_id']);
if ($condition != '') {
$condition .= ' OR ';
}
$condition .= '(' . $dbw->makeList($row, LIST_AND) . ')';
}
$condition = "s_id=" . $dbw->addQuotes($sid) . " AND ({$condition})";
$dbw->delete($propertyTable->getName(), array($condition), "SMW::writePropertyTableRowUpdates-delete-{$propertyTable->getName()}");
}
if ($propertyTable->isFixedPropertyTable()) {
$property = new SMWDIProperty($propertyTable->getFixedProperty());
$pid = $this->store->smwIds->makeSMWPropertyID($property);
}
foreach ($rows as $row) {
if (!$propertyTable->isFixedPropertyTable()) {
$pid = $row['p_id'];
}
if (!array_key_exists($pid, $propertyUseIncrements)) {
$propertyUseIncrements[$pid] = 0;
}
$propertyUseIncrements[$pid] += $insert ? 1 : -1;
}
}
示例4: makeList
/**
* Makes an encoded list of strings from an array
* $mode:
* LIST_COMMA - comma separated, no field names
* LIST_AND - ANDed WHERE clause (without the WHERE)
* LIST_OR - ORed WHERE clause (without the WHERE)
* LIST_SET - comma separated with field names, like a SET clause
* LIST_NAMES - comma separated field names
* LIST_SET_PREPARED - like LIST_SET, except with ? tokens as values
* @param array $a
* @param int $mode
* @throws DBUnexpectedError
* @return string
*/
function makeList($a, $mode = LIST_COMMA)
{
if (!is_array($a)) {
throw new DBUnexpectedError($this, 'DatabaseIbm_db2::makeList called with incorrect parameters');
}
// if this is for a prepared UPDATE statement
// (this should be promoted to the parent class
// once other databases use prepared statements)
if ($mode == LIST_SET_PREPARED) {
$first = true;
$list = '';
foreach ($a as $field => $value) {
if (!$first) {
$list .= ", {$field} = ?";
} else {
$list .= "{$field} = ?";
$first = false;
}
}
$list .= '';
return $list;
}
// otherwise, call the usual function
return parent::makeList($a, $mode);
}
示例5: getExcludeClause
/**
* SQL clause to skip forbidden log types for this user
*
* @param DatabaseBase $db
* @param string $audience Public/user
* @param User $user User to check, or null to use $wgUser
* @return string|bool String on success, false on failure.
*/
public static function getExcludeClause($db, $audience = 'public', User $user = null)
{
global $wgLogRestrictions;
if ($audience != 'public' && $user === null) {
global $wgUser;
$user = $wgUser;
}
// Reset the array, clears extra "where" clauses when $par is used
$hiddenLogs = array();
// Don't show private logs to unprivileged users
foreach ($wgLogRestrictions as $logType => $right) {
if ($audience == 'public' || !$user->isAllowed($right)) {
$hiddenLogs[] = $logType;
}
}
if (count($hiddenLogs) == 1) {
return 'log_type != ' . $db->addQuotes($hiddenLogs[0]);
} elseif ($hiddenLogs) {
return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
}
return false;
}
示例6: getTitleConds
/**
* Of the current set of keys, construct database query conditions.
* @since 2011-12-28
* @param DatabaseBase $db
* @return string
*/
protected function getTitleConds($db)
{
// Array of array( namespace, pagename )
$byNamespace = array();
foreach ($this->getTitles() as $title) {
$namespace = $title->getNamespace();
$pagename = $title->getDBKey();
$byNamespace[$namespace][] = $pagename;
}
$conds = array();
foreach ($byNamespace as $namespaces => $pagenames) {
$cond = array('page_namespace' => $namespaces, 'page_title' => $pagenames);
$conds[] = $db->makeList($cond, LIST_AND);
}
return $db->makeList($conds, LIST_OR);
}
示例7: makeList
/**
* Makes an encoded list of strings from an array
* @param array $a Containing the data
* @param int $mode Constant
* - LIST_COMMA: comma separated, no field names
* - LIST_AND: ANDed WHERE clause (without the WHERE). See
* the documentation for $conds in DatabaseBase::select().
* - LIST_OR: ORed WHERE clause (without the WHERE)
* - LIST_SET: comma separated with field names, like a SET clause
* - LIST_NAMES: comma separated field names
* @param array $binaryColumns Contains a list of column names that are binary types
* This is a custom parameter only present for MS SQL.
*
* @throws MWException|DBUnexpectedError
* @return string
*/
public function makeList($a, $mode = LIST_COMMA, $binaryColumns = array())
{
if (!is_array($a)) {
throw new DBUnexpectedError($this, 'DatabaseBase::makeList called with incorrect parameters');
}
if ($mode != LIST_NAMES) {
// In MS SQL, values need to be specially encoded when they are
// inserted into binary fields. Perform this necessary encoding
// for the specified set of columns.
foreach (array_keys($a) as $field) {
if (!isset($binaryColumns[$field])) {
continue;
}
if (is_array($a[$field])) {
foreach ($a[$field] as &$v) {
$v = new MssqlBlob($v);
}
unset($v);
} else {
$a[$field] = new MssqlBlob($a[$field]);
}
}
}
return parent::makeList($a, $mode);
}
示例8: getNameWhereClause
/**
* Get the where clause to query rows by either old or new name
*
* @param DatabaseBase $db
*
* @return string
*/
private function getNameWhereClause(DatabaseBase $db)
{
return $db->makeList(array('ru_oldname' => $this->name, 'ru_newname' => $this->name), LIST_OR);
}
示例9: __parse
private static function __parse($aInput, $aParams, &$parser, $returnPlainData = false)
{
global $wgLang, $wgUser, $wgCityId, $wgParser, $wgTitle;
global $wgExtensionsPath, $wgStylePath, $wgRequest;
wfProfileIn(__METHOD__);
/**
* because this parser tag contains elements of interface we need to
* inform parser to vary parser cache key by user lang option
**/
/* @var $parser Parser */
if ($parser instanceof Parser && $parser->mOutput instanceof ParserOutput) {
$parser->mOutput->recordOption('userlang');
}
$result = "";
self::$aTables = self::$aWhere = self::$aOptions = array();
self::$dbr = null;
/* default settings for query */
self::__setDefault();
$showOnlyPage = 0;
try {
/* database connect */
self::$dbr = wfGetDB(DB_SLAVE, 'dpl');
/* parse parameters as XML tags */
wfDebugLog(__METHOD__, "parse " . count($aInput) . " parameters (XML tags)\n");
$relationArray = array();
foreach ($aInput as $sParamName => $aParamValues) {
/* ignore empty lines */
if (empty($aParamValues)) {
wfDebugLog(__METHOD__, "ignore empty param: " . $sParamName . " \n");
continue;
}
/* invalid name of parameter or empty name */
if (!in_array($sParamName, array_keys(self::$aBlogParams))) {
throw new Exception(wfMsg('blog-invalidparam', $sParamName, implode(", ", array_keys(self::$aBlogParams))));
} elseif (trim($sParamName) == '') {
throw new Exception(wfMsg('blog-emptyparam'));
}
/* ignore comment lines */
if ($sParamName[0] == '#') {
wfDebugLog(__METHOD__, "ignore comment line: " . $sParamName . " \n");
continue;
}
/* parse value of parameter */
switch ($sParamName) {
case 'category':
if (!empty($aParamValues)) {
$aParamValues = array_slice($aParamValues, 0, self::$aBlogParams[$sParamName]['count']);
$aParamValues = str_replace(" ", "_", $aParamValues);
if (!empty($aParamValues) && is_array($aParamValues)) {
$relationArray[$sParamName] = $aParamValues;
}
$aPages = self::__getCategories($aParamValues, $parser);
if (!empty($aPages)) {
self::$aWhere[] = "page_id in (" . implode(",", $aPages) . ")";
} else {
self::$aWhere[] = "page_id = 0";
}
}
break;
case 'pages':
if (!empty($aParamValues)) {
$showOnlyPage = $aParamValues;
}
break;
case 'author':
if (!empty($aParamValues)) {
$aParamValues = array_slice($aParamValues, 0, self::$aBlogParams[$sParamName]['count']);
if (!empty($aParamValues) && is_array($aParamValues)) {
$relationArray[$sParamName] = $aParamValues;
$aTmpWhere = array();
foreach ($aParamValues as $id => $sParamValue) {
$sParamValue = str_replace(" ", "\\_", $sParamValue);
$aTmpWhere[] = "page_title like '" . addslashes($sParamValue) . "/%'";
}
if (!empty($aTmpWhere)) {
self::$aWhere[] = implode(" OR ", $aTmpWhere);
}
}
}
break;
case 'order':
if (!empty($aParamValues) && is_array($aParamValues)) {
list($sParamValue) = $aParamValues;
self::__makeOrder($sParamName, $sParamValue);
}
break;
case 'ordertype':
case 'type':
if (!empty($aParamValues) && is_array($aParamValues)) {
list($sParamValue) = $aParamValues;
self::__makeListOption($sParamName, $sParamValue);
}
break;
case 'count':
case 'displaycount':
case 'offset':
case 'summarylength':
case 'create_timestamp':
case 'timestamp':
if (!empty($aParamValues) && is_array($aParamValues)) {
//.........这里部分代码省略.........