【发布时间】:2013-01-10 10:04:20
【问题描述】:
您好,我是 Open ERP 的新手,我想使用写入方法更新 Open ERP 中的记录。以下更新代码来自doc.openerp.com上的example:
/**
* $client = xml-rpc handler
* $relation = name of the relation ex: res.partner
* $attribute = name of the attribute ex:code
* $operator = search term operator ex: ilike, =, !=
* $id = id of the record to be updated
* $data = data to be updated
*/
include("xmlrpc.inc");
function write($client,$relation,$attribute,$operator,$data,$id) {
var $user = 'admin';
var $password = 'admin';
var $userId = -1;
var $dbname = 'db_name';
var $server_url = 'http://localhost:8069/xmlrpc/';
$id_val = array();
$id_val[0] = new xmlrpcval($id, "int");
if($userId<=0) {
connect();
}
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval($relation, "string"));
$msg->addParam(new xmlrpcval("write", "string"));
$msg->addParam(new xmlrpcval($id, "array"));
$msg->addParam(new xmlrpcval($data, "struct"));
$resp = $client->send($msg);
$val = $resp->value();
$record = $val->scalarval();
return $record;
}
在上面的代码中,当我调用 write 函数时,我必须传递 $client 的第一个参数是 xml-rpc 处理程序。但我不清楚什么是 xml-rpc 处理程序。请帮帮我。
【问题讨论】:
-
如果这是你的代码,你肯定知道
$client是什么类..? -
这不是我的代码,它是发布在 Open ERP 网站 (doc.openerp.com/v6.1/developer/12_api.html) 上的示例代码。这就是为什么我不清楚这一点。 @库马尔
-
您的问题应该更清楚:“以下是 my Code 用于更新”
-
那么可能是
$sock = new xmlrpc_client($server_url.'common'); $client = $sock;。该页面上的示例有点烦人。 -
我已经尝试过了,但它不起作用。