예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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());
             }
         }
     }
 }
예제 #3
0
 /**
  * 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);
 }
예제 #4
0
 /**
  * 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__);
 }
예제 #5
0
 /**
  * Set internal mysql value
  * TODO remove this hack
  */
 protected function _setBigSelects()
 {
     $this->_db->setQuery('SET SQL_BIG_SELECTS = 1')->execute();
 }