예제 #1
0
파일: DB.php 프로젝트: nzonbi/fishbones
 public function __construct()
 {
     $this->conex = mysql_connect(Fishbones::getConfig()->dbHost, Fishbones::getConfig()->dbUser, Fishbones::getConfig()->dbPass);
     if (!$this->conex) {
         $error = "database connection error 1";
         $this->error = $error;
         Fishbones::getLog()->writeDatabaseError($error);
         Fishbones::getPump()->outXml($this->makeErrorXml($error));
     }
     $selected = mysql_select_db(Fishbones::getConfig()->dbDatabase, $this->conex);
     if (!$selected) {
         $error = "database selection error 2";
         $this->error = $error;
         Fishbones::getLog()->writeDatabaseError($error);
         Fishbones::getPump()->outXml($this->makeErrorXml($error));
     }
 }
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');
예제 #3
0
<?php

// fishbones sample webservice:
//
// simple load data as xml.
// The xml data can be used to feed a model in the client
// point this to start.php
$pathToStart = '../../start.php';
include $pathToStart;
///////////////////////////////////////////////////////////////////////////
// read data and send as xml
$sql = "\r\nSELECT some_data\r\nFROM some_table st\r\n";
// get query result as xml dom
$xmlResul = Fishbones::getDB()->queryAsXmlDom($sql);
// output
Fishbones::getPump()->outXml($xmlResul);