示例#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
 /**
  * Test loadRowList method
  *
  * @return  void
  *
  * @since   11.4
  */
 public function testLoadRowList()
 {
     $query = $this->object->getQuery(true);
     $query->select('*');
     $query->from('jos_dbtest');
     $query->where('description=' . $this->object->quote('one'));
     $this->object->setQuery($query);
     $result = $this->object->loadRowList();
     $expected = array(array(1, 'Testing', '1980-04-18 00:00:00', 'one'), array(2, 'Testing2', '1980-04-18 00:00:00', 'one'));
     $this->assertThat($result, $this->equalTo($expected), __LINE__);
 }
示例#3
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());
             }
         }
     }
 }
示例#4
0
 /**
  * Returns current query
  *
  * @return string
  */
 public function getQuery()
 {
     return str_replace($this->prefix, $this->db->getPrefix(), $this->db->getQuery());
 }