" * @license GPLv2 * @package generis * */ abstract class common_persistence_sql_SchemaManager { /** * HACK to set "PDO::MYSQL_ATTR_MAX_BUFFER_SIZE" for fileupload * * @author Lionel Lecaque, lionel@taotesting.com * @param unknown $name * @param unknown $value * @throws core_kernel_persistence_Exception */ public function setAttribute($name, $value) { throw new core_kernel_persistence_Exception('setattribute only availlable for mysql pdo implementation'); } /** * @author "Lionel Lecaque, " * @return Doctrine\DBAL\Schema\AbstractSchemaManager; */ abstract protected function getSchemaManager(); /** * Returns the column names of a given table * * @access public * @author Jerome Bogaerts, * @param string table * @return array */ public function getColumnNames($table) { return $this->getSchemaManager()->listTableColumns($table); } /** * @author "Lionel Lecaque, " */ public function createSchema() { $tables = $this->getSchemaManager()->listTables(); return new \Doctrine\DBAL\Schema\Schema($tables, [], $this->getSchemaManager()->createSchemaConfig()); } /** * @author "Lionel Lecaque, " * @param unknown $schema * @param unknown $tblname * @param unknown $column * @return unknown */ public function addColumnToTable($schema, $tblname, $column) { $newSchema = clone $schema; $table = $newSchema->getTable($tblname); $table->addColumn($column, "text", ["notnull" => false]); return $newSchema; } /** * Returns an array of string containting the names of the tables contained * the currently selected database in the storage engine. * * @abstract * @access public * @author Jerome Bogaerts, * @return array */ public function getTables() { return $this->getSchemaManager()->listTableNames(); } /** * @author "Lionel Lecaque, " * @param string $tableName */ public function getTableIndexes($tableName) { return $this->getSchemaManager()->listTableIndexes($tableName); } /** * Create an index on a given table and selected columns. This method throws * in case of error. * * @abstract * @access public * @author Jerome Bogaerts, * @param string indexName The name of the index to create. * @param string tableName A table name * @param array columns * @return void */ public function createIndex($indexName, $tableName, $columns) { $index = new \Doctrine\DBAL\Schema\Index($indexName, array_keys($columns)); $table = new \Doctrine\DBAL\Schema\Table($tableName); $this->getSchemaManager()->createIndex($index, $table); } /** * @return Doctrine\DBAL\Schema\AbstractSchemaManager; */ public function getDbalSchemaManager() { return $this->getSchemaManager(); } /** * The error code returned by PDO in when an Index already exists in a table * a given DBMS implementation. * @access public * @author Jerome Bogaerts, * @return string */ abstract public function getIndexAlreadyExistsErrorCode(); /** * * @author Lionel Lecaque, lionel@taotesting.com */ abstract public function getColumnNotFoundErrorCode(); }