本文整理汇总了PHP中db_quote函数的典型用法代码示例。如果您正苦于以下问题:PHP db_quote函数的具体用法?PHP db_quote怎么用?PHP db_quote使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_quote函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fn_get_seo_rules
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
$lang_code = fn_get_corrected_seo_lang_code($lang_code);
$global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' GROUP BY dispatch");
$local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s", $lang_code);
if ($diff = array_diff($global_total, $local_total)) {
foreach ($diff as $disp) {
fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, DESCR_SL);
}
}
// Init filter
$params = fn_init_view('seo_rules', $params);
// Set default values to input params
$params['page'] = empty($params['page']) ? 1 : $params['page'];
// default page is 1
$condition = '';
if (isset($params['name']) && fn_string_no_empty($params['name'])) {
$condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
}
if (isset($params['controller']) && fn_string_no_empty($params['controller'])) {
$condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['controller']) . "%");
}
$limit = '';
if (!empty($items_per_page)) {
$total = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
$limit = fn_paginate($params['page'], $total, $items_per_page);
}
$seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
return array($seo_data, $params);
}
示例2: update
public function update($content_id, $postdata)
{
$content_id = db_quote($content_id);
$title = db_quote($postdata['title']);
$body = db_quote($postdata['body_content']);
$this->db->query("UPDATE site_content SET title = {$title}, body = {$body} WHERE content_id = {$content_id}");
}
示例3: instance_config_form
public static function instance_config_form($group, $instance = null)
{
if (isset($instance)) {
$autosubscribe = get_field('interaction_forum_instance_config', 'value', 'field', 'autosubscribe', 'forum', $instance->get('id'));
$weight = get_field('interaction_forum_instance_config', 'value', 'field', 'weight', 'forum', $instance->get('id'));
$moderators = get_column_sql('SELECT fm.user FROM {interaction_forum_moderator} fm
JOIN {usr} u ON (fm.user = u.id AND u.deleted = 0)
WHERE fm.forum = ?', array($instance->get('id')));
}
if ($instance === null) {
$exclude = '';
} else {
$exclude = 'AND i.id != ' . db_quote($instance->get('id'));
}
$existing = get_records_sql_array('
SELECT i.id, i.title, c.value AS weight
FROM {interaction_instance} i
INNER JOIN {interaction_forum_instance_config} c ON (i.id = c.forum AND c.field = \'weight\')
WHERE i.group = ?
AND i.deleted != 1
' . $exclude . '
ORDER BY c.value', array($group->id));
if ($existing) {
foreach ($existing as &$item) {
$item = (array) $item;
}
} else {
$existing = array();
}
return array('fieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('settings'), 'elements' => array('autosubscribe' => array('type' => 'select', 'title' => get_string('autosubscribeusers', 'interaction.forum'), 'options' => array(true => get_string('yes'), false => get_string('no')), 'description' => get_string('autosubscribeusersdescription', 'interaction.forum'), 'defaultvalue' => isset($autosubscribe) ? $autosubscribe : false, 'rules' => array('required' => true), 'help' => true), 'weight' => array('type' => 'weight', 'title' => get_string('Order', 'interaction.forum'), 'description' => get_string('orderdescription', 'interaction.forum'), 'defaultvalue' => isset($weight) ? $weight : count($existing), 'rules' => array('required' => true), 'existing' => $existing, 'ignore' => count($existing) == 0), 'moderator' => array('type' => 'userlist', 'title' => get_string('Moderators', 'interaction.forum'), 'description' => get_string('moderatorsdescription', 'interaction.forum'), 'defaultvalue' => isset($moderators) ? $moderators : null, 'group' => $group->id, 'includeadmins' => false, 'filter' => false, 'lefttitle' => get_string('potentialmoderators', 'interaction.forum'), 'righttitle' => get_string('currentmoderators', 'interaction.forum')))));
}
示例4: fn_get_seo_redirects
function fn_get_seo_redirects($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
// Init filter
$params = LastView::instance()->update('seo_redirects', $params);
// Set default values to input params
$default_params = array('page' => 1, 'items_per_page' => $items_per_page);
$params = array_merge($default_params, $params);
$condition = '';
if (isset($params['src']) && fn_string_not_empty($params['src'])) {
$condition .= db_quote(" AND src LIKE ?l", "%" . trim($params['src']) . "%");
}
if (!empty($params['type'])) {
$condition .= db_quote(" AND type = ?s", $params['type']);
}
if (!empty($params['lang_code'])) {
$condition .= db_quote(" AND lang_code = ?s", $params['lang_code']);
}
$condition .= fn_get_seo_company_condition('?:seo_redirects.company_id');
$limit = '';
if (!empty($params['items_per_page'])) {
$params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_redirects WHERE 1 ?p", $condition);
$limit = db_paginate($params['page'], $params['items_per_page']);
}
$seo_redirects = db_get_hash_array("SELECT * FROM ?:seo_redirects WHERE 1 ?p ORDER BY src {$limit}", 'redirect_id', $condition);
if (!empty($seo_redirects)) {
foreach ($seo_redirects as $key => $seo_redirect) {
$seo_redirects[$key]['parsed_url'] = fn_generate_seo_url_from_schema($seo_redirect);
}
}
return array($seo_redirects, $params);
}
示例5: new_image
static function new_image($image)
{
global $_zp_exifvars;
$entry_locale = getUserLocale();
$languages = generateLanguageList();
$languageTags = $element = array();
$candidates = self::getTaggingItems();
foreach ($candidates as $key) {
if ($meta = $image->get($key)) {
setupCurrentLocale('en_US');
$en_us = $element[] = exifTranslate($meta);
foreach ($languages as $language) {
setupCurrentLocale($language);
$xlated = exifTranslate($meta);
if ($xlated != $en_us) {
// the string has a translation in this language
$element[] = $xlated;
$languageTags[$language] = $xlated;
}
}
}
}
setupCurrentLocale($entry_locale);
$element = array_unique(array_merge($image->getTags(), $element));
$image->setTags($element);
$image->save();
foreach ($languageTags as $language => $tag) {
$sql = 'UPDATE ' . prefix('tags') . ' SET `language`=' . db_quote($language) . ' WHERE `name`=' . db_quote($tag) . ' AND `language`=NULL OR `language` LIKE ""';
query($sql, false);
}
return $image;
}
示例6: instance_config_form
public static function instance_config_form($group, $instance = null)
{
if (isset($instance)) {
$instanceconfig = get_records_assoc('interaction_forum_instance_config', 'forum', $instance->get('id'), '', 'field,value');
$autosubscribe = isset($instanceconfig['autosubscribe']) ? $instanceconfig['autosubscribe']->value : false;
$weight = isset($instanceconfig['weight']) ? $instanceconfig['weight']->value : null;
$createtopicusers = isset($instanceconfig['createtopicusers']) ? $instanceconfig['createtopicusers']->value : null;
$closetopics = !empty($instanceconfig['closetopics']);
$indentmode = isset($instanceconfig['indentmode']) ? $instanceconfig['indentmode']->value : null;
$maxindent = isset($instanceconfig['maxindent']) ? $instanceconfig['maxindent']->value : null;
$moderators = get_forum_moderators($instance->get('id'));
}
if ($instance === null) {
$exclude = '';
} else {
$exclude = 'AND i.id != ' . db_quote($instance->get('id'));
}
$existing = get_records_sql_array('
SELECT i.id, i.title, c.value AS weight
FROM {interaction_instance} i
INNER JOIN {interaction_forum_instance_config} c ON (i.id = c.forum AND c.field = \'weight\')
WHERE i.group = ?
AND i.deleted != 1
' . $exclude . '
ORDER BY CHAR_LENGTH(c.value), c.value', array($group->id));
if ($existing) {
foreach ($existing as &$item) {
$item = (array) $item;
}
} else {
$existing = array();
}
return array('indentmode' => array('type' => 'select', 'title' => get_string('indentmode', 'interaction.forum'), 'options' => array('full_indent' => get_string('indentfullindent', 'interaction.forum'), 'max_indent' => get_string('indentmaxindent', 'interaction.forum'), 'no_indent' => get_string('indentflatindent', 'interaction.forum')), 'description' => get_string('indentmodedescription', 'interaction.forum'), 'defaultvalue' => isset($indentmode) ? $indentmode : 'full_indent', 'help' => true, 'rules' => array('required' => true)), 'maxindent' => array('type' => 'text', 'title' => get_string('maxindent', 'interaction.forum'), 'size' => 2, 'defaultvalue' => isset($maxindent) ? $maxindent : 10, 'class' => isset($indentmode) && $indentmode == 'max_indent' ? '' : 'hidden', 'rules' => array('integer' => true, 'minvalue' => 1, 'maxvalue' => 100)), 'fieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('forumsettings', 'interaction.forum'), 'elements' => array('autosubscribe' => array('type' => 'switchbox', 'title' => get_string('autosubscribeusers', 'interaction.forum'), 'description' => get_string('autosubscribeusersdescription', 'interaction.forum'), 'defaultvalue' => isset($autosubscribe) ? $autosubscribe : false, 'help' => true), 'weight' => array('type' => 'weight', 'title' => get_string('Order', 'interaction.forum'), 'description' => get_string('orderdescription', 'interaction.forum'), 'defaultvalue' => isset($weight) ? $weight : count($existing), 'rules' => array('required' => true), 'existing' => $existing, 'ignore' => count($existing) == 0), 'moderator' => array('type' => 'userlist', 'title' => get_string('Moderators', 'interaction.forum'), 'description' => get_string('moderatorsdescription', 'interaction.forum'), 'defaultvalue' => isset($moderators) ? $moderators : null, 'group' => $group->id, 'includeadmins' => false, 'lefttitle' => get_string('potentialmoderators', 'interaction.forum'), 'righttitle' => get_string('currentmoderators', 'interaction.forum')), 'createtopicusers' => array('type' => 'select', 'title' => get_string('whocancreatetopics', 'interaction.forum'), 'options' => array('members' => get_string('allgroupmembers', 'group'), 'moderators' => get_string('moderatorsandgroupadminsonly', 'interaction.forum')), 'description' => get_string('createtopicusersdescription', 'interaction.forum'), 'defaultvalue' => isset($createtopicusers) && $createtopicusers == 'moderators' ? 'moderators' : 'members', 'rules' => array('required' => true)), 'closetopics' => array('type' => 'switchbox', 'title' => get_string('closetopics', 'interaction.forum'), 'description' => get_string('closetopicsdescription1', 'interaction.forum'), 'defaultvalue' => !empty($closetopics)))));
}
示例7: fn_required_products_get_products
function fn_required_products_get_products($params, $fields, $sortings, $condition, $join, $sorting, $group_by)
{
if (!empty($params['for_required_product'])) {
$join .= " LEFT JOIN ?:product_required_products ON products.product_id = ?:product_required_products.required_id";
$condition .= db_quote(" AND ?:product_required_products.product_id = ?i", $params['for_required_product']);
}
}
示例8: fn_get_seo_rules
function fn_get_seo_rules($params = array(), $items_per_page = 0, $lang_code = DESCR_SL)
{
$condition = fn_get_seo_company_condition('?:seo_names.company_id');
$lang_code = fn_get_corrected_seo_lang_code($lang_code);
$global_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' ?p GROUP BY dispatch", $condition);
$local_total = db_get_fields("SELECT dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
if ($diff = array_diff($global_total, $local_total)) {
foreach ($diff as $disp) {
fn_create_seo_name(0, 's', str_replace('.', '-', $disp), 0, $disp, '', DESCR_SL);
}
}
// Init filter
$params = LastView::instance()->update('seo_rules', $params);
// Set default values to input params
$default_params = array('page' => 1, 'items_per_page' => $items_per_page);
$params = array_merge($default_params, $params);
if (isset($params['name']) && fn_string_not_empty($params['name'])) {
$condition .= db_quote(" AND name LIKE ?l", "%" . trim($params['name']) . "%");
}
if (isset($params['rule_params']) && fn_string_not_empty($params['rule_params'])) {
$condition .= db_quote(" AND dispatch LIKE ?l", "%" . trim($params['rule_params']) . "%");
}
$limit = '';
if (!empty($params['items_per_page'])) {
$params['total_items'] = db_get_field("SELECT COUNT(*) FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p", $lang_code, $condition);
$limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
}
$seo_data = db_get_array("SELECT name, dispatch FROM ?:seo_names WHERE object_id = '0' AND type = 's' AND lang_code = ?s ?p ORDER BY dispatch {$limit}", $lang_code, $condition);
return array($seo_data, $params);
}
示例9: user_create
function user_create($username, $email, $sms, $carrier, $password, $confirm_password)
{
# A bit of error checking
$len = strlen($username);
if ('' == $username || 4 > $len || 40 < $len) {
return 1;
}
if ($password != $confirm_password) {
return 2;
}
$len = strlen($password);
if (4 > $len || 40 < $len) {
return 3;
}
# Only digits in the phone number
$sms = preg_replace('/[^0-9]/', '', $sms);
# Insert the user
global $_user_id;
$hash = sha1($GLOBALS['SALT'] . $username . time());
if ($_user_id = db_query("INSERT INTO users (username, email, sms,\n\t\tpassword, hash, created) VALUES ('" . db_quote($username) . "', '" . db_quote($email) . "', '" . db_quote("{$sms}{$carrier}") . "', SHA1('" . db_quote($GLOBALS['SALT'] . $password) . "'), '{$hash}', NOW());")) {
# Send email confirmation
mail($email, "Where's my car? - Email confirmation", "Click the link below to confirm your email address and start " . "receiving email reminders to move your car.\n" . "http://car.rcrowley.org/confirm/email/" . sha1($GLOBALS['SALT'] . $email), "From: Where's my car? <nobody@car.rcrowley.org>\r\n");
# Send SMS confirmation
mail("{$sms}{$carrier}", '', 'Enter the confirmation code ' . substr(sha1($GLOBALS['SALT'] . "{$sms}{$carrier}"), 0, 6) . ' at car.rcrowley.org', "From: Where's my car?\r\n");
# Login
setcookie('car', serialize(array('user_id' => $_user_id, 'hash' => $hash)), strtotime('+1 year'), '/', 'car.rcrowley.org');
return 0;
}
# Key error when INSERTing
return 4;
}
示例10: fn_get_banners
function fn_get_banners($params = array(), $lang_code = CART_LANGUAGE)
{
$default_params = array('items_per_page' => 0);
$params = array_merge($default_params, $params);
$sortings = array('position' => '?:banners.position', 'timestamp' => '?:banners.timestamp', 'name' => '?:banner_descriptions.banner');
$condition = $limit = '';
if (!empty($params['limit'])) {
$limit = db_quote(' LIMIT 0, ?i', $params['limit']);
}
$sorting = db_sort($params, $sortings, 'name', 'asc');
$condition = AREA == 'A' ? '' : " AND ?:banners.status = 'A' ";
$condition .= fn_get_localizations_condition('?:banners.localization');
$condition .= AREA == 'A' ? '' : " AND (?:banners.type != 'G' OR ?:banner_images.banner_image_id IS NOT NULL) ";
if (!empty($params['item_ids'])) {
$condition .= db_quote(' AND ?:banners.banner_id IN (?n)', explode(',', $params['item_ids']));
}
if (!empty($params['period']) && $params['period'] != 'A') {
list($params['time_from'], $params['time_to']) = fn_create_periods($params);
$condition .= db_quote(" AND (?:banners.timestamp >= ?i AND ?:banners.timestamp <= ?i)", $params['time_from'], $params['time_to']);
}
fn_set_hook('get_banners', $params, $condition, $sorting, $limit, $lang_code);
$fields = array('?:banners.banner_id', '?:banners.type', '?:banners.target', '?:banners.status', '?:banners.position', '?:banner_descriptions.banner', '?:banner_descriptions.description', '?:banner_descriptions.url', '?:banner_images.banner_image_id');
if (fn_allowed_for('ULTIMATE')) {
$fields[] = '?:banners.company_id';
}
$banners = db_get_array("SELECT ?p FROM ?:banners " . "LEFT JOIN ?:banner_descriptions ON ?:banner_descriptions.banner_id = ?:banners.banner_id AND ?:banner_descriptions.lang_code = ?s" . "LEFT JOIN ?:banner_images ON ?:banner_images.banner_id = ?:banners.banner_id AND ?:banner_images.lang_code = ?s" . "WHERE 1 ?p ?p ?p", implode(", ", $fields), $lang_code, $lang_code, $condition, $sorting, $limit);
foreach ($banners as $k => $v) {
$banners[$k]['main_pair'] = fn_get_image_pairs($v['banner_image_id'], 'promo', 'M', true, false, $lang_code);
}
fn_set_hook('get_banners_post', $banners, $params);
return array($banners, $params);
}
示例11: fn_hot_deals_block_get_products
function fn_hot_deals_block_get_products($params, $fields, $sortings, $condition, $join, $sorting, $group_by)
{
if (!empty($params['hot_deals'])) {
$fields[] = '?:category_descriptions.category';
$join .= db_quote(" LEFT JOIN ?:category_descriptions ON ?:category_descriptions.category_id=products_categories.category_id AND products_categories.link_type = 'M' AND ?:category_descriptions.lang_code = ?s", CART_LANGUAGE);
$condition .= " AND products_categories.link_type = 'M'";
}
}
示例12: location_set_address
function location_set_address($address, $user_id = false)
{
if (!$user_id) {
$user_id = user_id();
}
$result = db_query("UPDATE users SET address = '" . db_quote($address) . "', impossible = '0', sweep_ts = NULL, inaccurate = '0',\n\t\tsent_email = '0', sent_sms = '0' WHERE id = '" . (int) $user_id . "' LIMIT 1;");
return $result;
}
示例13: fn_is_email_exists
function fn_is_email_exists($email)
{
$condition = db_quote(" (?p ) ", db_quote('email = ?s', $email));
//$condition .= db_quote(" AND user_id != ?i", $user_id);
// fn_set_hook('user_exist', $user_id, $user_data, $condition);
$is_exist = db_get_field("SELECT user_id FROM ?:users WHERE {$condition}");
//var_dump($is_exist); die();
return $is_exist;
}
示例14: fn_import_feature_variant
function fn_import_feature_variant($data, $options, &$processed_data, &$skip_record)
{
static $features;
$skip_record = true;
$variant = reset($data);
if (empty($variant['Feature name'])) {
return false;
}
$langs = array_keys($data);
$main_lang = reset($langs);
array_walk($variant, 'fn_trim_helper');
if (!empty($variant['Feature group'])) {
$feature_group = fn_exim_get_feature_data_by_name($variant['Feature group'], '');
$variant['parent_id'] = $feature_group['feature_id'];
} else {
$variant['Feature group'] = '';
$variant['parent_id'] = 0;
}
$feature = fn_exim_get_feature_data_by_name($variant['Feature name'], $variant['Feature group']);
if (empty($feature)) {
$processed_data['S']++;
return false;
}
$feature_id = $feature['feature_id'];
$company_id = $feature['company_id'];
if (Registry::get('runtime.company_id') && Registry::get('runtime.company_id') != $company_id) {
$processed_data['S']++;
return false;
}
if (!isset($features)) {
list($features) = fn_get_product_features(array('plain' => true), 0, $main_lang);
}
if (!empty($feature_id)) {
if (isset($variant['variant_id'])) {
$variant_id = db_get_field('SELECT variant_id FROM ?:product_feature_variants WHERE variant_id = ?i', $variant['variant_id']);
}
if (empty($variant_id)) {
$join = db_quote('INNER JOIN ?:product_feature_variants fv ON fv.variant_id = fvd.variant_id');
$variant_id = db_get_field("SELECT fvd.variant_id FROM ?:product_feature_variant_descriptions AS fvd {$join} WHERE variant = ?s AND feature_id = ?i", $variant['variant'], $feature_id);
}
$new_variant_id = fn_update_product_feature_variant($feature_id, $features[$feature_id]['feature_type'], $variant, $main_lang);
if ($variant_id == $new_variant_id) {
$processed_data['E']++;
} else {
$processed_data['N']++;
$variant_id = $new_variant_id;
}
foreach ($data as $lang_code => $variant) {
fn_update_product_feature_variant($feature_id, $features[$feature_id]['feature_type'], $variant, $lang_code);
}
if (!empty($variant['image_id'])) {
fn_import_images($options['images_path'], $variant['image_id'], '', 0, 'V', $variant_id, 'feature_variant');
}
}
return $variant_id;
}
示例15: getExtraCondition
public function getExtraCondition($params)
{
$condition = [];
$table_name = $this->getTableName();
$company_id = 0;
if (fn_allowed_for('ULTIMATE') && ($company_id = Registry::get('runtime.company_id'))) {
$condition[] = db_quote("{$table_name}.company_id = ?i", $company_id);
}
return $condition;
}