コード例 #1
0
function queryRemoteServer($url, $method, $params, $toArray = true)
{
    global $config;
    include_once 'SOAP/Client.php';
    $client = new SOAP_Client($url);
    if (!$config['utf8']) {
        $params = utf8_encode_recursive($params);
    }
    $response = $client->call($method, $params, array('namespace' => 'urn:DILPSQuery'));
    if (is_a($response, 'SOAP_Fault')) {
        $fault = $response->getFault();
        $response = new stdClass();
        $err = new stdClass();
        $err->error = var_export($fault, true);
        $response->result = $err;
    }
    if ($toArray) {
        $response = _stdclass2array($response);
        if (!$config['utf8']) {
            $response = utf8_decode_recursive($response);
        }
        $result = $response['result'];
    } else {
        $result = $response->result;
    }
    return $result;
}
コード例 #2
0
ファイル: tools.inc.php プロジェクト: BackupTheBerlios/dilps
/**
 *	deep-converts object to array
 *
 *	@access		public
 *	@param 		object $o
 * 	@return		array
 *
 */
function _stdclass2array($o)
{
    $a = array();
    foreach ($o as $p => $v) {
        if (is_object($v)) {
            $v = (array) $v;
        }
        if (is_array($v)) {
            $a1 = array();
            foreach ($v as $p1 => $v1) {
                if (is_object($v1) || is_array($v1)) {
                    $a1[$p1] = _stdclass2array($v1);
                } else {
                    $a1[$p1] = $v1;
                }
            }
            $a[$p] = $a1;
        } else {
            $a[$p] = $v;
        }
    }
    return $a;
}
コード例 #3
0
	function queryCount($querystruct) {
        global $db, $db_prefix;
        if (is_object($querystruct)) {
            $querystruct = _stdclass2array($querystruct);    
        }
        
        // take care of empty arrays which are mysteriously turned into empty strings by the soap monster:
        if (!is_array($querystruct['connectors'])) {$querystruct['connectors'] = array();}
        if (!is_array($querystruct['phrases'])) {$querystruct['phrases'] = array();}
        
    	$dbQuery = new dilpsQuery($db, $db_prefix);
    	
       $fields = 'count(*) as count'; 
       
        //return array('result'=>array('count'=>'here'));            	         
    	$where = $dbQuery->buildWhere($querystruct)
    	         ." and {$db_prefix}meta.status = 'reviewed'";
    	$from = "{$db_prefix}meta ";
    	$sql = "SELECT DISTINCT $fields FROM $from WHERE $where";

	    if ($rs = $db->GetRow($sql)) {
	        $result = $rs;
	    } else  {
	        $result = array('error'=>$db->ErrorMsg());
        	if ($this->needsUtf8Conversion) {
            	$result = utf8_encode_recursive($result);
        	}
	    }
    	    
    	$response = array('result'=>$result);
        return $response;	
	}