设为首页 加入收藏

TOP

PHPClientforMysqlBinlog
2015-11-21 01:38:40 来源: 作者: 【 】 浏览:0
Tags:PHPClientforMysqlBinlog

?

https://github.com/bullsoft/mysql-replication-listener/archive/master.zip
unzip mysql-replication-listener-master.zip
cd mysql-replication-listener-master
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-replication
make & make install

Install php-binlog

https://github.com/bullsoft/php-binlog/archive/master.zip
unzip php-binlog-master.zip cd php-binlog-master/ext /usr/local/php5.5.15/bin/phpize ./configure --with-php-config=/usr/local/php5.5.15/bin/php-config --with-mysql-binlog=/usr/local/mysql-replication

Examples

注:Binlog为行格式


      

Update_rows

update `type` set type_id = 22 WHERE id in (58, 59);
array(5) { 'type_code' => int(24) 'type_str' => string(11) "Update_rows" 'db_name' => string(5) "cloud" 'table_name' => string(4) "type" 'rows' => array(4) { [0] => array(5) { [0] => string(2) "58" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(2) "22" [4] => string(1) "0" } [1] => array(5) { [0] => string(2) "58" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(1) "4" [4] => string(1) "0" } [2] => array(5) { [0] => string(2) "59" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(2) "22" [4] => string(1) "0" } [3] => array(5) { [0] => string(2) "59" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(1) "4" [4] => string(1) "0" } } }

Delete_rows

delete from `type` WHERE id in (58, 59);
array(5) { 'type_code' => int(25) 'type_str' => string(11) "Delete_rows" 'db_name' => string(5) "cloud" 'table_name' => string(4) "type" 'rows' => array(2) { [0] => array(5) { [0] => string(2) "58" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(2) "22" [4] => string(1) "0" } [1] => array(5) { [0] => string(2) "59" [1] => string(8) "adsfasdf" [2] => string(4) "asdf" [3] => string(2) "22" [4] => string(1) "0" } } }

Write_rows

insert into type values (Null, "Hello, World", "Best world", 4, 0), (NULL, "你好,世界", "世界很美好", 3, 5);
array(5) { 'type_code' => int(23) 'type_str' => string(10) "Write_rows" 'db_name' => string(5) "cloud" 'table_name' => string(4) "type" 'rows' => array(2) { [0] => array(5) { [0] => string(2) "95" [1] => string(12) "Hello, World" [2] => string(10) "Best world" [3] => string(1) "4" [4] => string(1) "0" } [1] => array(5) { [0] => string(2) "96" [1] => string(15) "你好,世界" [2] => string(15) "世界很美好" [3] => string(1) "3" [4] => string(1) "5" } } }
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MySQL数据备份 下一篇mysql中的order by

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: