Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Batch Script connecting two databases in an Extract Tranform Load (ETL) Design Pattern (Do you have any advice about how to structure a program that will be moving data between pgsql and sqlsrv databases?)
Re: Batch Script connecting two databases in an Extract Tranform Load (ETL) Design Pattern [message #4761 is a reply to message #4752] Tue, 02 June 2015 22:21 Go to previous messageGo to previous message
rafs is currently offline  rafs
Messages: 69
Registered: May 2015
Member
Hi tony,

I am missing some fundamental issue. Can you see if you can explain why my data are not getting updated? The output from updateMultile seems to be correct, however, as you can see there are 0 updates, as seen in the messages array.

<?php
// Batch Test 

ini_set('include_path', '.');
require 'std.batch.inc';

batchInit(__FILE__);

$dbobj = RDCsingleton::getInstance('sids');
$dbobj->sql_select  = '';
$dbobj->sql_from    = '';
$dbobj->sql_where   = 'sid_type_id=2';
$dbobj->sql_groupby = '';
$dbobj->sql_orderby = 'sid ASC';

$rows = $dbobj->getData("sid IN (7, 15)");
print "Debug\tgetData:\n";
var_dump($rows);

// neither seem to work...
//$postarray['deployment_status_flags'] = 'deployment_status_flags | 2';
//$postarray[] = 'deployment_status_flags=2';
//$dbobj->startTransaction();
//$rows = $dbobj->updateMultiple($rows, $postarray);
//$dbobj->commit();

// so trying this...also does not update DB
foreach ( $rows as $i => $arr ) {
    $rows[$i]['deployment_status_flags'] = $rows[$i]['deployment_status_flags'] | 16;
}

$dbobj->startTransaction();
$rows = $dbobj->updateMultiple($rows, null);
$dbobj->commit();

if ( !empty($dbobj->errors) ) {
    print "Debug\tErrors:\n";
    var_dump($dbobj->errors);
}

if ( isset($dbobj->messages) ) {
    print "Debug\tmessages: \n";
    var_dump($dbobj->messages);
}

print "Debug\tAfter update rows:\n";
var_dump($rows);

batchEnd();

?>


output:
<html>
<p>** started at June 3, 2015, 3:58 am</p>
<p>server name  : localhost</p>
<p>document root: C:/xampp/htdocs/radicore</p>
<p>script name  : C:/xampp/htdocs/radicore/newsigdb/test-batch-idp.php</p>
<p>php_self     : /newsigdb/test-batch-idp.php</p>
<p>server API   : cli</p>
<p>language     : en-us</p>
<p>server_admin : </p>
<p>include_path : .;C:\xampp\radicore\includes;C:\xampp\htdocs\radicore\newsigdb;C:\xampp\htdocs\radicore\idp1;C:\xampp\htdocs\radicore\audit;C:\xampp\htdocs\radicore\audit\text;C:\xampp\htdocs\radicore\dict;C:\xampp\htdocs\radicore\menu;C:\xampp\htdocs\radicore\workflow;C:\xampp\htdocs\radicore\menu;C:\xampp\htdocs\radicore\audit;C:\xampp\htdocs\radicore\workflow</p>
<p>project_code : </p>
<p>user_id : batch</p>
<p>role_id : batch</p>
Debug	getData:
array(2) {
  [0]=>
  array(9) {
    ["id"]=>
    string(1) "2"
    ["sid_type_id"]=>
    string(1) "2"
    ["sid"]=>
    string(1) "7"
    ["current_signature_id"]=>
    string(5) "22825"
    ["deployment_status_flags"]=>
    string(1) "4"
    ["updated_at"]=>
    string(19) "2014-11-04 08:53:17"
    ["updated_by"]=>
    string(3) "222"
    ["first_deployed_timestamp"]=>
    NULL
    ["last_deployed_timestamp"]=>
    NULL
  }
  [1]=>
  array(9) {
    ["id"]=>
    string(1) "2"
    ["sid_type_id"]=>
    string(1) "2"
    ["sid"]=>
    string(2) "15"
    ["current_signature_id"]=>
    NULL
    ["deployment_status_flags"]=>
    string(1) "2"
    ["updated_at"]=>
    NULL
    ["updated_by"]=>
    NULL
    ["first_deployed_timestamp"]=>
    NULL
    ["last_deployed_timestamp"]=>
    NULL
  }
}
Debug	messages: 
array(1) {
  [0]=>
  string(30) "0 records were updated in SIDS"
}
Debug	After update rows:
array(2) {
  [0]=>
  array(9) {
    ["id"]=>
    string(1) "2"
    ["sid_type_id"]=>
    string(1) "2"
    ["sid"]=>
    string(1) "7"
    ["current_signature_id"]=>
    string(5) "22825"
    ["deployment_status_flags"]=>
    string(2) "20"
    ["updated_at"]=>
    string(19) "2014-11-04 08:53:17"
    ["updated_by"]=>
    string(3) "222"
    ["first_deployed_timestamp"]=>
    NULL
    ["last_deployed_timestamp"]=>
    NULL
  }
  [1]=>
  array(9) {
    ["id"]=>
    string(1) "2"
    ["sid_type_id"]=>
    string(1) "2"
    ["sid"]=>
    string(2) "15"
    ["current_signature_id"]=>
    NULL
    ["deployment_status_flags"]=>
    string(2) "18"
    ["updated_at"]=>
    NULL
    ["updated_by"]=>
    NULL
    ["first_deployed_timestamp"]=>
    NULL
    ["last_deployed_timestamp"]=>
    NULL
  }
}
<p>** finished at June 3, 2015, 3:58 am</p>
</html>
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to use actions(submit,submitstay,copy,quit)
Next Topic: tutorial4 Viewing the Tree structure
Goto Forum:
  


Current Time: Sun Apr 28 23:35:19 EDT 2024

Total time taken to generate the page: 0.01174 seconds