Advertisement
Guest User

jvargas

a guest
Mar 19th, 2013
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1.         function getCurrencyID($companyID)
  2.         {
  3.             $this->client = new xmlrpc_client($this->services.'object');
  4.  
  5.             $this->msg = new xmlrpcmsg('execute');
  6.            
  7.             /*  
  8.              * THE FOLLOWING CODE SHOULD WORK, BUT IT DOESNT
  9.              */
  10.             //~ $key = array(new xmlrpcval('currency_id', 'string'), );
  11. //~
  12.             //~ $this->msg->addParam(new xmlrpcval($this->database, "string"));
  13.             //~ $this->msg->addParam(new xmlrpcval($this->id, "int"));
  14.             //~ $this->msg->addParam(new xmlrpcval($this->user, "string"));
  15.             //~ $this->msg->addParam(new xmlrpcval("res.company","string"));
  16.             //~ $this->msg->addParam(new xmlrpcval("read", "string"));
  17.             //~ $this->msg->addParam(new xmlrpcval(array($companyID), "array"));
  18.             //~ $this->msg->addParam(new xmlrpcval($key, "array"));
  19.  
  20.             /*  
  21.              * THE FOLLOWING CODE DOES WORK, BUT IT's NOT WHAT WE WANT
  22.              */
  23.             $args = array(
  24.             new xmlrpcval(array(new xmlrpcval("name" , "string"),   //Table name
  25.                                 new xmlrpcval("=","string"),        //Operator
  26.                                 new xmlrpcval("CRC","string")),     //Search value
  27.                         "array"),
  28.             );
  29.  
  30.             $this->msg->addParam(new xmlrpcval($this->database, "string"));
  31.             $this->msg->addParam(new xmlrpcval($this->id, "int"));
  32.             $this->msg->addParam(new xmlrpcval($this->password, "string"));
  33.             $this->msg->addParam(new xmlrpcval("res.currency","string"));
  34.             $this->msg->addParam(new xmlrpcval("search", "string"));
  35.             $this->msg->addParam(new xmlrpcval($args, "array"));
  36.  
  37.  
  38.  
  39.             $this->res = &$this->client->send($this->msg);
  40.  
  41.             echo "<h1>Get Currency ID</h1><pre>";
  42.             var_dump ($this->res);
  43.             echo "</pre>";
  44.            
  45.  
  46.             if(!$this->res->faultCode())
  47.             {
  48.                 $res_value = $this->res->value()->scalarval();
  49.                 $res_value_first = $res_value[0]->scalarval();
  50.                 $currencyID = $res_value_first["currency_id"]->scalarval();
  51.                 if(count($currencyID) > 0)
  52.                 {
  53.                     //Retrieves the xmlrpcval with the currency_id
  54.                     return $currencyID[0];
  55.                 }
  56.                 else
  57.                 {
  58.                     return -1;
  59.                 }
  60.             }
  61.             else
  62.             {
  63.                 return 0;
  64.             }
  65.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement