Example #1
0
 /**
 	Function: getAllCancelBidForXML
 	Description: 
 	Input: 
 	Output: 
 */
 function getAllCancelBidForXML($OrderDate, $BankID)
 {
     $function_name = 'getAllCancelBidForXML';
     $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct';
     if (authenUser(func_get_args(), $this, $function_name) > 0) {
         return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
     }
     if (!required($OrderDate) || !required($BankID)) {
         if (!required($BankID)) {
             $this->_ERROR_CODE = 34365;
         }
         if (!required($OrderDate)) {
             $this->_ERROR_CODE = 34366;
         }
     } else {
         $query = sprintf("CALL sp_getAllCancelBidForXML('%s', %u )", $OrderDate, $BankID);
         $path = DAB_PATH;
         $date_array = getdate();
         $csv_dir = $path . $date_array['year'] . '/';
         if (!is_dir($csv_dir)) {
             mkdir($csv_dir, 0777);
         }
         $csv_dir = $csv_dir . $date_array['mon'] . '/';
         if (!is_dir($csv_dir)) {
             mkdir($csv_dir, 0777);
         }
         $filename = $csv_dir . date("Ynd") . '_DAB_CancelBidForXML.xml';
         $query2xml = XML_Query2XML::factory($this->_MDB2);
         if (file_exists($filename)) {
             $this->_ERROR_CODE = 34205;
             return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
         }
         $dom = $query2xml->getXML($query, array('rootTag' => 'AllCancelBid', 'idColumn' => false, 'rowTag' => 'CancelBid', 'elements' => array('custaccount' => 'custaccount', 'scraccount' => 'scraccount', 'refno' => 'refno', 'amount' => 'amount')));
         $dom->formatOutput = true;
         file_put_contents($filename, $dom->saveXML());
         $dab = new CDAB();
         $dab_rs = $dab->releaseBidFile($csv_dir, date("Ynd") . '_DAB_CancelBidForXML.xml');
         if ($dab_rs == 0) {
             $this->items[0] = new SOAP_Value('item', $struct, array("FileName" => new SOAP_Value("FileName", "string", "result_" . date("Ynd") . '_DAB_CancelBidForXML.xml')));
             $resultFileName = 'result_' . date("Ynd") . '_DAB_CancelBidForXML.xml';
             $query = sprintf("UPDATE %s SET DABCancel='%s' WHERE TradingDate='%s'", TBL_JOB_CALENDAR, $resultFileName, date("Y-m-d"));
         } else {
             $this->_ERROR_CODE = 34367 . " " . $dab_rs;
             $query = sprintf("UPDATE %s SET DABCancel='%s' WHERE TradingDate='%s'", TBL_JOB_CALENDAR, $dab_rs, date("Y-m-d"));
         }
         $rs = $this->_MDB2_WRITE->extended->getRow($query);
     }
     return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this);
 }
Example #2
0
<?php

require_once 'XML/Query2XML.php';
require_once 'MDB2.php';
$query2xml = XML_Query2XML::factory(MDB2::factory('mysql://root@localhost/Query2XML_Tests'));
$dom = $query2xml->getXML("SELECT\r\n        *\r\n     FROM\r\n        artist\r\n     ORDER BY\r\n        artistid", array('rootTag' => 'MUSIC_LIBRARY', 'rowTag' => 'ARTIST', 'idColumn' => 'artistid', 'elements' => array('NAME' => 'name', 'BIRTH_YEAR' => 'birth_year', 'BIRTH_YEAR_TWO_DIGIT' => "#firstTwoChars()", 'BIRTH_PLACE' => 'birth_place', 'GENRE' => 'genre', 'albums' => array('sql' => array('data' => array('artistid'), 'query' => 'SELECT * FROM album WHERE artist_id = ?'), '_sql_options' => array('merge_selective' => array('genre')), 'rootTag' => '', 'rowTag' => 'ALBUM', 'idColumn' => 'albumid', 'elements' => array('TITLE' => 'title', 'PUBLISHED_YEAR' => 'published_year', 'COMMENT' => 'comment', 'GENRE' => 'genre'), 'attributes' => array('ALBUMID' => 'albumid'))), 'attributes' => array('ARTISTID' => 'artistid', 'MAINTAINER' => ':Lukas Feiler')));
header('Content-Type: application/xml');
$dom->formatOutput = true;
print $dom->saveXML();
function firstTwoChars($record)
{
    return substr($record['birth_year'], 2);
}