示例#1
0
 /**
  * This function replaces a string identifier <var>$prefix</var> with the
  * string held is the <var>_table_prefix</var> class variable.
  *
  * @param	string	The SQL query
  * @param	string	The common table prefix
  */
 public function replacePrefix($sql, $prefix = '#__')
 {
     $app = JFactory::getApplication();
     $package = $app->getUserStateFromRequest('com_fabrik.package', 'package', 'fabrik');
     $sql = str_replace('{package}', $package, $sql);
     return parent::replacePrefix($sql, $prefix);
 }
示例#2
0
 /**
  * Execute the SQL statement.
  *
  * @param   boolean  $replacePrefixQuotes  Replace the prefixes inside the quotes too
  *
  * @return  mixed  A database cursor resource on success, boolean false on failure.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function execute($replacePrefixQuotes = false)
 {
     if ($replacePrefixQuotes) {
         $this->sql = $this->replacePrefix((string) $this->sql, '#__', $replacePrefixQuotes);
     }
     return parent::execute();
 }
 /**
  * Get the generic name of the table, converting the database prefix to the wildcard string.
  *
  * @param   string  $table  The name of the table.
  *
  * @return  string  The name of the table with the database prefix replaced with #__.
  *
  * @since   11.1
  */
 protected function getGenericTableName($table)
 {
     // TODO Incorporate into parent class and use $this.
     $prefix = $this->db->getPrefix();
     // Replace the magic prefix if found.
     $table = preg_replace("|^{$prefix}|", '#__', $table);
     return $table;
 }
示例#4
0
 function searchPaths($paths)
 {
     if (count($paths)) {
         $this->_db->setQuery('SELECT DISTINCT `path` FROM `#__joomdoc_file` WHERE `path` IN (' . implode(', ', array_map(array($this->_db, 'quote'), $paths)) . ')');
         return $this->_db->loadColumn();
     }
     return array();
 }
示例#5
0
 /**
  * Merges the incoming structure definition with the existing structure.
  *
  * @return  void
  *
  * @since   11.1
  *
  * @throws  Exception on error.
  * @note    Currently only supports XML format.
  * @todo    If it's not XML convert to XML first.
  */
 protected function mergeStructure()
 {
     // Initialise variables.
     $prefix = $this->db->getPrefix();
     $tables = $this->db->getTableList();
     $result = true;
     if ($this->from instanceof SimpleXMLElement) {
         $xml = $this->from;
     } else {
         $xml = new SimpleXMLElement($this->from);
     }
     // Get all the table definitions.
     $xmlTables = $xml->xpath('database/table_structure');
     foreach ($xmlTables as $table) {
         // Convert the magic prefix into the real table name.
         $tableName = (string) $table['name'];
         $tableName = preg_replace('|^#__|', $prefix, $tableName);
         if (in_array($tableName, $tables)) {
             // The table already exists. Now check if there is any difference.
             if ($queries = $this->getAlterTableSQL($xml->database->table_structure)) {
                 // Run the queries to upgrade the data structure.
                 foreach ($queries as $query) {
                     $this->db->setQuery((string) $query);
                     if (!$this->db->query()) {
                         $this->addLog('Fail: ' . $this->db->getQuery());
                         throw new Exception($this->db->getErrorMsg());
                     } else {
                         $this->addLog('Pass: '******'Fail: ' . $this->db->getQuery());
                 throw new Exception($this->db->getErrorMsg());
             } else {
                 $this->addLog('Pass: ' . $this->db->getQuery());
             }
         }
     }
 }
示例#6
0
 /**
  * Execute a batch query
  *
  * @abstract
  * @access public
  * @return mixed A database resource if successful, FALSE if not.
  */
 function query_batch($abort_on_error = true, $p_transaction_safe = false)
 {
     return parent::queryBatch($abort_on_error, $p_transaction_safe);
 }
 /**
  * Test Test method - there really isn't a lot to test here, but
  * this is present for the sake of completeness
  */
 public function testTest()
 {
     $this->assertThat(JDatabaseMySQL::test(), $this->isTrue(), __LINE__);
 }
示例#8
0
文件: saveOrderG.php 项目: JozefAB/qk
# author    iJoomla
# copyright Copyright (C) 2013 ijoomla.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.ijoomla.com
# Technical Support:  Forum - http://www.ijoomla.com/forum/index/
-------------------------------------------------------------------------*/
$items = explode(",", $_GET['saveString']);
define('_JEXEC', 1);
define('JPATH_BASE', 1);
include_once "../../../../../../configuration.php";
include_once "../../../../../../libraries/joomla/base/object.php";
include_once "../../../../../../libraries/joomla/database/database.php";
include_once "../../../../../../libraries/joomla/database/database/mysql.php";
$config = new JConfig();
$options = array("host" => $config->host, "user" => $config->user, "password" => $config->password, "database" => $config->db, "prefix" => $config->dbprefix);
$database = new JDatabaseMySQL($options);
$sql = " SELECT id, days, tasks FROM #__guru_programstatus WHERE pid = 27 ";
$database->setQuery($sql);
if (!$database->query()) {
    echo $database->stderr();
    return;
}
$ids = $database->loadObject();
$the_old_day_order = $ids->days;
$the_old_day_order = explode(';', $the_old_day_order);
$the_old_task_order = $ids->tasks;
$the_old_task_order = explode(';', $the_old_task_order);
$new_daystatus_order = '';
$new_taskstatus_order = '';
foreach ($items as $one_item) {
    //one_item looks like this ->  6-0:false:202: