定制 coderofsalvation/sql-table-diff 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coderofsalvation/sql-table-diff

Composer 安装命令:

composer require coderofsalvation/sql-table-diff

包简介

Find differences between 2 similar SQL tables. Compare large collections of data fast and stylish

README 文档

README

Find differences between 2 similar SQL tables. Compare large collections of data fast and stylish.

Usage

$ composer require coderofsalvation/sql-diff-table

And then

// 2 db handlers since some frameworks use a separate read- and write-handler 
$a = new SQLTableDiff( "sync_products_A", $dbConn, $dbConn );
$b = new SQLTableDiff( "sync_products_B", $dbConn, $dbConn );

// create 2 SQL tables based on the object fields 
$a->createTableFromFields( array_keys($productsA[0]) );
$b->createTableFromFields( array_keys($productsB[0]) );
// fill the 2 SQL tables
foreach( $productsA as $p ) $sm->addRow( $p );
foreach( $productsB as $p ) $si->addRow( $p );

/*
 * get products which have similar id-value but different stock-value
 */

$filter = (object)array(
  'tableA' => "sync_products_A",
  'tableB' => "sync_products_B",
  'id'     => "sku",              // match on id field
  'fields' => array("stock")      // compare these fields
);

// SQL query is generated and the differences are returned as a result
$result = $sm->diff( $filter);
// there you go!

Todo

  • use closure for SQL query execution

Notes

Multiple-insertions-per-query takes place using smart-buffering, which makes importing large datasets ultrafast.

Hint

If you want to compare large collections with items, sometimes the items are not compatible. For example, if you want to compare products from an csv export with products in your database. In that case you might want to transform the collections to a middleware-format. DataMapper allows you to do that. After you mapped it to your middleware-format, then you can proceed inserting it into the db using createTableFormFields()

License

BSD

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-08-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固