Created
July 5, 2011 19:38
-
-
Save flevour/1065692 to your computer and use it in GitHub Desktop.
Create a table programmatically with Doctrine1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This class has been auto-generated by the Doctrine ORM Framework | |
*/ | |
class InstallSearchData | |
{ | |
protected $connection = NULL; | |
public function __construct(Doctrine_Connection $connection) | |
{ | |
$this->connection = $connection; | |
} | |
public function install() | |
{ | |
$table = array(); | |
$table['tableName'] = 'search_data'; | |
$table['fields'] = array( | |
'id' => | |
array( | |
'type' => 'integer', | |
'length' => '8', | |
'autoincrement' => '1', | |
'primary' => '1', | |
), | |
'lang' => | |
array( | |
'type' => 'string', | |
'length' => '2', | |
), | |
'model' => | |
array( | |
'type' => 'string', | |
'length' => '255', | |
), | |
'model_id' => | |
array( | |
'type' => 'integer', | |
'length' => '8', | |
), | |
'content' => | |
array( | |
'type' => 'string', | |
'length' => '', | |
), | |
); | |
$table['options'] = array( | |
'type' => 'MyISAM', | |
'indexes' => | |
array( | |
'content' => | |
array( | |
'fields' => | |
array( | |
0 => 'content', | |
), | |
'type' => 'fulltext', | |
), | |
), | |
'primary' => | |
array( | |
0 => 'id', | |
), | |
'collate' => 'utf8_unicode_ci', | |
'charset' => 'utf8' | |
); | |
$this->connection->export->createTable($table['tableName'], $table['fields'], $table['options']); | |
} | |
public function uninstall() | |
{ | |
$this->connection->export->dropTable('search_data'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment