建表
phinx\bin\phinx.bat migrate -e production
建设 phinx.yml文件
paths:
migrations: %%PHINX_CONFIG_DIR%%\database\migrations
seeds: %%PHINX_CONFIG_DIR%%\database\seeds
environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost
user: root
pass: ''
development:
name: development_db
testing:
name: testing_db
数据迁移命令如下:
phinx\bin\phinx.bat seed:run -e production
%%PHINX_CONFIG_DIR%%\database\seeds下面的文件示例CreateGroupsTable.php如下:
php
/*
* This file is part of Jitamin.
*
* Copyright (C) Jitamin Team
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Jitamin\Foundation\Security\Role;
use Phinx\Seed\AbstractSeed;
class UserSeeder extends AbstractSeed
{
/**
* Run Method.
public function run()
$data = [
[
'username' = 'admin',
'password' = bcrypt('admin'),
'email' = 'admin@admin.com',
'role' = Role::APP_ADMIN,
],
];
$users = $this-table('users');
$users-insert($data)
-save();
}
把A中的q1倒出来 mysqldump -uadmin1 -padmin111 Q1 Q1.sql
导入Q1 source Q1.sql
这样就可以了!
这篇文章主要介绍了php实现redis数据库指定库号迁移的方法,涉及对于redis数据库的操作技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php实现redis数据库指定库号迁移的方法,分享给大家供大家参考.具体如下:
redis普通的数据库迁移,只能整个redis
save,或者利用主从,当然也可以安装一个redis-dump,不过比较麻烦,这里提供一种php的脚本,实现指定库号的迁移,其实也就是遍历根据存储类型,读出来,插入新库,效果是这样:
代码如下:
[root@localhost
~]#
①php
PHP实例代码如下:
$from
=
$to
$from_redis
redis_init($from);
$to_redis
redis_init($to);
$keys
$from_redis-keys('*');
$count
0;
$total
count($keys);
foreach($keys
as
$key){
if(++$count
%
①.00
==
①.){
echo
"$count/$totaln";
$type
$from_redis-type($key);
switch($type){
case
Redis::REDIS_STRING:
$val
$from_redis-get($key);
$to_redis-set($key,
$val);
break;
Redis::REDIS_LIST:
$list
$from_redis-lRange($key,
0,
-1);
foreach($list
$val){
$to_redis-rPush($key,
Redis::REDIS_HASH:
$hash
$from_redis-hGetAll($key);
$to_redis-hMSet($key,
$hash);
Redis::REDIS_ZSET:
$zset
$from_redis-zRange($key,
-1,
true);
foreach($zset
$val=$score){
$to_redis-zAdd($key,
$score,
function
redis_init($conf){
$redis
new
Redis();
$conf,
$ms);
$host
$ms[1];
$port
':');
$db
$redis-connect($host,
$port);
$redis-select($db);
return
$redis;
希望本文所述对大家的php程序设计有所帮助.
以上就是土嘎嘎小编为大家整理的php迁移数据相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!