本文整理匯總了PHP中JCckDatabase::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP JCckDatabase::execute方法的具體用法?PHP JCckDatabase::execute怎麽用?PHP JCckDatabase::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JCckDatabase
的用法示例。
在下文中一共展示了JCckDatabase::execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: g_onCCK_PaymentValidate
public static function g_onCCK_PaymentValidate($data, $success, &$config)
{
$update = 'pay_return = "' . JCckDatabase::escape(json_encode($data['order'])) . '",' . 'pay_return_payments = "' . JCckDatabase::escape(json_encode($data['payments'])) . '",' . 'state = ' . $data['order_state'];
JCckDatabase::execute('UPDATE #__cck_more_ecommerce_orders SET ' . $update . ' WHERE pay_key = "' . $config['pay_key'] . '"');
if (!$success) {
return;
}
// Cart
$cart_id = (int) JCckDatabase::loadResult('SELECT a.id FROM #__cck_more_ecommerce_carts AS a WHERE a.pay_key = "' . $config['pay_key'] . '"');
if ($cart_id) {
JCckDatabase::execute('UPDATE #__cck_more_ecommerce_carts SET pay_key = "" WHERE id = ' . $cart_id);
JCckDatabase::execute('DELETE a.* FROM #__cck_more_ecommerce_cart_product AS a WHERE a.cart_id = ' . $cart_id);
}
// Execute Processings (Invoice, Notifications, ...)
if (JCckToolbox::getConfig()->get('processing', 0)) {
$event = 'onCckPaymentSuccess';
$processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile, options FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type');
if (isset($processing[$event])) {
foreach ($processing[$event] as $p) {
if (is_file(JPATH_SITE . $p->scriptfile)) {
$options = new JRegistry($p->options);
include_once JPATH_SITE . $p->scriptfile;
}
}
}
}
}
示例2: batchFolder
public function batchFolder($pks, $type)
{
$app = JFactory::getApplication();
$folder = $app->input->getInt('batch_folder', 0);
if (!$folder) {
return false;
}
return JCckDatabase::execute('UPDATE #__cck_core_' . $type . ' SET folder = ' . $folder . ' WHERE id IN (' . $pks . ')');
}
示例3: 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');
}
}
示例4: load
public function load($pk = null, $force = false)
{
$return = parent::load($pk);
$k = $this->_tbl_key;
if (!$return) {
if ($force === true) {
JCckDatabase::execute('INSERT INTO ' . $this->_tbl . ' (' . $k . ') VALUES (' . (int) $pk . ')');
$return = parent::load($pk);
}
}
return $return;
}
示例5: postSaveHook
protected function postSaveHook(CCKModelSite &$model, $validData = array())
{
$recordId = $model->getState($this->context . '.id');
if ($recordId == 10 || $recordId == 500) {
$db = JFactory::getDbo();
$params = JCckDatabase::loadResult('SELECT params FROM #__extensions WHERE element = "com_cck"');
$config = JCckDev::fromJSON($params, 'object');
$config->multisite = 1;
$params = $db->escape(JCckDev::toJSON($config));
JCckDatabase::execute('UPDATE #__extensions SET params = "' . $params . '" WHERE element = "com_cck"');
}
}
示例6: delete
public function delete($pk = null)
{
if ($this->id) {
$clients = array('search', 'filter', 'list', 'item');
foreach ($clients as $client) {
$Pf = 'template_' . $client;
$style = JCckDatabase::loadObject('SELECT a.id, a.template FROM #__template_styles AS a' . ' WHERE a.template IN ( SELECT b.template FROM #__template_styles as b WHERE b.id = ' . (int) $this->{$Pf} . ' )' . ' ORDER BY a.id');
if ($style->id != $this->{$Pf}) {
JCckDatabase::execute('DELETE a.* FROM #__template_styles AS a WHERE a.id=' . (int) $this->{$Pf});
}
}
JCckDatabase::execute('DELETE IGNORE a.*, b.*' . ' FROM #__cck_core_search_field AS a' . ' LEFT JOIN #__cck_core_search_position AS b ON b.searchid = a.searchid' . ' WHERE a.searchid=' . (int) $this->id);
}
return parent::delete();
}
示例7: 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();
}
示例8: revert
public function revert($pk, $type)
{
$db = $this->getDbo();
$table = $this->getTable();
if (!$pk || !$type) {
return false;
}
$table->load($pk);
if (JCck::getConfig_Param('version_revert', 1) == 1) {
Helper_Version::createVersion($type, $table->e_id, JText::sprintf('COM_CCK_VERSION_AUTO_BEFORE_REVERT', $table->e_version));
}
$row = JTable::getInstance($type, 'CCK_Table');
$row->load($table->e_id);
$core = JCckDev::fromJSON($table->e_core);
if (isset($row->asset_id) && $row->asset_id && isset($core['rules'])) {
JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($core['rules']) . '" WHERE id = ' . (int) $row->asset_id);
}
// More
if ($type == 'search') {
$clients = array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order');
} else {
$clients = array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
}
foreach ($clients as $i => $client) {
$name = 'e_more' . $i;
$this->_revert_more($type, $client, $table->e_id, $table->{$name});
}
// Override
if ($row->version && $row->version != $table->e_version) {
$core['version'] = ++$row->version;
}
$core['checked_out'] = 0;
$core['checked_out_time'] = '0000-00-00 00:00:00';
$row->bind($core);
$row->check();
$row->store();
return true;
}
示例9: _download_hits
protected function _download_hits($id, $fieldname, $collection = '', $x = 0)
{
$where = 'a.id = ' . (int) $id . ' AND a.field = "' . (string) $fieldname . '" AND a.collection = "' . (string) $collection . '" AND a.x = ' . (int) $x;
$hits = JCckDatabase::loadResult('SELECT a.hits FROM #__cck_core_downloads AS a WHERE ' . $where);
if (!$hits) {
JCckDatabase::execute('INSERT INTO #__cck_core_downloads(`id`, `field`, `collection`, `x`, `hits`) VALUES(' . (int) $id . ', "' . (string) $fieldname . '", "' . (string) $collection . '", ' . (int) $x . ', 1)');
} else {
$hits++;
JCckDatabase::execute('UPDATE #__cck_core_downloads AS a SET a.hits = ' . (int) $hits . ' WHERE ' . $where . ' AND a.id = ' . (int) $id);
}
return $hits;
}
示例10: 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;');
}
}
}
}
}
示例11: onCCK_Storage_LocationSearch
public function onCCK_Storage_LocationSearch($type, $tables, $fields, $fields_order, &$config, &$inherit, &$results)
{
if (self::$type != $type) {
return;
}
if ($config['doQuery'] === false && isset($config['query']) && $config['query']) {
if (isset($config['query_variables']) && count($config['query_variables'])) {
foreach ($config['query_variables'] as $var) {
if ($var != '') {
JCckDatabase::execute($var);
}
}
}
$results = JCckDatabase::loadObjectList($config['query']);
$inherit['query'] = $config['query'];
unset($config['query']);
}
}
示例12: onCCK_FieldAfterStore
public static function onCCK_FieldAfterStore($process, &$fields, &$storages, &$config = array())
{
$table = '#__cck_store_join_' . $process['name'];
$value = $process['value'];
static $bool = 1;
if ($bool == 1) {
$bool = 0;
JCckDatabase::execute('DELETE a.* FROM ' . $table . ' AS a WHERE a.id = ' . (int) $config['pk']);
}
if ($value > 0) {
JCckDatabase::execute('INSERT IGNORE INTO ' . $table . ' VALUES (' . (int) $config['pk'] . ', ' . $value . ')');
}
}
示例13: revert
public static function revert($type, $pk, $version = 0)
{
require_once JPATH_ADMINISTRATOR . '/components/com_cck/tables/version.php';
require_once JPATH_ADMINISTRATOR . '/components/com_cck/tables/' . $type . '.php';
$db = JFactory::getDbo();
$pkv = JCckDatabase::loadResult('SELECT id FROM #__cck_core_versions WHERE e_type ="' . $type . '" AND e_version = ' . $version . ' AND e_id = ' . $pk);
$table = JTable::getInstance('Version', 'CCK_Table');
$table->load($pkv);
$row = JTable::getInstance(ucfirst($type), 'CCK_Table');
$row->load($pk);
$core = JCckDev::fromJSON($table->e_core);
if (isset($row->asset_id) && $row->asset_id && isset($core['rules'])) {
JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($core['rules']) . '" WHERE id = ' . (int) $row->asset_id);
}
// More
if ($type == 'search') {
$clients = array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order');
} else {
$clients = array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
}
foreach ($clients as $i => $client) {
$name = 'e_more' . $i;
self::revert_more($type, $client, $pk, $table->{$name});
}
// --
if ($row->version && $row->version != $table->e_version) {
$core['version'] = ++$row->version;
}
$row->bind($core);
$row->check();
$row->store();
}
示例14: prepareData
protected function prepareData()
{
$data = JRequest::get('post');
$data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
if ($data['mode']) {
$data['featured'] = 0;
} else {
if ($data['featured']) {
JCckDatabase::execute('UPDATE #__cck_core_templates SET featured = 0 WHERE id');
} else {
if (!JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core_templates WHERE featured = 1 AND id != ' . (int) $data['id'])) {
$data['featured'] = 1;
}
}
}
return $data;
}
示例15: g_isMax
public function g_isMax($author_id, $parent_id, $config = array())
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$typeId = JCckDatabase::loadResult('SELECT id FROM #__cck_core_types WHERE name ="' . $config['type'] . '"');
jimport('cck.joomla.access.access');
$max_parent_author = (int) CCKAccess::check($user->id, 'core.create.max.parent.author', 'com_cck.form.' . $typeId);
$max_parent = (int) CCKAccess::check($user->id, 'core.create.max.parent', 'com_cck.form.' . $typeId);
$max_author = (int) CCKAccess::check($user->id, 'core.create.max.author', 'com_cck.form.' . $typeId);
if ($max_parent_author > 0) {
$count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND parent_id = ' . $parent_id . ' AND author_id = ' . $author_id);
if ($count >= $max_parent_author) {
JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
$app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_PARENT_AUTHOR'), 'error');
$config['error'] = true;
return 1;
}
}
if ($max_parent > 0) {
$count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND parent_id = ' . $parent_id);
if ($count >= $max_parent) {
JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
$app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_PARENT'), 'error');
$config['error'] = true;
return 1;
}
}
if ($max_author > 0) {
$count = JCckDatabase::loadResult('SELECT COUNT(id) FROM #__cck_core WHERE cck="' . $config['type'] . '" AND author_id = ' . $author_id);
if ($count >= $max_author) {
JCckDatabase::execute('DELETE FROM #__cck_core WHERE id = ' . (int) $config['id']);
$app->enqueueMessage(JText::_('COM_CCK_ERROR_MAX_AUTHOR'), 'error');
$config['error'] = true;
return 1;
}
}
return 0;
}