本文整理汇总了PHP中XenForo_Db::quoteLike方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Db::quoteLike方法的具体用法?PHP XenForo_Db::quoteLike怎么用?PHP XenForo_Db::quoteLike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Db
的用法示例。
在下文中一共展示了XenForo_Db::quoteLike方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareUserFieldConditions
/**
* Prepares a set of conditions to select fields against.
*
* @param array $conditions List of conditions.
* @param array $fetchOptions The fetch options that have been provided. May be edited if criteria requires.
*
* @return string Criteria as SQL for where clause
*/
public function prepareUserFieldConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['display_group'])) {
$sqlConditions[] = 'user_field.display_group = ' . $db->quote($conditions['display_group']);
}
if (!empty($conditions['profileView'])) {
$sqlConditions[] = 'user_field.display_group <> \'preferences\' AND user_field.viewable_profile = 1';
}
if (!empty($conditions['messageView'])) {
$sqlConditions[] = 'user_field.display_group <> \'preferences\' AND user_field.viewable_message = 1';
}
if (!empty($conditions['registration'])) {
$sqlConditions[] = 'user_field.required = 1 OR user_field.show_registration = 1';
}
if (isset($conditions['moderator_editable'])) {
$sqlConditions[] = 'user_field.moderator_editable = ' . ($conditions['moderator_editable'] ? 1 : 0);
}
if (!empty($conditions['adminQuickSearch'])) {
$searchStringSql = 'CONVERT(user_field.field_id USING utf8) LIKE ' . XenForo_Db::quoteLike($conditions['adminQuickSearch']['searchText'], 'lr');
if (!empty($conditions['adminQuickSearch']['phraseMatches'])) {
$sqlConditions[] = '(' . $searchStringSql . ' OR CONVERT(user_field.field_id USING utf8) IN (' . $db->quote($conditions['adminQuickSearch']['phraseMatches']) . '))';
} else {
$sqlConditions[] = $searchStringSql;
}
}
return $this->getConditionsForClause($sqlConditions);
}
示例2: prepareTemplateConditions
/**
* Prepares conditions for searching templates. Often, this search will
* be done on an effective template set (using the map). Some conditions
* may require this.
*
* @param array $conditions
* @param array $fetchOptions
*
* @return string SQL conditions
*/
public function prepareTemplateConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['title'])) {
if (is_array($conditions['title'])) {
$sqlConditions[] = 'template.title LIKE ' . XenForo_Db::quoteLike($conditions['title'][0], $conditions['title'][1], $db);
} else {
$sqlConditions[] = 'template.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], 'lr', $db);
}
}
if (!empty($conditions['template'])) {
if (is_array($conditions['template'])) {
$sqlConditions[] = 'template.template LIKE ' . XenForo_Db::quoteLike($conditions['template'][0], $conditions['phrase_text'][1], $db);
} else {
$sqlConditions[] = 'template.template LIKE ' . XenForo_Db::quoteLike($conditions['template'], 'lr', $db);
}
}
if (!empty($conditions['template_state'])) {
$stateIf = 'IF(template.style_id = 0, \'default\', IF(template.style_id = template_map.style_id, \'custom\', \'inherited\'))';
if (is_array($conditions['template_state'])) {
$sqlConditions[] = $stateIf . ' IN (' . $db->quote($conditions['template_state']) . ')';
} else {
$sqlConditions[] = $stateIf . ' = ' . $db->quote($conditions['template_state']);
}
}
return $this->getConditionsForClause($sqlConditions);
}
示例3: prepareResourceFetchOptions
/**
*
* @see XenResource_Model_Resource::prepareResourceFetchOptions()
*/
public function prepareResourceFetchOptions(array $fetchOptions)
{
$resourceFetchOptions = parent::prepareResourceFetchOptions($fetchOptions);
$db = $this->_getDb();
if (!empty($fetchOptions['order'])) {
if (strlen($fetchOptions['order']) > strlen('custom_field_') && substr($fetchOptions['order'], 0, strlen('custom_field_')) == 'custom_field_') {
$customFieldId = substr($fetchOptions['order'], strlen('custom_field_'));
$fetchOptions['customFields'][$customFieldId] = true;
}
}
if (!empty($fetchOptions['customFields']) && is_array($fetchOptions['customFields'])) {
foreach ($fetchOptions['customFields'] as $customFieldId => $value) {
if ($value === '' || is_array($value) && !$value) {
continue;
}
$isExact = !empty($fetchOptions['customFieldsExact'][$customFieldId]);
$customFieldId = preg_replace('/[^a-z0-9_]/i', '', $customFieldId);
$resourceFetchOptions['selectFields'] .= ", resource_field_value_{$customFieldId}.field_value AS custom_field_{$customFieldId}";
if ($value === true) {
$resourceFetchOptions['joinTables'] .= "\n LEFT JOIN xf_resource_field_value AS resource_field_value_{$customFieldId} ON\n (resource_field_value_{$customFieldId}.resource_id = resource.resource_id\n AND resource_field_value_{$customFieldId}.field_id = " . $this->_getDb()->quote($customFieldId) . ")";
} else {
$possibleValues = array();
foreach ((array) $value as $possible) {
if ($isExact) {
$possibleValues[] = "resource_field_value_{$customFieldId}.field_value = " . $this->_getDb()->quote($possible);
} else {
$possibleValues[] = "resource_field_value_{$customFieldId}.field_value LIKE " . XenForo_Db::quoteLike($possible, 'lr');
}
}
$resourceFetchOptions['joinTables'] .= "\n INNER JOIN xf_resource_field_value AS resource_field_value_{$customFieldId} ON\n (resource_field_value_{$customFieldId}.resource_id = resource.resource_id\n AND resource_field_value_{$customFieldId}.field_id = " . $this->_getDb()->quote($customFieldId) . "\n\t\t\t\t\t\tAND (" . implode(' OR ', $possibleValues) . "))";
}
}
}
return $resourceFetchOptions;
}
示例4: getLanguagesForAdminQuickSearch
/**
* Return results for admin quick search
*
* @param string Keywords for which to search
*
* @return array
*/
public function getLanguagesForAdminQuickSearch($searchText)
{
return $this->fetchAllKeyed('
SELECT *
FROM xf_language
WHERE title LIKE ' . XenForo_Db::quoteLike($searchText, 'lr', $this->_getDb()) . '
ORDER BY title
', 'language_id');
}
示例5: verifyPosition
public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
{
$positions = trim($positions);
if (empty($positions)) {
$dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
}
if ('all' == $positions) {
return true;
}
/** @var XenForo_Model_Template $templateModel */
$templateModel = $dw->getModelFromCache('XenForo_Model_Template');
$db = XenForo_Application::getDb();
$positionsArray = explode(',', $positions);
$positionsGood = array();
$templateForHooks = array();
foreach ($positionsArray as $position) {
$position = trim($position);
if (empty($position)) {
continue;
}
if (in_array($position, array('wf_widget_page', 'hook:wf_widget_page_contents'), true) and !$dw->get('widget_page_id')) {
$dw->error(new XenForo_Phrase('wf_position_x_requires_widget_page', array('position' => $position)), $fieldName);
return false;
}
if (in_array($position, array('wf_widget_ajax'), true)) {
$dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
return false;
}
// sondh@2012-08-25
// added support for hook:hook_name
if (substr($position, 0, 5) == 'hook:') {
// accept all kind of hooks, just need to get parent templates for them
$templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
if (count($templates) > 0) {
$templateForHooks[$position] = array();
foreach ($templates as $template) {
$templateForHooks[$position][] = $template['title'];
}
$templateForHooks[$position] = array_unique($templateForHooks[$position]);
} else {
$dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
return false;
}
} elseif (!$templateModel->getTemplateInStyleByTitle($position)) {
$dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
return false;
}
$positionsGood[] = $position;
}
$dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
asort($positionsGood);
$positions = implode(', ', $positionsGood);
return true;
}
示例6: prepareLinkProxyConditions
/**
* Prepares a collection of link proxy fetching related conditions into an SQL clause
*
* @param array $conditions List of conditions
* @param array $fetchOptions Modifiable set of fetch options (may have joins pushed on to it)
*
* @return string SQL clause (at least 1=1)
*/
public function prepareLinkProxyConditions(array $conditions, array &$fetchOptions)
{
$sqlConditions = array();
$db = $this->_getDb();
if (!empty($conditions['url'])) {
if (is_array($conditions['url'])) {
$sqlConditions[] = 'link_proxy.url LIKE ' . XenForo_Db::quoteLike($conditions['url'][0], $conditions['url'][1], $db);
} else {
$sqlConditions[] = 'link_proxy.url LIKE ' . XenForo_Db::quoteLike($conditions['url'], 'lr', $db);
}
}
return $this->getConditionsForClause($sqlConditions);
}
示例7: prepareTermConditions
public function prepareTermConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['value'])) {
if (is_array($conditions['value'])) {
$sqlConditions[] = 'terms.value LIKE ' . XenForo_Db::quoteLike($conditions['value'][0], $conditions['value'][1], $db);
} else {
$sqlConditions[] = 'terms.value LIKE ' . XenForo_Db::quoteLike($conditions['value'], 'lr', $db);
}
}
return $this->getConditionsForClause($sqlConditions);
}
示例8: getPromotions
/**
* Gets promotions matching the specified conditions.
*
* @param array $conditions
*
* @return array [promotion id] => info
*/
public function getPromotions(array $conditions = array())
{
$sqlConditions = array();
if (isset($conditions['active'])) {
$sqlConditions[] = 'promotion.active = ' . ($conditions['active'] ? 1 : 0);
}
if (isset($conditions['adminQuickSearch'])) {
$sqlConditions[] = 'promotion.title LIKE ' . XenForo_Db::quoteLike($conditions['adminQuickSearch'], 'lr', $this->_getDb());
}
$whereClause = $this->getConditionsForClause($sqlConditions);
return $this->fetchAllKeyed('
SELECT promotion.*
FROM xf_user_group_promotion AS promotion
WHERE ' . $whereClause . '
ORDER BY promotion.title
', 'promotion_id');
}
示例9: prepareResourceFieldConditions
/**
* Prepares a set of conditions to select fields against.
*
* @param array $conditions List of conditions.
* @param array $fetchOptions The fetch options that have been provided. May
* be edited if criteria requires.
*
* @return string Criteria as SQL for where clause
*/
public function prepareResourceFieldConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (isset($conditions['field_ids'])) {
$sqlConditions[] = 'field.field_id IN(' . $db->quote($conditions['field_ids']) . ')';
}
if (!empty($conditions['field_group_id'])) {
$sqlConditions[] = 'field.field_group_id = ' . $db->quote($conditions['field_group_id']);
}
if (!empty($conditions['field_choices_class_id'])) {
$sqlConditions[] = 'field.field_choices_class_id = ' . $db->quote($conditions['field_choices_class_id']);
}
if (!empty($conditions['addon_id'])) {
$sqlConditions[] = 'field.addon_id = ' . $db->quote($conditions['addon_id']);
}
if (!empty($conditions['active'])) {
$sqlConditions[] = 'addon.active = 1 OR field.addon_id = \'\'';
$this->addFetchOptionJoin($fetchOptions, self::FETCH_ADDON);
}
if (!empty($conditions['adminQuickSearch'])) {
$searchStringSql = 'field.field_id LIKE ' . XenForo_Db::quoteLike($conditions['adminQuickSearch']['searchText'], 'lr');
if (!empty($conditions['adminQuickSearch']['phraseMatches'])) {
$sqlConditions[] = '(' . $searchStringSql . ' OR field.field_id IN (' . $db->quote($conditions['adminQuickSearch']['phraseMatches']) . '))';
} else {
$sqlConditions[] = $searchStringSql;
}
}
if (isset($conditions['resource_category_id'])) {
if (is_array($conditions['resource_category_id'])) {
$sqlConditions[] = 'rcf.resource_category_id IN (' . $db->quote($conditions['resource_category_id']) . ')';
} else {
$sqlConditions[] = 'rcf.resource_category_id = ' . $db->quote($conditions['resource_category_id']);
}
$this->addFetchOptionJoin($fetchOptions, self::FETCH_CATEGORY_FIELD);
}
if (isset($conditions['resource_category_ids'])) {
$sqlConditions[] = 'rcf.resource_category_id IN(' . $db->quote($conditions['resource_category_ids']) . ')';
$this->addFetchOptionJoin($fetchOptions, self::FETCH_CATEGORY_FIELD);
}
if (!empty($conditions['informationView'])) {
$sqlConditions[] = 'field.viewable_information = 1';
}
return $this->getConditionsForClause($sqlConditions);
}
示例10: _getPhraseMatches
/**
* Searches phrases for the given search text, when the phrase title
* matches constraints set by $phraseConditions, then returns those
* results in groups according to the title constraint they matched.
*
* @param string $searchText
* @param array $phraseConditions [type => [like => SQL Like string, regex => regex match]]
* @param array $viewingUser
*
* @return array
*/
protected function _getPhraseMatches($searchText, array $phraseConditions)
{
$db = $this->_getDb();
// build the title constraints
$titleConditions = array();
foreach ($phraseConditions as $searchType => $phraseCondition) {
if ($phraseCondition) {
$titleConditions[$searchType] = 'title LIKE ' . $phraseCondition['like'];
}
}
// there were no title constraints, so bypass all the heavy lifting
if (!$titleConditions) {
// build an array that looks like we did all the stuff below but found nothing
return array_fill_keys(array_keys($phraseConditions), array());
}
// get the ID of the language within which to search
$languageId = XenForo_Visitor::getInstance()->language_id;
if (!$languageId) {
$languageId = XenForo_Application::get('options')->defaultLanguageId;
}
$phraseIds = $db->fetchCol('
SELECT title
FROM xf_phrase_compiled
WHERE language_id = ?
AND phrase_text LIKE ' . XenForo_Db::quoteLike($searchText, 'lr', $db) . '
AND (
' . implode(' OR
', $titleConditions) . '
)
', $languageId);
// Divide the found phrases into groups using the phrase condition regexes
$phrases = array();
foreach ($phraseConditions as $searchType => $phraseCondition) {
$phrases[$searchType] = array();
if ($phraseCondition) {
foreach ($phraseIds as $i => $phraseId) {
if (preg_match($phraseCondition['regex'], $phraseId, $match)) {
$phrases[$searchType][] = $match[1];
unset($phraseIds[$i]);
}
}
}
}
return $phrases;
}
示例11: prepareForumConditions
/**
* Prepares a collection of forum fetching related conditions into an SQL clause
*
* @param array $conditions List of conditions
* @param array $fetchOptions Modifiable set of fetch options (may have joins pushed on to it)
*
* @return string SQL clause (at least 1=1)
*/
public function prepareForumConditions(array $conditions, array &$fetchOptions)
{
$parentConditions = parent::prepareForumConditions($conditions, $fetchOptions);
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['title'])) {
if (is_array($conditions['title'])) {
$sqlConditions[] = 'node.title LIKE ' . XenForo_Db::quoteLike($conditions['title'][0], $conditions['title'][1], $db);
} else {
$sqlConditions[] = 'node.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], 'lr', $db);
}
}
if ($parentConditions != '1=1') {
return $parentConditions;
} else {
return $this->getConditionsForClause($sqlConditions);
}
}
示例12: prepareGalleryFieldConditions
/**
* Prepares a set of conditions to select fields against.
*
* @param array $conditions List of conditions.
* @param array $fetchOptions The fetch options that have been provided. May be edited if criteria requires.
*
* @return string Criteria as SQL for where clause
*/
public function prepareGalleryFieldConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['display_group'])) {
$sqlConditions[] = 'field.display_group = ' . $db->quote($conditions['display_group']);
}
if (!empty($conditions['adminQuickSearch'])) {
$searchStringSql = 'CONVERT(field.field_id USING utf8) LIKE ' . XenForo_Db::quoteLike($conditions['adminQuickSearch']['searchText'], 'lr');
if (!empty($conditions['adminQuickSearch']['phraseMatches'])) {
$sqlConditions[] = '(' . $searchStringSql . ' OR CONVERT(field.field_id USING utf8) IN (' . $db->quote($conditions['adminQuickSearch']['phraseMatches']) . '))';
} else {
$sqlConditions[] = $searchStringSql;
}
}
if (isset($conditions['display_add_media'])) {
$sqlConditions[] = 'field.display_add_media = ' . $db->quote($conditions['display_add_media']);
}
return $this->getConditionsForClause($sqlConditions);
}
示例13: validateConfiguration
public function validateConfiguration(array &$config)
{
$errors = array();
$config['db']['prefix'] = preg_replace('/[^a-z0-9_]/i', '', $config['db']['prefix']);
try {
$db = Zend_Db::factory('mysqli', array('host' => $config['db']['host'], 'port' => $config['db']['port'], 'username' => $config['db']['username'], 'password' => $config['db']['password'], 'dbname' => $config['db']['dbname'], 'charset' => $config['db']['charset']));
$db->getConnection();
} catch (Zend_Db_Exception $e) {
$errors[] = new XenForo_Phrase('source_database_connection_details_not_correct_x', array('error' => $e->getMessage()));
}
if ($errors) {
return $errors;
}
try {
$db->query('
SELECT userid
FROM ' . $config['db']['prefix'] . 'users
LIMIT 1
');
} catch (Zend_Db_Exception $e) {
if ($config['db']['dbname'] === '') {
$errors[] = new XenForo_Phrase('please_enter_database_name');
} else {
$errors[] = new XenForo_Phrase('table_prefix_or_database_name_is_not_correct');
}
}
$config['noRatingsTable'] = false;
try {
$ratingsTableExists = $db->fetchOne('
SHOW TABLES LIKE ' . XenForo_Db::quoteLike($config['db']['prefix'] . 'ratings', '') . '
');
if (!$ratingsTableExists) {
$config['noRatingsTable'] = true;
}
} catch (Zend_Db_Exception $e) {
}
return $errors;
}
示例14: prepareTemplateConditions
/**
* Prepares conditions for searching admin templates.
*
* @param array $conditions
* @param array $fetchOptions
*
* @return string SQL conditions
*/
public function prepareTemplateConditions(array $conditions, array &$fetchOptions)
{
$db = $this->_getDb();
$sqlConditions = array();
if (!empty($conditions['title'])) {
if (is_array($conditions['title'])) {
$sqlConditions[] = 'template.title LIKE ' . XenForo_Db::quoteLike($conditions['title'][0], $conditions['title'][1], $db);
} else {
$sqlConditions[] = 'template.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], 'lr', $db);
}
}
if (!empty($conditions['template'])) {
if (is_array($conditions['template'])) {
$sqlConditions[] = 'template.template LIKE ' . XenForo_Db::quoteLike($conditions['template'][0], $conditions['phrase_text'][1], $db);
} else {
$sqlConditions[] = 'template.template LIKE ' . XenForo_Db::quoteLike($conditions['template'], 'lr', $db);
}
}
if (!empty($conditions['addon_id'])) {
$sqlConditions[] = 'addon.addon_id = ' . $db->quote($conditions['addon_id']);
}
return $this->getConditionsForClause($sqlConditions);
}
示例15: getBbCodeMediaSitesForAdminQuickSearch
public function getBbCodeMediaSitesForAdminQuickSearch($searchText)
{
$quotedString = XenForo_Db::quoteLike($searchText, 'lr', $this->_getDb());
return $this->fetchAllKeyed('
SELECT * FROM xf_bb_code_media_site
WHERE site_title LIKE ' . $quotedString . '
ORDER BY site_title', 'media_site_id');
}