本文整理汇总了PHP中DBUtil::modify_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::modify_fields方法的具体用法?PHP DBUtil::modify_fields怎么用?PHP DBUtil::modify_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::modify_fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: down
public function down()
{
// load the sentry config file
\Config::load('sentry', true);
// add group table columns level, is_admin and parent
\DBUtil::add_fields(\Config::get('sentry.table.groups'), array('level' => array('constraint' => 11, 'type' => 'int'), 'is_admin' => array('constraint' => 1, 'type' => 'tinyint'), 'parent' => array('constraint' => 11, 'type' => 'int')));
// remove group table column permission
\DBUtil::drop_fields(\Config::get('sentry.table.groups'), array('permissions'));
// remove user table column permission
\DBUtil::drop_fields(\Config::get('sentry.table.users'), array('permissions'));
\DBUtil::modify_fields(\Config::get('sentry.table.users'), array('password' => array('constraint' => 81, 'type' => 'varchar'), 'temp_password' => array('constraint' => 81, 'type' => 'varchar'), 'password_reset_hash' => array('constraint' => 81, 'type' => 'varchar'), 'remember_me' => array('constraint' => 81, 'type' => 'varchar'), 'activation_hash' => array('constraint' => 81, 'type' => 'varchar')));
}
示例2: down
function down()
{
// get the driver used
\Config::load('auth', true);
$drivers = \Config::get('auth.driver', array());
is_array($drivers) or $drivers = array($drivers);
if (in_array('Ormauth', $drivers)) {
// get the tablename
\Config::load('ormauth', true);
$table = \Config::get('ormauth.table_name', 'users');
// modify the filter field to add the 'remove' filter
\DBUtil::modify_fields($table . '_roles', array('filter' => array('type' => 'enum', 'constraint' => "'', 'A', 'D'", 'default' => '')));
}
}
示例3: run
public static function run()
{
try {
$users = \DB::select_array(['id', 'username'])->from('users')->execute();
\DB::start_transaction();
foreach ($users as $user) {
\DB::update('auctions')->value('won_user', $user['id'])->where('won_user', '=', $user['username'])->execute();
}
\DB::commit_transaction();
\DBUtil::modify_fields('auctions', ['won_user' => ['constraint' => 11, 'type' => 'int', 'name' => 'user_id']]);
} catch (Exception $e) {
\DB::rollback_transaction();
}
}
示例4: down
function down()
{
// get the drivers defined
$drivers = normalize_driver_types();
if (in_array('Ormauth', $drivers)) {
// get the tablename
\Config::load('ormauth', true);
$table = \Config::get('ormauth.table_name', 'users');
// make sure the configured DB is used
\DBUtil::set_connection($connection = \Config::get('ormauth.db_connection', null));
// modify the filter field to add the 'remove' filter
\DB::update($table . '_roles')->set(array('filter' => 'D'))->where('filter', '=', 'R')->execute($connection);
\DBUtil::modify_fields($table . '_roles', array('filter' => array('type' => 'enum', 'constraint' => "'', 'A', 'D'", 'default' => '')));
}
// reset any DBUtil connection set
\DBUtil::set_connection(null);
}
示例5: down
public function down()
{
\DBUtil::modify_fields('creatures', array('name' => array('name' => 'creature', 'type' => 'varchar', 'constraint' => 255)));
}
示例6: usertable
protected static function usertable()
{
if (!\DBUtil::table_exists(static::$data['ormauth_table'])) {
if (!\DBUtil::table_exists(static::$data['simpleauth_table'])) {
// table users
\DBUtil::create_table(static::$data['ormauth_table'], array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50), 'password' => array('type' => 'varchar', 'constraint' => 255), 'group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1), 'email' => array('type' => 'varchar', 'constraint' => 255), 'last_login' => array('type' => 'varchar', 'constraint' => 25), 'previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0), 'login_hash' => array('type' => 'varchar', 'constraint' => 255), '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'));
// add a unique index on username and email
\DBUtil::create_index(static::$data['ormauth_table'], array('username', 'email'), 'username', 'UNIQUE');
} else {
\DBUtil::rename_table(static::$data['simpleauth_table'], static::$data['ormauth_table']);
}
}
// run a check on required fields, and deal with missing ones. we might be migrating from simpleauth
if (\DBUtil::field_exists(static::$data['ormauth_table'], 'group')) {
\DBUtil::modify_fields(static::$data['ormauth_table'], array('group' => array('name' => 'group_id', 'type' => 'int', 'constraint' => 11)));
}
if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'group_id')) {
\DBUtil::add_fields(static::$data['ormauth_table'], array('group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1, 'after' => 'password')));
}
if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'previous_login')) {
\DBUtil::add_fields(static::$data['ormauth_table'], array('previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0, 'after' => 'last_login')));
}
if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'user_id')) {
\DBUtil::add_fields(static::$data['ormauth_table'], array('user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'login_hash')));
}
if (\DBUtil::field_exists(static::$data['ormauth_table'], 'created')) {
\DBUtil::modify_fields(static::$data['ormauth_table'], array('created' => array('name' => 'created_at', 'type' => 'int', 'constraint' => 11)));
}
if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'created_at')) {
\DBUtil::add_fields(static::$data['ormauth_table'], array('created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'user_id')));
}
if (\DBUtil::field_exists(static::$data['ormauth_table'], 'updated')) {
\DBUtil::modify_fields(static::$data['ormauth_table'], array('updated' => array('name' => 'updated_at', 'type' => 'int', 'constraint' => 11)));
}
if (!\DBUtil::field_exists(static::$data['ormauth_table'], 'updated_at')) {
\DBUtil::add_fields(static::$data['ormauth_table'], array('updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'created_at')));
}
}
示例7: down
public function down()
{
\DBUtil::modify_fields('users', array('contact_num' => array('name' => 'contact_number', 'type' => 'varchar', 'constraint' => 20)));
}
示例8: down
public function down()
{
\DBUtil::modify_fields('users', array('profile_field' => array('name' => 'profile_fields', 'type' => 'text', 'null' => true)));
}
示例9: down
public function down()
{
\DBUtil::modify_fields('users', array('charge_html' => array('type' => 'tinyint', 'constraint' => 1)));
}
示例10: down
public function down()
{
\DBUtil::modify_fields('authentications', array('secret' => array('constraint' => 255, 'type' => 'varchar', 'null' => false)));
}
示例11: down
public function down()
{
\DBUtil::modify_fields('contacts', array('first_name' => array('type' => 'varchar', 'constraint' => 255), 'last_name' => array('type' => 'varchar', 'constraint' => 255)));
}
示例12: down
public function down()
{
\DBUtil::modify_fields('tests', array('biography' => array('name' => 'bio', 'type' => 'text')));
}
示例13: down
public function down()
{
\DBUtil::rename_table('seller_callbacks', 'seller_events');
\DBUtil::modify_fields('seller_events', array('url' => array('name' => 'callback', 'type' => 'varchar', 'constraint' => 255)));
}
示例14: down
public function down()
{
\DBUtil::modify_fields('books', array('book_url' => array('name' => 'file_url', 'type' => 'varchar', 'constraint' => 255, 'null' => true)));
}
示例15: create_tables
public function create_tables()
{
if (file_exists(APPPATH . 'config/production/db.php') == true) {
Log::error('shit worked!');
}
// DBUtil::set_connection(null);
if (DBUtil::table_exists('urls')) {
if (DBUtil::field_exists('urls', array('time'))) {
// Upgrade Me
try {
DBUtil::rename_table('urls', 'v2_urls');
DBUtil::rename_table('stats', 'v2_stats');
DBUtil::rename_table('settings', 'v2_settings');
} catch (\Database_Exception $e) {
Log::error($e);
}
Controller_Install::create_tables();
} else {
// Already Installed
}
} else {
$oil_path = str_replace('public/', '', DOCROOT);
try {
@Migrate::current('default', 'app');
@Migrate::current('auth', 'package');
} catch (\Database_exception $e) {
Debug::Dump('PLEASE REVISIT THIS /install (DONT RELOAD) THAT SHOULD INSTALL THE SCRIPT FOR YOU IF NOT THEN: Access has been denied for the database user , go to fuel/app/config/production/db.php , and edit your username and password!');
die;
}
try {
\DBUtil::create_index('urls', 'short_url');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('urls', 'user_id');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('urls', array('id', 'short_url'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('urls', array('id', 'user_id'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('urls', array('id', 'short_url', 'user_id'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats', 'url_id');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats', 'country');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats', array('id', 'url_id'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats_countries', 'start_ip');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats_countries', 'end_ip');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats_countries', 'country');
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats_countries', array('start_ip', 'end_ip'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::create_index('url_stats_countries', array('start_ip', 'end_ip', 'country'));
} catch (\Database_exception $e) {
Log::error($e);
}
try {
\DBUtil::modify_fields('urls', array('url' => array('constraint' => 255, 'type' => 'varchar')));
} catch (\Database_exception $e) {
Log::error($e);
}
}
//.........这里部分代码省略.........