本文整理汇总了PHP中DBUtil::create_table方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::create_table方法的具体用法?PHP DBUtil::create_table怎么用?PHP DBUtil::create_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::create_table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
function up()
{
// get the driver used
\Config::load('auth', true);
$drivers = \Config::get('auth.driver', array());
is_array($drivers) or $drivers = array($drivers);
if (in_array('Simpleauth', $drivers)) {
// get the tablename
\Config::load('simpleauth', true);
$table = \Config::get('simpleauth.table_name', 'users') . '_providers';
// make sure the configured DB is used
\DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
} elseif (in_array('Ormauth', $drivers)) {
// get the tablename
\Config::load('ormauth', true);
$table = \Config::get('ormauth.table_name', 'users') . '_providers';
// make sure the configured DB is used
\DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
}
if (isset($table)) {
\DBUtil::create_table($table, array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'parent_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'provider' => array('type' => 'varchar', 'constraint' => 50), 'uid' => array('type' => 'varchar', 'constraint' => 255), 'secret' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'access_token' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'expires' => array('type' => 'int', 'constraint' => 12, 'default' => 0, 'null' => true), 'refresh_token' => array('type' => 'varchar', 'constraint' => 255, 'null' => true), 'user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0)), array('id'));
\DBUtil::create_index($table, 'parent_id', 'parent_id');
}
// reset any DBUtil connection set
\DBUtil::set_connection(null);
}
示例2: up
public function up()
{
\DBUtil::create_table('crm_ppi_refund', array('claim_id' => array('constraint' => 11, 'type' => 'int'), 'method_id' => array('constraint' => 11, 'type' => 'int'), 'refund_amount' => array('constraint' => 11, 'type' => 'int'), 'invoice_amount' => array('constraint' => 11, 'type' => 'int'), 'invoice_sent_date' => array('type' => 'datetime'), 'paid' => array('constraint' => "'yes','no'", 'type' => 'enum', 'default' => 'no'), 'invoice_paid_date' => array('type' => 'datetime')), array('claim_id'));
//Adding indexes to id fields
$active_db = \Config::get('db.active');
\DB::query("ALTER TABLE `crm_ppi_refund` ADD INDEX ( `claim_id` )")->execute();
}
示例3: up
public function up()
{
\DBUtil::create_table('statistics', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'seller_id' => array('type' => 'int', 'constraint' => 11), 'type' => array('type' => 'varchar', 'constraint' => 50), 'name' => array('type' => 'varchar', 'constraint' => 255), 'value' => array('type' => 'text'), 'date' => array('type' => 'date')), array('id'));
\DBUtil::create_index('statistics', 'seller_id', 'seller_id');
\DBUtil::create_index('statistics', array('seller_id', 'type'), 'seller_type');
\DBUtil::create_index('statistics', array('seller_id', 'type', 'name'), 'seller_type_name');
}
示例4: up
public function up()
{
\DBUtil::create_table('menu', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true), 'left_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'right_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'tree_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'name' => array('constraint' => 252, 'type' => 'varchar'), 'slug' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'url' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'fields' => array('type' => 'text', 'null' => true)), array('id'));
\DBUtil::create_index('menu', 'left_id');
\DBUtil::create_index('menu', 'right_id');
\DBUtil::create_table('menu_meta', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'menu_id' => array('constraint' => 11, 'type' => 'int'), 'key' => array('type' => 'text'), 'value' => array('type' => 'text')), array('id'));
}
示例5: up
public function up()
{
\DBUtil::create_table('crm_referrals', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'user_id' => array('constraint' => 11, 'type' => 'int'), 'introducer_id' => array('constraint' => 11, 'type' => 'int'), 'company_id' => array('constraint' => 11, 'type' => 'int'), 'product_id' => array('constraint' => 11, 'type' => 'int'), 'dialler_lead_id' => array('constraint' => 11, 'type' => 'int'), 'dialler_list_id' => array('constraint' => 11, 'type' => 'int'), 'dialler_list_name' => array('constraint' => 11, 'type' => 'int'), 'referral_date' => array('type' => 'datetime'), 'disposition_id' => array('constraint' => 11, 'type' => 'int'), 'title' => array('constraint' => 5, 'type' => 'varchar'), 'forename' => array('constraint' => 100, 'type' => 'varchar'), 'surname' => array('constraint' => 100, 'type' => 'varchar'), 'street_and_number' => array('constraint' => 100, 'type' => 'varchar'), 'area' => array('constraint' => 100, 'type' => 'varchar'), 'district' => array('constraint' => 100, 'type' => 'varchar'), 'town' => array('constraint' => 100, 'type' => 'varchar'), 'county' => array('constraint' => 100, 'type' => 'varchar'), 'country_id' => array('constraint' => 100, 'type' => 'varchar'), 'post_code' => array('constraint' => 100, 'type' => 'varchar'), 'date_of_birth' => array('type' => 'date'), 'tel_home' => array('constraint' => 11, 'type' => 'bigint'), 'tel_work' => array('constraint' => 11, 'type' => 'bigint'), 'tel_mobile' => array('constraint' => 11, 'type' => 'bigint'), 'email' => array('constraint' => 100, 'type' => 'varchar'), 'notes' => array('type' => 'text')), array('id'));
\DB::query("ALTER TABLE `crm_referrals` ADD INDEX ( `user_id` )")->execute();
\DB::query("ALTER TABLE `crm_referrals` ADD INDEX ( `company_id` )")->execute();
\DB::query("ALTER TABLE `crm_referrals` ADD INDEX ( `disposition_id` )")->execute();
}
示例6: up
public function up()
{
\DBUtil::create_table('customer_gateways', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'customer_id' => array('type' => 'int', 'constraint' => 11), 'gateway_id' => array('type' => 'int', 'constraint' => 11), 'external_id' => array('type' => 'varchar', 'constraint' => 255, 'null' => true)), array('id'));
\DBUtil::create_index('customer_gateways', 'customer_id', 'customer_id');
\DBUtil::create_index('customer_gateways', 'gateway_id', 'gateway_id');
\DBUtil::create_index('customer_gateways', array('customer_id', 'gateway_id'), 'customer_gateway', 'unique');
}
示例7: up
public function up()
{
\DBUtil::create_table('crm_client_access_log', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'client_id' => array('constraint' => 11, 'type' => 'int'), 'user_id' => array('constraint' => 11, 'type' => 'int'), 'access_date' => array('type' => 'datetime')), array('id'));
// \DB::query("ALTER TABLE `crm_client_access_log` ADD PRIMARY KEY ( `id` )")->execute();
\DB::query("ALTER TABLE `crm_client_access_log` ADD INDEX ( `client_id` )")->execute();
\DB::query("ALTER TABLE `crm_client_access_log` ADD INDEX ( `user_id` )")->execute();
}
示例8: up
function up()
{
// get the drivers defined
$drivers = normalize_driver_types();
if (in_array('Simpleauth', $drivers)) {
// get the tablename
\Config::load('simpleauth', true);
$basetable = \Config::get('simpleauth.table_name', 'users');
// make sure the configured DB is used
\DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
} elseif (in_array('Ormauth', $drivers)) {
// get the tablename
\Config::load('ormauth', true);
$basetable = \Config::get('ormauth.table_name', 'users');
// make sure the configured DB is used
\DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
} else {
$basetable = 'users';
}
\DBUtil::create_table($basetable . '_clients', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'name' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'client_id' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'client_secret' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'redirect_uri' => array('type' => 'varchar', 'constraint' => 255, 'default' => ''), 'auto_approve' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'autonomous' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'status' => array('type' => 'enum', 'constraint' => '"development","pending","approved","rejected"', 'default' => 'development'), 'suspended' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0), 'notes' => array('type' => 'tinytext')), array('id'));
\DBUtil::create_index($basetable . '_clients', 'client_id', 'client_id', 'UNIQUE');
\DBUtil::create_table($basetable . '_sessions', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'client_id' => array('type' => 'varchar', 'constraint' => 32, 'default' => ''), 'redirect_uri' => array('type' => 'varchar', 'constraint' => 255, 'default' => ''), 'type_id' => array('type' => 'varchar', 'constraint' => 64), 'type' => array('type' => 'enum', 'constraint' => '"user","auto"', 'default' => 'user'), 'code' => array('type' => 'text'), 'access_token' => array('type' => 'varchar', 'constraint' => 50, 'default' => ''), 'stage' => array('type' => 'enum', 'constraint' => '"request","granted"', 'default' => 'request'), 'first_requested' => array('type' => 'int', 'constraint' => 11), 'last_updated' => array('type' => 'int', 'constraint' => 11), 'limited_access' => array('type' => 'tinyint', 'constraint' => 1, 'default' => 0)), array('id'), true, false, null, array(array('constraint' => 'oauth_sessions_ibfk_1', 'key' => 'client_id', 'reference' => array('table' => $basetable . '_clients', 'column' => 'client_id'), 'on_delete' => 'CASCADE')));
\DBUtil::create_table($basetable . '_scopes', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'scope' => array('type' => 'varchar', 'constraint' => 64, 'default' => ''), 'name' => array('type' => 'varchar', 'constraint' => 64, 'default' => ''), 'description' => array('type' => 'varchar', 'constraint' => 255, 'default' => '')), array('id'));
\DBUtil::create_index($basetable . '_scopes', 'scope', 'scope', 'UNIQUE');
\DBUtil::create_table($basetable . '_sessionscopes', array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'session_id' => array('type' => 'int', 'constraint' => 11), 'access_token' => array('type' => 'varchar', 'constraint' => 50, 'default' => ''), 'scope' => array('type' => 'varchar', 'constraint' => 64, 'default' => '')), array('id'), true, false, null, array(array('constraint' => 'oauth_sessionscopes_ibfk_1', 'key' => 'scope', 'reference' => array('table' => $basetable . '_scopes', 'column' => 'scope')), array('constraint' => 'oauth_sessionscopes_ibfk_2', 'key' => 'session_id', 'reference' => array('table' => $basetable . '_sessions', 'column' => 'id'), 'on_delete' => 'CASCADE')));
\DBUtil::create_index($basetable . '_sessionscopes', 'session_id', 'session_id');
\DBUtil::create_index($basetable . '_sessionscopes', 'access_token', 'access_token');
\DBUtil::create_index($basetable . '_sessionscopes', 'scope', 'scope');
// reset any DBUtil connection set
\DBUtil::set_connection(null);
}
示例9: up
public function up()
{
// -- [ Scripts Forms Table ]
// --------------------------
\DBUtil::create_table('scripts_forms', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'active' => array('constraint' => "'yes','no'", 'type' => 'enum', 'default' => 'yes'), 'created_at' => array('constraint' => 11, 'type' => 'int')), array('id'));
// -- [ Script Form Questions ]
// ----------------------------
\DBUtil::create_table('scripts_forms_questions', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'script_form_id' => array('constraint' => 11, 'type' => 'int'), 'question' => array('constraint' => 200, 'type' => 'varchar'), 'type_field_id' => array('constraint' => 11, 'type' => 'int'), 'required' => array('constraint' => "'yes','no'", 'type' => 'enum', 'default' => 'yes')), array('id'));
// -- [ Script Form Types ]
// ------------------------
\DBUtil::create_table('type_scripts_forms_fields', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'description' => array('constraint' => 100, 'type' => 'varchar'), 'type' => array('constraint' => 50, 'type' => 'varchar'), 'ajax_call' => array('constraint' => 300, 'type' => 'varchar')), array('id'));
// -- [ Script Type Defaults]
// --------------------------
\DB::insert('type_scripts_forms_fields')->set(array('description' => 'Textbox', 'type' => 'text'))->execute();
\DB::insert('type_scripts_forms_fields')->set(array('description' => 'Textarea', 'type' => 'textarea'))->execute();
\DB::insert('type_scripts_forms_fields')->set(array('description' => 'Checkboxes', 'type' => 'checkbox'))->execute();
\DB::insert('type_scripts_forms_fields')->set(array('description' => 'Radio Buttons', 'type' => 'radio'))->execute();
\DB::insert('type_scripts_forms_fields')->set(array('description' => 'Select Menu', 'type' => 'select'))->execute();
// -- [ Script Form Answers ]
// --------------------------
\DBUtil::create_table('scripts_forms_answers', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'script_forms_question_id' => array('constraint' => 11, 'type' => 'int'), 'option_name' => array('constraint' => 200, 'type' => 'varchar'), 'option_value' => array('constraint' => 200, 'type' => 'varchar')), array('id'));
// -- [ Script Form Responses ]
// ----------------------------
\DBUtil::create_table('scripts_forms_responses', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'script_forms_id' => array('constraint' => 11, 'type' => 'int'), 'script_forms_question_id' => array('constraint' => 11, 'type' => 'int'), 'script_forms_answer_id' => array('constraint' => 11, 'type' => 'int'), 'reference_group' => array('constraint' => 200, 'type' => 'varchar'), 'reference' => array('constraint' => 200, 'type' => 'varchar')), array('id'));
}
示例10: up
public function up()
{
\DBUtil::create_table('crm_ppi_correspondence', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'claim_id' => array('constraint' => 11, 'type' => 'int'), 'stage_id' => array('constraint' => 11, 'type' => 'int'), 'user_id' => array('constraint' => 11, 'type' => 'int'), 'date' => array('type' => 'datetime'), 'notes' => array('constraint' => 11, 'type' => 'text')), array('id'));
//Adding indexes to id fields
$active_db = \Config::get('db.active');
\DB::query("ALTER TABLE `crm_ppi_correspondence` ADD INDEX ( `claim_id` )")->execute();
}
示例11: create
/**
* create the sessions table
* php oil r session:create
*/
public static function create()
{
// load session config
\Config::load('session', true);
if (\Config::get('session.driver') != 'db') {
// prompt the user to confirm they want to remove the table.
$continue = \Cli::prompt(\Cli::color('Your current driver type is not set db. Would you like to continue and add the sessions table anyway?', 'yellow'), array('y', 'n'));
if ($continue === 'n') {
return \Cli::color('Database sessions table was not created.', 'red');
}
}
if (\DBUtil::table_exists(\Config::get('session.db.table'))) {
return \Cli::write('Session table already exists.');
}
// create the session table using the table name from the config file
\DBUtil::create_table(\Config::get('session.db.table'), array('session_id' => array('constraint' => 40, 'type' => 'varchar'), 'previous_id' => array('constraint' => 40, 'type' => 'varchar'), 'user_agent' => array('type' => 'text', 'null' => false), 'ip_hash' => array('constraint' => 32, 'type' => 'char'), 'created' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'updated' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'payload' => array('type' => 'longtext')), array('session_id'), false, 'InnoDB', \Config::get('db.default.charset'));
// make previous_id a unique_key. speeds up query and prevents duplicate id's
\DBUtil::create_index(\Config::get('session.db.table'), 'previous_id', 'previous_id', 'unique');
if (\Config::get('session.driver') === 'db') {
// return success message.
return \Cli::color('Success! Your session table has been created!', 'green');
} else {
// return success message notifying that the driver is not db.
return \Cli::color('Success! Your session table has been created! Your current session driver type is set to ' . \Config::get('session.driver') . '. In order to use the table you just created to manage your sessions, you will need to set your driver type to "db" in your session config file.', 'green');
}
}
示例12: up
public function up()
{
\DBUtil::create_table('location', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'title' => array('constraint' => 255, 'type' => 'varchar')), array('id'));
\DBUtil::create_table('events', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'title' => array('constraint' => 255, 'type' => 'varchar'), 'description' => array('type' => 'text', 'null' => true), 'location_id' => array('constraint' => 11, 'type' => 'int'), 'start' => array('type' => 'datetime'), 'poster' => array('constraint' => 255, 'type' => 'varchar', 'null' => true)), array('id'));
\DBUtil::create_table('agenda', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'title' => array('constraint' => 255, 'type' => 'varchar'), 'event_id' => array('constraint' => 11, 'type' => 'int')), array('id'));
\DBUtil::create_table('countries', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 255, 'type' => 'varchar'), 'iso_code' => array('constraint' => 255, 'type' => 'varchar'), 'created_at' => array('constraint' => 11, 'type' => 'int'), 'updated_at' => array('constraint' => 11, 'type' => 'int')), array('id'));
\DBUtil::create_table('users', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'username' => array('constraint' => 50, 'type' => 'varchar'), 'password' => array('constraint' => 255, 'type' => 'varchar'), 'group' => array('constraint' => 11, 'type' => 'int'), 'email' => array('constraint' => 255, 'type' => 'varchar'), 'last_login' => array('constraint' => 25, 'type' => 'varchar'), 'login_hash' => array('constraint' => 255, 'type' => 'varchar'), 'profile_fields' => array('type' => 'text'), 'created_at' => array('constraint' => 11, 'type' => 'int')), array('id'));
}
示例13: up
public function up()
{
\DBUtil::create_table('blog_category', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true, 'unsigned' => true), 'name' => array('constraint' => 255, 'type' => 'varchar'), 'slug' => array('constraint' => 255, 'type' => 'varchar'), 'post_count' => array('constraint' => 11, 'type' => 'int'), 'created_at' => array('constraint' => 11, 'type' => 'int', 'null' => true), 'updated_at' => array('constraint' => 11, 'type' => 'int', 'null' => true)), array('id'));
\Model_Category::forge(array('name' => 'Category #1', 'slug' => 'category-1', 'post_count' => 3))->save();
\Model_Category::forge(array('name' => 'Category #2', 'slug' => 'category-2', 'post_count' => 1))->save();
\Model_Category::forge(array('name' => 'Category #3', 'slug' => 'category-3', 'post_count' => 0))->save();
\Model_Category::forge(array('name' => 'Category #4', 'slug' => 'category-4', 'post_count' => 0))->save();
}
示例14: up
public function up()
{
\DBUtil::create_table('crm_ppi_clients', array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'client_id' => array('constraint' => 11, 'type' => 'int'), 'company_id' => array('constraint' => 11, 'type' => 'int'), 'referral_id' => array('constraint' => 11, 'type' => 'int'), 'user_id' => array('constraint' => 11, 'type' => 'int'), 'account_status' => array('constraint' => 11, 'type' => 'int'), 'account_created' => array('type' => 'datetime')), array('id'));
//Adding indexes to id fields
$active_db = \Config::get('db.active');
\DB::query("ALTER TABLE `crm_ppi_clients` ADD INDEX ( `client_id` )")->execute();
\DB::query("ALTER TABLE `crm_ppi_clients` ADD INDEX ( `account_status` )")->execute();
}
示例15: up
public function up()
{
\DBUtil::create_table($this->table_name, array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'group' => array('constraint' => 20, 'type' => 'varchar'), 'name' => array('constraint' => 20, 'type' => 'varchar'), 'title' => array('constraint' => 50, 'type' => 'varchar'), 'title_en' => array('constraint' => 50, 'type' => 'varchar'), 'seq' => array('constraint' => 11, 'type' => 'int'), 'link' => array('constraint' => 255, 'type' => 'varchar', 'null' => true), 'has_sub' => array('constraint' => 1, 'type' => 'char', 'default' => 'N'), 'parent' => array('constraint' => 20, 'type' => 'varchar', 'null' => true), 'level' => array('constraint' => 11, 'type' => 'int', 'null' => true)), array('id'), true, 'InnoDB', 'utf8_general_ci');
// add UNIQUE index for username and email fields
$active_db = \Config::get('db.active');
$table_prefix = \Config::get('db.' . $active_db . '.table_prefix');
\DB::query("CREATE UNIQUE INDEX menu_name ON " . $table_prefix . $this->table_name . " (name)")->execute();
}