예제 #1
0
파일: Pump.php 프로젝트: nzonbi/fishbones
 /**
  * output xml doc <data><line><value>x</value></line></data>
  * 
  * @param $data String the data
  * createa an xml document with a value node in a line node in a data root node
  * send that to output, and die the script
  * 
  */
 public function outXmlValue($value)
 {
     header("Content-Type: text/xml");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     $domXml = new DOMDocument('1.0', 'utf-8');
     $dataNode = $domXml->appendChild(new DOMElement('data'));
     $lineNode = $dataNode->appendChild(new DOMElement('line'));
     //$valueNode = $lineNode->appendChild( new DOMElement('value', $value ) );
     $valueNode = $lineNode->appendChild(new DOMElement('value'));
     $texNode = $domXml->createTextNode($value);
     $valueNode->appendChild($texNode);
     $xmlString = $domXml->saveXML();
     Fishbones::getLog()->writeOutput($xmlString);
     die($xmlString);
 }
예제 #2
0
파일: DB.php 프로젝트: nzonbi/fishbones
 /**
  * executeas a sql and return result as array
  *
  * @param	string $sql	sql query
  *
  * @return	array|boolean	numeric indexed array of associative arrays with
  * 					data value pairs, 
  *					array with one element, empty array in case of sucess but no resulset
  *					this cast to boolena true, and iterations do nothing
  *					boolean false on error
  * 
  */
 public function queryAsArray($sql)
 {
     $this->error = '';
     Fishbones::getLog()->writeSql($sql);
     $res = mysql_query($sql, $this->conex);
     // query error
     if (!$res) {
         $this->transactionStarted ? $this->rollBack() : null;
         $error = "database query error";
         $this->error = $error;
         Fishbones::getLog()->writeDatabaseError($error);
         Fishbones::getLog()->keepLog();
         return false;
     }
     // query sucess with reults
     if (is_resource($res)) {
         $this->resul = array();
         while ($assoc = mysql_fetch_assoc($res)) {
             $this->resul[] = $assoc;
         }
         return $this->resul;
     }
     // revised: just return an array
     // query sucess with no resulset
     // empty array cast to boolean false
     // so return array with one element. empty array, to make function result cast to true
     //if ( $res == true ) {
     //if ( $res == true ) {
     $this->resul = array();
     //$this->resul[] = array();
     return $this->resul;
     //}
 }
/////////////////////////////////////////////////////////////////////////////
Fishbones::getDB()->startTransaction();
/////////////////////////////////////////////////////////////////////////////
// db query
$sql = "\r\n\tSELECT \r\n\t*\r\n\tFROM items_{$groupId}\r\n\tWHERE\r\n\titem_id = {$itemId}\r\n";
$result = Fishbones::getDB()->queryAsArray($sql);
if ($result === false) {
    Fishbones::getDB()->rollback();
    Fishbones::getPump()->outXmlErrorString("database error 80");
}
// check if item has been deleted
if (count($result) == 0) {
    Fishbones::getDB()->rollback();
    Fishbones::getPump()->outXmlValue("del");
}
$some_data = $result['0']['some_data'];
Fishbones::getLog()->writeDebug('itemCreatorId: ' . $some_data);
$new_data = strrev($some_data);
///////////////////////////////////////////////////////////////////////////
// update
$sql = "\r\n\tUPDATE items_{$groupId} SET\r\n\r\n\tsome_data = '\${$new_data}'\r\n\t\r\n\tWHERE vote_user_id = '{$userId}'\r\n\titem_id = '{$itemId}'\r\n";
$check = Fishbones::getDB()->query($sql);
if ($check === false) {
    Fishbones::getDB()->rollback();
    Fishbones::getPump()->outXmlErrorString("Error 92");
}
///////////////////////////////////////////////////////////////////////////
Fishbones::getDB()->commit();
///////////////////////////////////////////////////////////////////////////
// output
Fishbones::getPump()->outXmlValue('ok');