Skip to content

Instantly share code, notes, and snippets.

@flevour
Created July 5, 2011 19:38
Show Gist options
  • Save flevour/1065692 to your computer and use it in GitHub Desktop.
Save flevour/1065692 to your computer and use it in GitHub Desktop.
Create a table programmatically with Doctrine1
<?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