Database
[ class tree: Database ] [ index: Database ] [ all elements ]

Class: PHP_Bean_Client

Source Location: /Web/Services/PhpBeans/phpbeans.php

Class Overview


PHP Bean client base package. Allows PHP scripts to communicate with servers implementing the PHP Bean specification, such as the Sitellite Object Server. For more info, see:

Class Details

[line 57]
PHP Bean client base package. Allows PHP scripts to communicate with servers implementing the PHP Bean specification, such as the Sitellite Object Server. For more info, see:

http://www.phpbeans.com/

  1. <?php
  2.  
  3. loader_import ('saf.Database.Bean');
  4.  
  5. // connect to the server
  6.  
  7. $client = new PHP_Bean_Client ('localhost', 3843, 2);
  8. if (! $client->connect ()) {
  9. die ($client->error);
  10. }
  11.  
  12. // authenticate yourself
  13.  
  14. if (! $client->authenticate ($user, $pass)) {
  15. die ($client->error);
  16. }
  17.  
  18. // call a method using the literal query syntax
  19.  
  20. $res = $client->call ('server/uptime');
  21. if (! $res) {
  22. die ($client->error);
  23. }
  24.  
  25. echo 'Server up since: ' . $res;
  26.  
  27. // or use a local object to alias a server-side one
  28.  
  29. $server =& $client->getObject ('server');
  30.  
  31. echo 'Server up since: ' . $server->uptime ();
  32.  
  33. // and finally, disconnect
  34.  
  35. $client->disconnect ();
  36.  
  37. ? >




access:  public
version:  1.0, 2004-09-10, $Id: phpbeans.php,v 1.2 2005/04/14 02:00:47 weizhuo Exp $
license:  http://www.opensource.org/licenses/lgpl-license.php
copyright:  Copyright (C) 2004, Simian Systems Inc.
author:  John Luxford <lux@simian.ca>


[ Top ]

Variables

Methods



Class Variables

$connection =

[line 63]

3078 Socket connection resource.



access:  public

Type:   mixed


[ Top ]

$errno =

[line 105]

Error number when an error occurs.



access:  public

Type:   mixed


[ Top ]

$error =

[line 112]

Error message when an error occurs.



access:  public

Type:   mixed


[ Top ]

$log = array ()

[line 119]

Log of communication between the client and the server.



access:  public

Type:   mixed


[ Top ]

$logging =  false

[line 126]

Whether to keep a log of the communication or not.



access:  public

Type:   mixed


[ Top ]

$maxResponseLength =  4096

[line 134]

The maximum size of a response message from the server.

Default is 4KB.




access:  public

Type:   mixed


[ Top ]

$pass =

[line 98]

Password to authenticate with the bean server.



access:  public

Type:   mixed


[ Top ]

$port =  3843

[line 77]

Server port.



access:  public

Type:   mixed


[ Top ]

$server =  'localhost'

[line 70]

Server name or IP address.



access:  public

Type:   mixed


[ Top ]

$timeout =  15

[line 84]

Socket timeout for connection and requests.



access:  public

Type:   mixed


[ Top ]

$user =

[line 91]

Username to authenticate with the bean server.



access:  public

Type:   mixed


[ Top ]



Class Methods


constructor PHP_Bean_Client [line 144]

PHP_Bean_Client PHP_Bean_Client( [string $server = 'localhost'], [int $port = 3843], [int $timeout = 15])

Constructor method.



access:  public


Parameters:

string   $server  
int   $port  
int   $timeout  

[ Top ]

method authenticate [line 185]

boolean authenticate( string $user, string $pass)

Authenticates with the server.



access:  public


Parameters:

string   $user  
string   $pass  

[ Top ]

method call [line 280]

mixed call( string $request)

Calls a method on a remote object.



access:  public


Parameters:

string   $request  

[ Top ]

method connect [line 156]

boolean connect( )

Connects to the server.



access:  public


[ Top ]

method decode [line 386]

void decode( mixed $resp)

Decode Unicode characters properly.



access:  public


[ Top ]

method disconnect [line 373]

void disconnect( )

Disconnects from the server.



access:  public


[ Top ]

method getObject [line 211]

object &getObject( string $name)

Creates a local object that mimicks the specified server-side object.



access:  public


Parameters:

string   $name  

[ Top ]

method getResponse [line 304]

string getResponse( )

Fetches the response from the server. This is called automatically by the call() method.



access:  public


[ Top ]

method isError [line 363]

boolean isError( mixed $resp)

Determines whether a response is an error or not. Called automatically by the call() method.



access:  public


Parameters:

mixed   $resp  

[ Top ]

method makeStr [line 340]

string makeStr( string $name, string $value)

Makes a properly formatted key/value pair ready for inclusion in a method call.



access:  public


Parameters:

string   $name  
string   $value  

[ Top ]

method parseResponse [line 326]

mixed parseResponse( string $resp)

Unserializes the response from the server. Called automatically by the call() method.



access:  public


Parameters:

string   $resp  

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.