/** * Set documents as favorite/unfavorite * * @param array $ids documents IDs * @param int $value value use constantS JOOMDOC_FAVORITE/JOOMDOC_STANDARD to set as favorite/unfavorite * @return int num of affected rows */ function setFavorite($ids, $value) { if (count($ids)) { JArrayHelper::toInteger($ids); $this->_db->setQuery(sprintf('UPDATE `#__joomdoc` SET `favorite` = %d WHERE `id` IN (%s)', $value, implode(', ', $ids))); $this->_db->query(); JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_PREFIX)->flat(null, $ids); return $this->_db->getAffectedRows(); } return 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()); } } } }
/** * 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__); }
# 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') { // saving the new order