public function loadTable($name) { $conn = $this->getDbConnection(); if ($conn->getCompanyId() > 0) { $this->_dbname = $conn->getDbName(); $name = $this->_dbname . '.' . $name; } return parent::loadTable($name); }
/** * Adds support for replacing default arguments. * @param type $type */ public function getColumnType($type) { if (preg_match('/^([[:alpha:]]+)\\s*(\\(.+?\\))(.*)$/', $type, $matches)) { $baseType = parent::getColumnType($matches[1] . ' ' . $matches[3]); $param = $matches[2]; $result = preg_replace('/\\(.+?\\)/', $param, $baseType, 1); } else { $result = parent::getColumnType($type); } return $result; }
/** * Adds support for replacing default arguments. * @param string $type * @return string */ public function getColumnType($type) { if (isset($this->columnTypes[$type])) { // Direct : get it $sResult = $this->columnTypes[$type]; } elseif (preg_match('/^([a-zA-Z ]+)\\((.+?)\\)(.*)$/', $type, $matches)) { // With params : some test to do $baseType = parent::getColumnType($matches[1]); if (preg_match('/^([a-zA-Z ]+)\\((.+?)\\)(.*)$/', $baseType, $baseMatches)) { // Replace the default Yii param $sResult = preg_replace('/\\(.+\\)/', "(" . $matches[2] . ")", parent::getColumnType($matches[1] . " " . $matches[3])); } else { // Get the base type and join $sResult = join(" ", array($baseType, "(" . $matches[2] . ")", $matches[3])); } } else { $sResult = parent::getColumnType($type); } return $sResult; }
/** * Returns all table names in the database which start with the tablePrefix. * * @param string $schema * * @return string */ protected function findTableNames($schema = null) { if (!$schema) { $connection = $this->getDbConnection(); $likeSql = $connection->tablePrefix ? ' LIKE \'' . $connection->tablePrefix . '%\'' : ''; return $connection->createCommand()->setText('SHOW TABLES' . $likeSql)->queryColumn(); } else { return parent::findTableNames(); } }
public function createTable($table, $columns, $options = null) { $result = parent::createTable($table, $columns, $options); $result .= ' ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; return $result; }
/** * Returns all table names in the database which start with the tablePrefix. * * @access protected * @param string $schema * @return string */ protected function findTableNames($schema = null) { if (!$schema) { $likeSql = craft()->db->tablePrefix ? ' LIKE \'' . craft()->db->tablePrefix . '%\'' : ''; return craft()->db->createCommand()->setText('SHOW TABLES' . $likeSql)->queryColumn(); } else { return parent::findTableNames(); } }