/** * Load log types and prepare them as an array with options. * * <code> * $filters = new CrowdFundingFilters(JFactory::getDbo()); * $options = $filters->getLogTypes(); * </code> * * @return array */ public function getLogTypes() { $query = $this->db->getQuery(true); $query->select("a.type AS value, a.type AS text")->from($this->db->quoteName("#__crowdf_logs", "a"))->group("a.type"); $this->db->setQuery($query); $types = $this->db->loadAssocList(); if (!$types) { $types = array(); } return $types; }
/** * Merges the incoming structure definition with the existing structure. * * @return void * * @since 11.1 * * @throws Exception on error. * @note Currently supports XML format only. * @todo IF it is not in XML format, convert it first. */ protected function mergeStructure() { // Currently only support XML format anyway. // 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()); } } } }
/** * Sets the SQL query string for later execution. * * @param string $sql * @return void */ public function setQuery($sql) { $sql = str_replace('spdb', $this->prefix . 'sobipro', $sql); $sql = str_replace('NOW()', '\'' . gmdate(Sobi::Cfg('date.db_format', 'Y-m-d H:i:s')) . '\'', $sql); return $this->db->setQuery($sql); }
/** * Test the JDatabaseMySQLi::query() method * * @return void * * @since 11.4 */ 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__); }
/** * Set internal mysql value * TODO remove this hack */ protected function _setBigSelects() { $this->_db->setQuery('SET SQL_BIG_SELECTS = 1')->execute(); }