Пример #1
0
 /**
  * Get the generic name of the table, converting the database prefix to the wildcard string.
  *
  * @param   string  $table  The name of the table.
  *
  * @return  string  The name of the table with the database prefix replaced with #__.
  *
  * @since   12.1
  */
 protected function getGenericTableName($table)
 {
     // TODO Incorporate into parent class and use $this.
     $prefix = $this->db->getPrefix();
     // Replace the magic prefix if found.
     $table = preg_replace("|^{$prefix}|", '#__', $table);
     return $table;
 }
Пример #2
0
 /**
  * Merges the incoming structure definition with the existing structure.
  *
  * @return  void
  *
  * @note    Currently only supports XML format.
  * @since   12.1
  * @throws  Exception on error.
  * @todo    If it's not XML convert to XML first.
  */
 protected function mergeStructure()
 {
     // Initialise variables.
     $prefix = $this->db->getPrefix();
     $tables = $this->db->getTableList();
     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);
                     try {
                         $this->db->execute();
                     } catch (RuntimeException $e) {
                         $this->addLog('Fail: ' . $this->db->getQuery());
                         throw $e;
                     }
                     $this->addLog('Pass: '******'Fail: ' . $this->db->getQuery());
                 throw $e;
             }
             $this->addLog('Pass: ' . $this->db->getQuery());
         }
     }
 }
 /**
  * Test Test method - there really isn't a lot to test here, but
  * this is present for the sake of completeness
  *
  * @return   void
  */
 public function testTest()
 {
     $this->assertTrue(JDatabaseDriverPostgresql::test());
 }
 /**
  * Test Test method - there really isn't a lot to test here, but
  * this is present for the sake of completeness
  *
  * @return   void
  */
 public function testTest()
 {
     $this->assertThat(JDatabaseDriverPostgresql::test(), $this->isTrue(), __LINE__);
 }