/**
  * getCreateTable
  *
  * @param $table
  *
  * @return array|mixed|string
  */
 protected function getCreateTable($table)
 {
     $db = $this->db;
     $result = $db->setQuery($this->queryHelper->showCreateTable($table))->loadRow();
     $sql = preg_replace('#AUTO_INCREMENT=\\S+#is', '', $result[1]);
     $sql = explode("\n", $sql);
     $tableStriped = TableHelper::stripPrefix($result[0], $db->getPrefix());
     $sql[0] = str_replace($result[0], $tableStriped, $sql[0]);
     $sql = implode("\n", $sql);
     return $sql;
 }
Beispiel #2
0
 /**
  * setTrack
  *
  * @param        $tables
  * @param string $status
  *
  * @return void
  */
 public function setTrack($tables, $status = 'all')
 {
     $db = \JFactory::getDbo();
     $prefix = $db->getPrefix();
     $tables = (array) $tables;
     $track = $this->getTrackList();
     foreach ($tables as $table) {
         $table = TableHelper::stripPrefix($table, $prefix);
         $track->set('table.' . $table, $status);
     }
     $this->saveTrackList($track);
 }
Beispiel #3
0
 /**
  * stripPrefix
  *
  * @param $table
  *
  * @return string
  */
 protected function stripPrefix($table)
 {
     return TableHelper::stripPrefix($table, $this->prefix);
 }
 /**
  * getCreateTable
  *
  * @param $table
  *
  * @return mixed
  */
 protected function getCreateTable($table)
 {
     $db = $this->db;
     $columns = $db->setQuery('SHOW FULL COLUMNS FROM ' . $db->quoteName($db->escape($table)))->loadAssocList('Field');
     $indexes = $db->setQuery("SHOW INDEX FROM `{$table}`")->loadAssocList();
     // Handle column details
     foreach ($columns as &$column) {
         /* // Unsigned
         			if (strpos($column['Type'], 'unsigned'))
         			{
         				$column['Unsigned'] = true;
         				$column['Type'] = substr($column['Type'], 0, -9);
         			}
         			else
         			{
         				$column['Unsigned'] = false;
         			}*/
         /*
         // Type and length
         $match = array();
         
         if (preg_match('/^(.*)\((.*)\)$/', $column['Type'], $match))
         {
         	$column['Type']   = $match[1];
         	$column['Length'] = $match[2];
         }
         */
         $column['From'] = array($column['Field']);
         unset($column['Key']);
         unset($column['Privileges']);
         // unset($column['Extra']);
         unset($column['Collation']);
     }
     // Handle index details
     foreach ($indexes as &$index) {
         unset($index['Model']);
         unset($index['Collation']);
         unset($index['Cardinality']);
         // unset($index['Sub_part']);
         unset($index['Packed']);
         unset($index['Index_type']);
         $index['Table'] = TableHelper::stripPrefix($index['Table']);
     }
     $result['name'] = $table;
     $result['from'] = array($table);
     $result['columns'] = $columns;
     $result['index'] = $indexes;
     // $sql = preg_replace('#AUTO_INCREMENT=\S+#is', '', $result[1]);
     return $result;
 }