本文整理匯總了PHP中JCckDatabase::quoteName方法的典型用法代碼示例。如果您正苦於以下問題:PHP JCckDatabase::quoteName方法的具體用法?PHP JCckDatabase::quoteName怎麽用?PHP JCckDatabase::quoteName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JCckDatabase
的用法示例。
在下文中一共展示了JCckDatabase::quoteName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: alterTableAddColumn
public static function alterTableAddColumn($table, $column, $column_prev = '', $type = 'VARCHAR(50)')
{
$db = JFactory::getDbo();
$columns = $db->getTableColumns($table);
if ($column_prev != '' && $column != $column_prev) {
if (!isset($columns[$column])) {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' CHANGE ' . JCckDatabase::quoteName($column_prev) . ' ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL');
}
} elseif (!isset($columns[$column])) {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' ADD ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL');
}
}
示例2: delete
public function delete($pk = null)
{
if ($this->id) {
if (strpos($this->storage_table, '#__cck_store_item_') !== false || strpos($this->storage_table, '#__cck_store_form_') !== false) {
if (!$this->storage_field2) {
$db = JFactory::getDbo();
$table = (string) $this->storage_table;
$column = $this->storage_field ? $this->storage_field : $this->name;
$columns = $db->getTableColumns($table);
if (isset($columns[$column])) {
if (JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core_fields WHERE storage_table = "' . (string) $table . '" AND storage_field = "' . (string) $column . '"') == 1) {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' DROP COLUMN ' . JCckDatabase::quoteName((string) $column));
}
}
}
}
}
return parent::delete();
}
示例3: importTables
public static function importTables($data)
{
$db = JFactory::getDbo();
$path = $data['root'] . '/tables';
if (file_exists($path)) {
$items = JFolder::files($path, '\\.xml$');
if (count($items)) {
$prefix = JFactory::getConfig()->get('dbprefix');
$tables = array_flip(JCckDatabase::loadColumn('SHOW TABLES'));
foreach ($items as $item) {
$xml = JCckDev::fromXML($path . '/' . $item);
if (!$xml || (string) $xml->attributes()->type != 'tables') {
return;
}
$name = (string) $xml->table->name;
$table_key = (string) $xml->table->primary_key;
$short = str_replace('#__', $prefix, $name);
if (isset($tables[$short])) {
$table = JCckTable::getInstance($name);
$table_fields = $table->getFields();
$previous = '';
// Fields
$fields = $xml->fields->children();
if (count($fields)) {
foreach ($fields as $field) {
$column = (string) $field;
$type = (string) $field->attributes()->type;
$default = (string) $field->attributes()->default;
if (!isset($table_fields[$column])) {
$query = 'ALTER TABLE ' . $name . ' ADD ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL';
$query .= $default != '' ? ' DEFAULT "' . $default . '"' : '';
$query .= $previous != '' ? ' AFTER ' . JCckDatabase::quoteName($previous) : ' FIRST';
JCckDatabase::execute($query);
} else {
if ($type != $table_fields[$column]->Type) {
$query = 'ALTER TABLE ' . $name . ' CHANGE ' . JCckDatabase::quoteName($column) . ' ' . JCckDatabase::quoteName($column) . ' ' . $type . ' NOT NULL';
$query .= $default != '' ? ' DEFAULT "' . $default . '"' : '';
JCckDatabase::execute($query);
}
}
$previous = $column;
}
}
// Indexes
$indexes = $xml->indexes->children();
$indexes2 = array();
if (count($indexes)) {
foreach ($indexes as $index) {
$idx = (string) $index;
$indexes2[$idx][(string) $index->attributes()->seq_in_type] = (string) $index->attributes()->column_name;
}
}
if (count($indexes2)) {
foreach ($indexes2 as $k => $v) {
if ($k == 'PRIMARY') {
JCckDatabase::execute('ALTER TABLE ' . $name . ' DROP PRIMARY KEY, ADD PRIMARY KEY ( ' . implode(',', $v) . ' )');
} else {
// todo
}
}
}
} else {
$sql_query = '';
// Fields
$fields = $xml->fields->children();
if (count($fields)) {
foreach ($fields as $field) {
$type = (string) $field->attributes()->type;
$default = (string) $field->attributes()->default;
$sql_query .= ' ' . JCckDatabase::quoteName((string) $field) . ' ' . $type . ' NOT NULL';
if ($default != '') {
$sql_query .= ' DEFAULT "' . $default . '"';
}
$sql_query .= ',';
}
}
// Indexes
$indexes = $xml->indexes->children();
$indexes2 = array();
if (count($indexes)) {
foreach ($indexes as $index) {
$idx = (string) $index;
$indexes2[$idx][(string) $index->attributes()->seq_in_type] = (string) $index->attributes()->column_name;
}
}
if (count($indexes2)) {
foreach ($indexes2 as $k => $v) {
$sql_query .= $k == 'PRIMARY' ? ' PRIMARY KEY ( ' . implode(',', $v) . ' ),' : ' KEY ' . $k . ' ( ' . implode(',', $v) . ' ),';
}
}
$sql_query = $sql_query ? substr($sql_query, 0, -1) : '';
JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $name . ' (' . $sql_query . ') ENGINE=InnoDB DEFAULT CHARSET=utf8;');
}
}
}
}
}
示例4: g_onCCK_FieldConstruct
public function g_onCCK_FieldConstruct(&$data)
{
$db = JFactory::getDbo();
$data['display'] = 3;
$data['script'] = JRequest::getVar('script', '', '', 'string', JREQUEST_ALLOWRAW);
if (isset($data['selectlabel']) && $data['selectlabel'] == '') {
$data['selectlabel'] = ' ';
}
// JSON
if (isset($data['json']) && is_array($data['json'])) {
foreach ($data['json'] as $k => $v) {
if (is_array($v)) {
if (isset($v['options'])) {
$options = array();
if (count($v['options'])) {
foreach ($v['options'] as $option) {
$options[] = $option;
}
}
$v['options'] = $options;
}
$data[$k] = JCckDev::toJSON($v);
}
}
}
// STRING
if (isset($data['string']) && is_array($data['string'])) {
foreach ($data['string'] as $k => $v) {
if (is_array($v)) {
$string = '';
foreach ($v as $s) {
if ($s != '') {
$string .= $s . '||';
}
}
if ($string) {
$string = substr($string, 0, -2);
}
$data[$k] = $string;
}
}
}
if (empty($data['storage'])) {
$data['storage'] = 'none';
}
if ($data['storage'] == 'dev') {
$data['published'] = 0;
$data['storage_location'] = '';
$data['storage_table'] = '';
} else {
// No Table for None!
if ($data['storage'] == 'none') {
$data['storage_location'] = '';
$data['storage_table'] = '';
}
// Storage Field is required!
if (!@$data['storage_field']) {
if ($data['storage'] == 'none' && $data['storage_field_prev']) {
$data['storage_field'] = $data['storage_field_prev'];
} else {
$data['storage_field'] = $data['name'];
$dev_prefix = JCck::getConfig_Param('development_prefix', '');
if ($dev_prefix) {
$data['storage_field'] = str_replace($dev_prefix . '_', '', $data['storage_field']);
}
}
}
// Storage Field2 is better for flexibility!
if ($data['storage'] != 'standard' && $data['storage_field']) {
if (($cut = strpos($data['storage_field'], '[')) !== false) {
$data['storage_field2'] = substr($data['storage_field'], $cut + 1, -1);
$data['storage_field'] = substr($data['storage_field'], 0, $cut);
} else {
$data['storage_field2'] = '';
}
}
// Un-existing Fields must be mapped!
if (!isset($data['alterTable'])) {
$data['alterTable'] = true;
}
if ($data['storage_location'] == '' && $data['storage_table'] == '') {
$data['storage'] = 'none';
}
if ($data['alterTable']) {
$data['storage_alter_type'] = isset($data['storage_alter_type']) && $data['storage_alter_type'] ? $data['storage_alter_type'] : 'VARCHAR(255)';
$alter = isset($data['storage_alter']) && $data['storage_alter'] && in_array(1, $data['storage_alter']);
if (isset($data['storage_alter_table']) && $data['storage_alter_table'] && $alter) {
if ($data['storage_table'] && $data['storage_field']) {
$columns = $db->getTableColumns($data['storage_table']);
if (!isset($columns[$data['storage_field']])) {
if ($data['storage_alter_table'] == 2 && $data['storage_field_prev'] != '') {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field_prev']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
} else {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
}
} else {
JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
}
}
} else {
//.........這裏部分代碼省略.........
示例5: postflight
//.........這裏部分代碼省略.........
$live_type = 'url_variable';
$live_options = '{"variable":"' . $l->live_value . '","type":"string"}';
}
if (!JCckDatabase::doQuery('UPDATE #__cck_core_search_field SET live = "' . $live_type . '", live_options = "' . $db->escape($live_options) . '" WHERE searchid = ' . $l->searchid . ' AND fieldid = ' . $l->fieldid . ' AND client = "' . $l->client . '"')) {
$bool = false;
}
}
}
if ($bool) {
JCckDatabase::doQuery('UPDATE #__extensions SET enabled = 0 WHERE element IN ("url_var_int","url_var_string","user_profile") AND folder = "cck_field_live"');
}
}
if ($i2 < 25) {
$table = JTable::getInstance('asset');
$table->loadByName('com_cck');
if ($table->rules) {
$rules = (array) json_decode($table->rules);
$rules['core.delete.own'] = array(6 => "1");
$table->rules = json_encode($rules);
$table->store();
}
}
if ($i2 < 31) {
$src = JPATH_ADMINISTRATOR . '/components/com_cck/install/src/tmp/joomla_message';
if (JFolder::exists($src)) {
JFolder::copy($src, JPATH_SITE . '/plugins/cck_storage_location/joomla_message', '', true);
}
}
if ($i2 < 33) {
$folders = array(10, 11, 12, 13, 14);
foreach ($folders as $folder) {
Helper_Folder::rebuildBranch($folder);
}
}
if ($i2 < 35) {
$objects = array('joomla_article' => 'article', 'joomla_category' => 'category', 'joomla_user' => 'user', 'joomla_user_group' => 'user_group');
foreach ($objects as $k => $v) {
$params = JCckDatabase::loadResult('SELECT options FROM #__cck_core_objects WHERE name = "' . $k . '"');
$params = json_decode($params);
$params->default_type = JCck::getConfig_Param('integration_' . $v, '');
$params->add_redirect = $params->default_type != '' ? '1' : '0';
$params->edit = JCck::getConfig_Param('integration_' . $v . '_edit', '0');
if ($k == 'joomla_category') {
$params->exclude = JCck::getConfig_Param('integration_' . $v . '_exclude', '');
}
JCckDatabase::doQuery('UPDATE #__cck_core_objects SET options = "' . $db->escape(json_encode($params)) . '" WHERE name = "' . $k . '"');
}
}
if ($i2 < 45) {
$table = '#__cck_store_item_users';
$columns = $db->getTableColumns($table);
if (isset($columns['password2'])) {
JCckDatabase::doQuery('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' DROP ' . JCckDatabase::quoteName('password2'));
}
}
if ($i2 < 66) {
$path = JPATH_ADMINISTRATOR . '/components/com_cck/download.php';
if (JFile::exists($path)) {
JFile::delete($path);
}
}
if ($i2 < 70) {
$plg_image = JPluginHelper::getPlugin('cck_field', 'upload_image');
$plg_params = new JRegistry($plg_image->params);
$com_cck = JComponentHelper::getComponent('com_cck');
$com_cck->params->set('media_quality_jpeg', $plg_params->get('quality_jpeg', '90'));
$com_cck->params->set('media_quality_png', $plg_params->get('quality_png', '3'));
JCckDatabase::doQuery('UPDATE #__extensions SET params = "' . $db->escape($com_cck->params->toString()) . '" WHERE type = "component" AND element = "com_cck"');
}
// Folder Tree
Helper_Folder::rebuildTree(2, 1);
}
// Overrides
$path = JPATH_ADMINISTRATOR . '/components/com_cck/install/src';
if (JFolder::exists($path)) {
$folders = JFolder::folders($path, '^joomla');
$folders = array_reverse($folders);
$count = count($folders);
foreach ($folders as $folder) {
$version = str_replace('joomla', '', $folder);
if (version_compare(JVERSION, $version, 'lt')) {
$path .= '/' . $folder;
$len = strlen($path);
$items = JFolder::files($path, '.', true, true, array('index.html'));
if (count($items)) {
foreach ($items as $item) {
$dest = JPATH_SITE . substr($item, $len);
JFile::copy($item, $dest);
}
}
break;
}
}
}
// Tmp
$path = JPATH_ADMINISTRATOR . '/components/com_cck/install/src/tmp';
if (JFolder::exists($path)) {
JFolder::delete($path);
}
}