public static function clearLine() { if (self::isRunningOnWindows()) { echo "\r"; } else { parent::clearLine(); } }
public function up() { $user = new User(); $password_hash = Yii::$app->security->generatePasswordHash('123456'); $auth_key = Yii::$app->security->generateRandomString(); $time = time(); $user->setAttributesAll = [['username' => 'caicai1', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai2', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai3', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai4', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai5', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai6', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai7', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time]]; $ret = $user->saveAll(); if ($ret !== true) { BaseConsole::output("测试数据初始化出错," . $ret . '(请手动初始化)'); } }
/** * Prints a string to STDOUT. * * @param string $string the string to print * @return int|boolean Number of bytes printed or false on error */ public static function stdout($string) { $indentStr = self::$isNewLine ? str_repeat(' ', self::$indent) : ''; return parent::stdout($indentStr . $string); }