本文整理匯總了PHP中models\User::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::insert方法的具體用法?PHP User::insert怎麽用?PHP User::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::insert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: subscribe
public function subscribe()
{
$user = Input::get('user');
$password = Input::get('password');
$name = Input::get('name');
$email = Input::get('email');
$address = Input::get('address');
$gender = Input::get('gender');
$result = User::query()->where('user', '=', $user)->first();
if (!is_null($result)) {
return Response::redirect('/login?error=subscribe');
}
User::insert(array('user' => $user, 'password' => md5($password), 'name' => $name, 'email' => $email, 'address' => $address, 'gender' => $gender));
return Response::redirect('/login');
}
示例2: varchar
`user` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`gender` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`admin` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci', 'CREATE TABLE IF NOT EXISTS `news`(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`body` text COLLATE utf8_unicode_ci NOT NULL,
`image` tinyint(1) NOT NULL,
`section` varchar(20) NOT NULL,
`created` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci', 'CREATE TABLE IF NOT EXISTS `comments`(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`newsId` int(10) unsigned NOT NULL,
`userId` int(10) unsigned NOT NULL,
`comment` text COLLATE utf8_unicode_ci NOT NULL,
`created` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
foreach ($queries as $value) {
$statement = Connection::prepare($value);
$statement->execute();
}
User::insert(array('user' => 'admin', 'password' => md5('admin'), 'name' => 'admin', 'email' => 'admin@admin.com', 'address' => 'admin', 'gender' => 'man', 'admin' => 1));
Connection::disconnect();
示例3: run
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('user')->truncate();
DB::table('role')->truncate();
DB::table('role_user')->truncate();
DB::table('event')->truncate();
DB::table('exp_level')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
$faker = Factory::create();
$uQ = new User();
$uQ->login = 'quentin';
$uQ->pseudo = 'QsAnakrose';
$uQ->password = Hash::make('quentin');
$uQ->email = 'quentin@mail.com';
$uQ->streaming = 1;
$uQ->twitch_channel = 'riotgames';
$uQ->save();
$data = [];
for ($i = 0; $i < 110; $i++) {
$username = $faker->unique()->username;
$data[] = ['login' => $username, 'pseudo' => $username, 'email' => $faker->unique()->freeEmail, 'password' => Hash::make($username)];
}
User::insert($data);
$this->command->info('Users created');
$admin = new Role();
$admin->title = 'admin';
$admin->save();
$streamer = new Role();
$streamer->title = 'streamer';
$streamer->save();
$this->command->info('Roles created');
$uQ->becomeAdmin();
$uQ->becomeStreamer();
for ($i = 2; $i < 13; $i++) {
$u = User::find($i);
$u->becomeStreamer();
$u->twitch_channel = $i;
$u->description = $u->login . 'lorem ipsum dolor. Lol.';
$rand = rand(0, 2);
if ($rand == 0) {
$u->streaming = 1;
} else {
$u->streaming = 0;
}
/*
$avatarManager = new AvatarManager();
$intervManager = $avatarManager->getImgManager();
$width = $avatarManager->getAvatarWidth();
$color = substr(md5(rand()), 0, 6);
$intervManager->canvas($width, $width, $color);
*/
$u->save();
}
$su = new StreamingUserService();
$su->update();
$this->command->info('Roles attached');
$event = new Event();
$event->title = 'Hugo';
$event->start = '2015-06-26T12:30:00+02:00';
$event->end = '2015-06-26T15:30:00+02:00';
$event->allDay = 'false';
$event->color = '#FF0000';
$event->timezone = '+02:00';
$event->save();
$this->command->info('Test event created');
$expManager = new ExperienceManager();
$data = $expManager->generateExperienceSystem();
ExpLevel::insert($data);
$this->command->info('Experience system initialized');
}