SimpleDB: Compute number of affected rows
This commit is contained in:
parent
1060a3f9eb
commit
c6b4f2e1d3
|
@ -15,7 +15,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
|
|
||||||
if (class_exists('SimpleXMLElement')) {
|
if (class_exists('SimpleXMLElement')) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $_result;
|
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows, $_result;
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
return ($database == "domain");
|
return ($database == "domain");
|
||||||
|
@ -122,6 +122,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
class Min_Driver {
|
class Min_Driver {
|
||||||
|
|
||||||
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
||||||
|
global $connection;
|
||||||
foreach (array_chunk($ids, 25) as $chunk) {
|
foreach (array_chunk($ids, 25) as $chunk) {
|
||||||
$params2 = $params;
|
$params2 = $params;
|
||||||
foreach ($chunk as $i => $id) {
|
foreach ($chunk as $i => $id) {
|
||||||
|
@ -134,10 +135,11 @@ if (isset($_GET["simpledb"])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$connection->affected_rows = count($ids);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _extractIds($queryWhere, $limit) {
|
function _extractIds($table, $queryWhere, $limit) {
|
||||||
$return = array();
|
$return = array();
|
||||||
if (preg_match_all("~itemName\(\) = ('[^']*+')+~", $queryWhere, $matches)) {
|
if (preg_match_all("~itemName\(\) = ('[^']*+')+~", $queryWhere, $matches)) {
|
||||||
$return = array_map('idf_unescape', $matches[1]);
|
$return = array_map('idf_unescape', $matches[1]);
|
||||||
|
@ -151,7 +153,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
|
|
||||||
function delete($table, $queryWhere, $limit = 0) {
|
function delete($table, $queryWhere, $limit = 0) {
|
||||||
return $this->_chunkRequest(
|
return $this->_chunkRequest(
|
||||||
$this->_extractIds($queryWhere, $limit),
|
$this->_extractIds($table, $queryWhere, $limit),
|
||||||
'BatchDeleteAttributes',
|
'BatchDeleteAttributes',
|
||||||
array('DomainName' => $table)
|
array('DomainName' => $table)
|
||||||
);
|
);
|
||||||
|
@ -172,7 +174,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ids = $this->_extractIds($queryWhere, $limit);
|
$ids = $this->_extractIds($table, $queryWhere, $limit);
|
||||||
$params = array('DomainName' => $table);
|
$params = array('DomainName' => $table);
|
||||||
return (!$insert || $this->_chunkRequest($ids, 'BatchPutAttributes', $params, $insert))
|
return (!$insert || $this->_chunkRequest($ids, 'BatchPutAttributes', $params, $insert))
|
||||||
&& (!$delete || $this->_chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete))
|
&& (!$delete || $this->_chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete))
|
||||||
|
|
Loading…
Reference in a new issue