#native_company# #native_desc#
#native_cta#

ODBC Socket Server Page 3

By Tim Uckun
on December 6, 2000

Step 3: Setting up the client:
Using phpinfo() make sure that XML support is compiled. If it’s not compiled, recompile PHP using
the –with-xml configuration options. Although not required for this application,
you might also want to enable DOM and WDDX functionality. Here is an example.
./configure 
        --with-apxs=/usr/sbin/apxs 
        --enable-track-vars 
        --with-xml 
        --with-dom 
        --with-wddx
make
make install
If you are using an earlier version you will need to make a change to the php.ini file. Either set the
allow_call_time_pass_reference = On or add ~E_COMPILE_WARNING
to the error_reporting setting
If you don’t do this php will complain bitterly about a
call by reference which we have to make.
Next, drop the included odbcsocketserverobj.php file into a directory in your include path.
That’s it!. We are now ready to run some tests.
Your communication with the socket server will be handled by the odbcsocketserverobj.php. This object has the
following “public” interface.

<?php

$HostName;              // Name of the host to connect to

$Port=9628;             // Port to connect to (set to the default)

$ConnectionString;      // Connection string to use I will show an example later.

$CaseFolding=true;      // Determines weather or not all XML tags are mapped to uppercase pretty useful sometimes

$XML="";                // the raw XML as returned from the socket server

$Error="";              // Please don't use use the function instead

$Recordset=null;        // An array containing the recordset just in case you want to deal with it directly

$BOF true;            // Indicates that the current record position is before the first record in a Recordset object.

$EOF true;            // Indicates that the current record position is after the last record in a Recordset object.

$RecordCount=0;         // Please don't use use the function instead

$FieldNames;            // Please don't use use the function instead

$FieldCount=0;          // Please don't use use the function instead

execute($SQL)

errorMsg()

getField($field

moveNext()

nextRow()           

movePrev()

prevRow()            

moveFirst()

firstRow()               

moveLast()

lastRow()            

moveRow($rowNumber 0)

getNumOfRows()

getNumOfFields() 

getFieldNames() 

?>



Even though PHP does not have any concepts of private and public variables, I have made an effort to hide the
usage of variables in the object. Wrapper functions are provided to
access variables. For example, it is better oop practise to use getNumOfField() method rather then the
$RecordCount variable. Also, note that the movement records are aliased to each other. This was done to
establish compatibility with phpDB recordset objects.
Now that we know what the object does, let’s put it to the test.