php 调试线上怎么保证线上线下数据同步

数据同步的收银系统
全部答案(共2个回答)
等信息功能,适用于各行各业连锁店。
得看开发者是否设计了这个功能。
电子层,或称电子壳,是原子物理学中,一组拥有相同主量子数n的原子轨道。电子在原子中处于不同的能级状态,粗略说是分层分布的,故电子层又叫能层。(如若,您对我的答复...
王城商厦楼上有卖
数据同步存储在车载计算机系统中,经事后编辑处理,形成各种有用的专题数据成果,如导航电子地图等等
我现在用的智络科技的超市收银系统感觉很好用就介绍给大家
可以调啊,这其实难度都不大,关键是看你老板让不让你调了。
答: 可以给宝宝买耳温枪或者是额温枪的,量体温很方便的,我就是买的欧姆龙的额温枪的,宝宝发烧的时候测起来很方便的。
答: 接入技术的发展充分体现了“三网合一”的应用趋势:ADSL是利用原来的语音载体电话线传递数据,线缆调制解调器则利用原有的图像载体有线电视传递数据,大家熟悉的IP电...
答: 端口:500说明:InternetKeyExchange(IKE)(Internet密钥交换)端口:说明:RemotAuthenticatio...
大家还关注
确定举报此问题
举报原因(必选):
广告或垃圾信息
激进时政或意识形态话题
不雅词句或人身攻击
侵犯他人隐私
其它违法和不良信息
报告,这不是个问题
报告原因(必选):
这不是个问题
这个问题分类似乎错了
这个不是我熟悉的地区PHP&soap&大数据同步问题
问题描述:
&& 假如你的php
soap客户端不能正常的同步数据,但你直接调用服务端相应的方法又是正常的,那有可能是default_socket_timeout值过小引起的(可在php.ini文件中设置
),默认情况下它的值为60
,表示socket的过期时间为60s,如果你要作大量的数据同步,尤其是需要轮循的取出数据,那应把该值设置大一些,具体视同步时间长短而定。
如下是php手册对soap的示例,最下方的描述谈到过关于default_socket_timeout值的设置问题。
The SoapClient class
The SoapClient class provides a client for ? SOAP 1.1, ? SOAP
1.2 servers. It can be used in WSDL or non-WSDL mode.
SoapClient {
public mixed __call ( string $function_name , string $arguments
SoapClient ( mixed $wsdl [, array $options ] )
public string __doRequest ( string $request , string $location ,
string $action , int $version [, int $one_way = 0 ] )
public array __getFunctions ( void )
public string __getLastRequest ( void )
public string __getLastRequestHeaders ( void )
public string __getLastResponse ( void )
public string __getLastResponseHeaders ( void )
public array __getTypes ( void )
public void __setCookie ( string $name [, string $value ] )
public string __setLocation ([ string $new_location ] )
public bool __setSoapHeaders ([ mixed $soapheaders ] )
public mixed __soapCall ( string $function_name , array $arguments
[, array $options [, mixed $input_headers [, array
&$output_headers ]]] )
SoapClient ( mixed $wsdl [, array $options ] )
Table of Contents
SoapClient::__call — Calls a SOAP function (deprecated)
SoapClient::__construct — SoapClient constructor
SoapClient::__doRequest — Performs a SOAP request
SoapClient::__getFunctions — Returns list of available SOAP
SoapClient::__getLastRequest — Returns last SOAP request
SoapClient::__getLastRequestHeaders — Returns the SOAP headers from
the last request
SoapClient::__getLastResponse — Returns last SOAP response
SoapClient::__getLastResponseHeaders — Returns the SOAP headers
from the last response
SoapClient::__getTypes — Returns a list of SOAP types
SoapClient::__setCookie — The __setCookie purpose
SoapClient::__setLocation — Sets the location of the Web service to
SoapClient::__setSoapHeaders — Sets SOAP headers for subsequent
SoapClient::__soapCall — Calls a SOAP function
SoapClient::SoapClient — SoapClient constructor
SoapClient::__call use_soap_error_handler
[edit] Last updated: Fri, 01 Jul 2011
&& add a noteUser Contributed
Notes SoapClient
stepan dot zarubin at gmail dot com 30-Jun-
Well, this example works fine:
&&& $x = @new
SoapClient("non-existent.wsdl");&
} catch (Exception $e) {&
$e-&getMessage();
Just make sure use NEW with @.
tlk 19-May-
Make sure to prefix constructor calls with @ and catch SoapFault
exceptions, otherwise you risk having the php interpreter exit/die
on simple network issues.
Robust sample code by Rasmus from
&&& $x = @new
SoapClient("non-existent.wsdl",array("exceptions" =&
} catch (SoapFault $E) {&
echo "ok\n";
jjlopez 09-Mar-
If you are making soap calls in WSDL mode , and the address of your
web service includes a port different from 80 (like ,
the WSDL file is fetched correctly, but all subsequent requests are
made without any port in the host field. This causes a SoapFault
exception when trying to call any of the service’s methods.
You need to redefine the soapClient class and force the port in
each call.
See this example:
hugues at zonereseau dot com 18-Feb-
When you need to connect to services requiring to send extra header
use this method.
Here how we can to it with PHP and SoapClient
class exampleChannelAdvisorAuth
&&& public
$DeveloperK
&&& public
&&& public
function __construct($key, $pass)
$this-&DeveloperKey = $
$this-&Password = $
$devKey&&&&&&&
$password&&& =
$accountId&&& =
// Create the SoapClient instance
$url&&&&&&&&
$client&&&&
= new SoapClient($url, array("trace" =& 1,
"exception" =& 0));
// Create the header
$auth&&&&&&&&
= new ChannelAdvisorAuth($devKey, $password);
$header&&&&
= new SoapHeader(",
"APICredentials", $auth, false);
// Call wsdl function
$result = $client-&__soapCall("DeleteMarketplaceAd",
"DeleteMarketplaceAd" =& array(
"accountID"&&&&&&&
=& $accountId,
"marketplaceAdID"&&&
"9938745"&&&&&&&
// The ads ID
), NULL, $header);
// Echo the result
echo "&pre&".print_r($result,
true)."&/pre&";
if($result-&DeleteMarketplaceAdResult-&Status
== "Success")
&&& echo "Item
deleted!";
jeffmixpute 24-Jan-
Simple php client and server:
// bind SOAP/Client.php -& path of the php
require_once "SOAP/Client.php";
// URI delivered to web service
$sc = new SOAP_Client("
// start call function to use the function of the Web
$parameter = array();
$result = $sc-&call ("now",
&$parameter, "urn:TimeSerivce");
// print result
print $result."\n";
// bind PEAR::SOAP
require_once "SOAP/Server.php";
$skiptrace =& PEAR::getStaticProperty('PEAR_Error',
'skiptrace');
$skiptrace =
// program service class
class TimeSerivce {
&&& public
function now () {
date_default_timezone_set("Europe/Berlin");
return (date ("H:i"));
// web service classs develop
$service = new TimeSerivce();
// server develop
$ss = new SOAP_SERVER();
// assing the name to the service
$ss-&addObjectMap($service, "urn:TimeSerivce");
// Einstellung, dass POST-Daten an den Service weiter gegeben
// preferene to forword POST data to the service
$ss-&service ($HTTP_RAW_POST_DATA);
fourat dot zouari at tritux dot com 20-Jun-2009
In addition to the KeepAlive trick which
is a "server-side" modification, on the "client side"
default_socket_timeout should be increased from its default value
(60) when you deal with ~slow SOAP servers.
As for the KeepAlive, if creating a new separate vhost for the soap
api is not possible, you can add this to your existing vhost:
BrowserMatch "^PHP-SOAP" nokeepalive
where PHP-SOAP is the agent name of your soap client, if you dont
know what agent name your client use, just checkout the access.log
of your apache.
peter dot hansen at fastit dot net 01-May-2009
When you get errors like:
"Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching
http headers in"
after a few (time intensive) SOAP-Calls, check your
webserver-config.
Sometimes the webservers "KeepAlive"-Setting tends to result in
this error. For SOAP-Environments I recommend you to disable
KeepAlive.
Hint: It might be tricky to create a dedicated vhost for your
SOAP-Gateways and disable keepalive just for this vhost because for
normal webpages Keepalive is a nice speed-boost.
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。3.同步数据到其他表的。
这种又分插入和更新字段两种情况,除了sql方面的逻辑外,要考虑记录执行sql和变化前后数据记录。总是要做最坏的打算,一旦更新错了还能回滚数据。
比如在更新之前先记录被更新的数据记录到某表(新建表)或文件中。在编写阶段也做到先跑一条数据,然后再进循环去测试。
一步一步,小心驶得万年船,毕竟你是在做非select操作。
4.从一种DB迁移数据到另外一种DB的。(比如从mssql-&mysql,或反之)这种迁移其实和第二种是类似的,除了业务逻辑外,也要考虑上线后数据的回滚,还有查询和插入需要做到分批。编写代码的时候各种引用渠道和调用model不要写到foreach里面了,驱动也别滥用,每一次的初始化都会消耗链接资源和时间成本。把不必要的查询都干掉,集中在一次查询里面,同时也避免什么都select *之类的查询,用到哪几个字段列就select那几个。在设计数据表的时候(mysql),还是多用时间戳,方便查询,即使显示格式要求,也可以在脚本层面去做。
在插入的时候还应该多用框架自带的批量方法,比如CI中有insert_batch方法,多了解一下驱动底层的实现,免得自己重复造轮子还加一些多于判断。
比如我之前写的分批插入:
for ($i = 1; $i&= $times;$i++) {
$insertData = array();
$partData = $this-&mssql-&select($sql, array(), $i, 10000);
//var_dump($partData);die();
foreach ($partData as $p) {
$insertData[] = array(
'user_id' =& $p['user_id'],
'login_from' =& $p['login_from'],
'type' =& $p['type'],
'ip' =& $p['ip'],
'created' =& $p['created']
$allData = array_chunk($insertData, 1000); // 分批插入
$num = count($allData);
for ($n = 0; $n& $num; $n++) {
$mysql-&insert_batch($tableName , $allData[$n]);
其中array_chunk那句是把装好的10000条数据的数组再分成1000个一份,然后每一千个记录插入一次。看起来很合理,但实际上CI的insert_batch里面已经帮我们这么做了。
DB_active_rec.php源码如下:
// Batch this baby
for ($i = 0, $total = count($this-&ar_set); $i & $total; $i = $i + 1000)
  $sql = $this-&_insert_batch($this-&_protect_identifiers($table, TRUE, NULL, FALSE), $this-&ar_keys, array_slice($this-&ar_set, $i, 1000));
  $this-&query($sql);
这里面已经是1000条一次性批量插入了(这是我修改过的,默认是100),当然mssql的官方驱动比较二逼,那个_insert_batch方法并不存在,我把mysql驱动对应的那个_insert_batch方法给拷贝过去即可。
多了解一些底层实现,就少一些麻烦。
阅读(...) 评论()日 19:27:05
开发过程中线上和线下的配置文件中的值是不一样的
例如:线上生产环境的样式域名为ie.style.abc.com,而开发环境为ie.style.abc.net
此时有两种方案:
一种是将所有以com顶级域名结尾的变量写一份配置文件,以.net结尾的变量写在另一份文件中,在调用的时候根据环境不同而调用不同的文件
1.文件加载类设计复杂;
2.维护特别麻烦:如上边例子,如果有chrome.style.abc.com,firefox.style.abc.com... ...那么添加一个变量至少要修改文件数目为总数乘以2(更别说环境中有100+类似这样的文件,每次添加一个变量得需要修改200多个文件)
第二个方案:
将公共变量抽离出来,本例中可以抽离那些只有顶级域名不一样的变量
1 class PublicVar
public static function get($varname)
if (IS_PRODUCTENV) {
$site = '.style.abc.com';
$site = '.style.abc.net';
$ie = 'http://ie'.$site;
$chrome = 'http://360'.$site;
$firefox = 'http://firefox'.$site;
return $$varname;//双$符,类似c语言的&&双取地址符
19 //程序中调用
20 $domainIE = PublicVar::get('ie');
21 $domainChrome = PublicVar::get('chrome');
22 $domainFirefox = PublicVar::get('firefox');
阅读(...) 评论()

我要回帖

更多关于 php 调试线上 的文章

 

随机推荐