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(); }
/** * 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()); } } } }
/** * Builds the XML structure to export. * * @return array An array of XML lines (strings). * * @since 11.1 * @throws Exception if an error occurs. */ protected function buildXmlStructure() { $buffer = array(); $query = $this->db->getQuery(true); foreach ($this->from as $table) { // Replace the magic prefix if found. $table = $this->getGenericTableName($table); /* * Table structure */ // Get the details columns information. $fields = $this->db->getTableColumns($table, false); $keys = $this->db->getTableKeys($table); $buffer[] = ' <table_structure name="' . $table . '">'; foreach ($fields as $field) { $buffer[] = ' <field' . ' Field="' . $field->Field . '"' . ' Type="' . $field->Type . '"' . ' Null="' . $field->Null . '"' . ' Key="' . $field->Key . '"' . (isset($field->Default) ? ' Default="' . $field->Default . '"' : '') . ' Extra="' . $field->Extra . '"' . ' Comment="' . htmlspecialchars($field->Comment) . '"' . ' />'; } foreach ($keys as $key) { $buffer[] = ' <key' . ' Table="' . $table . '"' . ' Non_unique="' . $key->Non_unique . '"' . ' Key_name="' . $key->Key_name . '"' . ' Seq_in_index="' . $key->Seq_in_index . '"' . ' Column_name="' . $key->Column_name . '"' . ' Collation="' . $key->Collation . '"' . ' Null="' . $key->Null . '"' . ' Index_type="' . $key->Index_type . '"' . ' Comment="' . htmlspecialchars($key->Comment) . '"' . ' />'; } $buffer[] = ' </table_structure>'; /* * Table data */ if (!$this->options->get('with-data')) { continue; } $query->clear()->from($this->db->quoteName($table))->select('*'); $rows = $this->db->setQuery($query)->loadObjectList(); $buffer[] = ' <table_data name="' . $table . '">'; foreach ($rows as $row) { $buffer[] = ' <row>'; foreach ($row as $fieldName => $fieldValue) { $buffer[] = ' <field' . ' name="' . $fieldName . '">' . htmlspecialchars($fieldValue) . '</field>'; } $buffer[] = ' </row>'; } $buffer[] = ' </table_data>'; } return $buffer; }
/** * Test the JDatabaseMySQL::query() method * * @return void * * @since 11.1 */ public function testQuery() { $this->object->setQuery("REPLACE INTO `jos_dbtest` SET `id` = 5, `title` = 'testTitle'"); $this->assertThat($this->object->query(), $this->isTrue(), __LINE__); $this->assertThat($this->object->insertid(), $this->equalTo(5), __LINE__); }
# @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: $one_item_array = explode(':', $one_item); if ($one_item_array[1] == 'false') {