[PHP-DB] Passing Parameters By Reference to a COM Object function... Nasty!

2004-05-23 Thread Keith
Dear All,

I've got a nasty little problem here I hope someone can help me...

I'm doing a job which requires me to use a 3rd party COM component to
connect to a MSSQL Server. This works by calling Stored Procedures in the
MSSQL DB and returning them in an ADO RecordSet.

The VB Declaration of the COM object function I use is:

 = DBRequest(ByRef responseDB as Variant, ByRef ErrorStr as
Variant, database as String, Procedure as String, ParamArray paramlist() as
Variant)


I have written 2 test scripts one in ASP VBScript and one in PHP. The
VBScript one works fine but the PHP one doesn't. I have pretty much
definitively established that the problem with the PHP script is that the
RecordSet being passed in by reference is not happening.

Both examples (given below) connect successfully to the DB via the COM
object and execute the specified Stored Procedure. The PHP ADO Recordset
parameter is still empty after the function call. I have also forced an
error by calling a non-existent SP and confirmed that the Error String
parameter, (also passed in by reference) is empty in PHP and not in ASP.


So my question is... HOW DO I PASS A PARAMETER BY REFERENCE TO A COM OBJECT
FUNCTION IN PHP?



< ASP EXAMPLE >
<%@ Language=VBScript %>

<%
Dim VBDB
Dim RecSet
Dim RetVal
Dim sDatabase
Dim sError

Set RecSet= Server.CreateObject("ADODB.RecordSet")
Set VBDB = Server.CreateObject("VBDBClientProtocol.msgProtocol")

VBDB.LocalHostIP = "127.0.0.1"
VBDB.RemotePort = 6667
VBDB.RemoteHostIP = "127.0.0.1"

RetVal = VBDB.DBRequest(RecSet, sError, "Oort", "osp_get_Regions")

If RetVal Then
 While (Not RecSet.EOF)
  Response.Write RecSet.Fields(0).Value
  Response.Write ""
  Response.Write RecSet.Fields(1).Value
  Response.Write ""

  RecSet.MoveNext
 Wend

 RecSet.Close
Else
 Response.Write sError
End If

VBDB.Disconnect

Set VBDB = Nothing
Set RecSet = Nothing

%>



< PHP EXAMPLE >

LocalHostIP = "localhost";
$VBDB->RemotePort = 6667;
$VBDB->RemoteHostIP = "localhost";

$rs = new COM("ADODB.Recordset");
$sError = "";

$ReqSuccessful = $VBDB->DBRequest(&$rs, &$sError, "Oort",
"osp_get_Regions");

if ($ReqSuccessful)
{
 while (!$rs->EOF)
 {
  echo $rs->Fields["inRegion"]->value . "";
  echo $rs->Fields["vcName"]->value . "";
  $rs->MoveNext();
 }
}

$rs->Close();
$rs = null;
$VBDB->Disconnect();
$VBDB = null;

?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Passing Parameters By Reference to a COM Object function... Nasty!

2004-05-23 Thread Keith
Dear All,

I've got a nasty little problem here I hope someone can help me...

I'm doing a job which requires me to use a 3rd party COM component to
connect to a MSSQL Server. This works by calling Stored Procedures in the
MSSQL DB and returning them in an ADO RecordSet.

The VB Declaration of the COM object function I use is:

 = DBRequest(ByRef responseDB as Variant, ByRef ErrorStr as
Variant, database as String, Procedure as String, ParamArray paramlist() as
Variant)


I have written 2 test scripts one in ASP VBScript and one in PHP. The
VBScript one works fine but the PHP one doesn't. I have pretty much
definitively established that the problem with the PHP script is that the
RecordSet being passed in by reference is not happening.

Both examples (given below) connect successfully to the DB via the COM
object and execute the specified Stored Procedure. The PHP ADO Recordset
parameter is still empty after the function call. I have also forced an
error by calling a non-existent SP and confirmed that the Error String
parameter, (also passed in by reference) is empty in PHP and not in ASP.


So my question is... HOW DO I PASS A PARAMETER BY REFERENCE TO A COM OBJECT
FUNCTION IN PHP?



< ASP EXAMPLE >
<%@ Language=VBScript %>

<%
Dim VBDB
Dim RecSet
Dim RetVal
Dim sDatabase
Dim sError

Set RecSet= Server.CreateObject("ADODB.RecordSet")
Set VBDB = Server.CreateObject("VBDBClientProtocol.msgProtocol")

VBDB.LocalHostIP = "127.0.0.1"
VBDB.RemotePort = 6667
VBDB.RemoteHostIP = "127.0.0.1"

RetVal = VBDB.DBRequest(RecSet, sError, "Oort", "osp_get_Regions")

If RetVal Then
While (Not RecSet.EOF)
Response.Write RecSet.Fields(0).Value
Response.Write ""
Response.Write RecSet.Fields(1).Value
Response.Write ""
RecSet.MoveNext
Wend

RecSet.Close
Else
Response.Write sError
End If

VBDB.Disconnect

Set VBDB = Nothing
Set RecSet = Nothing

%>



< PHP EXAMPLE >

LocalHostIP = "localhost";
$VBDB->RemotePort = 6667;
$VBDB->RemoteHostIP = "localhost";

$rs = new COM("ADODB.Recordset");
$sError = "";

$ReqSuccessful = $VBDB->DBRequest(&$rs, &$sError, "Oort",
"osp_get_Regions");

if ($ReqSuccessful)
{
while (!$rs->EOF)
{
echo $rs->Fields["inRegion"]->value . "";
echo $rs->Fields["vcName"]->value . "";
$rs->MoveNext();
}
}

$rs->Close();
$rs = null;
$VBDB->Disconnect();
$VBDB = null;

?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Variables in database content

2004-05-23 Thread Sunmaia
Hi

you need eval()

http://uk2.php.net/manual/en/function.eval.php

HTH

Peter

> -Original Message-
> From: Brian Stoffer [mailto:[EMAIL PROTECTED]
> Sent: 23 May 2004 23:34
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Variables in database content
> 
> 
> Hi there.  I have what I suspect is an easy one, but was unable to find 
> something similar in the archives (it's a tough one to search for...).
> 
> Basically I have a table with a text block column.  The actual content 
> that lives in column contains php variables that I want to be able to 
> use when I pull the text out of the database.  Let me give you an 
> example:
> 
> Content:
> "Hi there.  My name is $name.  This is a bunch of text that $othername 
> is telling me to populate with some data.  Hopefully you will be able 
> to help $othername and I get this to work.  Thanks!"
> 
> Now, in my script I want to be able to pull names out of another table, 
> initialize the $name and $othername variables, then pull out the 
> content above, parse the "names" variables and display it in the 
> browser.
> 
> My problem is the variables don't get parsed.  I've tried a few obvious 
> things, like storing the text in a variable, using print or echo, and 
> so-on, even processing it with the various text-to-html functions 
> hoping that it would process the variables, but it seems like it's 
> treating the text as a literal and not actually parsing the variables.
> 
> I suspect it has something to do with either the order, the method of 
> output, or some pre-processing that I'm missing, but after a few hours 
> I simply can't get it.
> 
> Thanks for any advice!
> 
> -b
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Variables in database content

2004-05-23 Thread Brian Stoffer
Hi there.  I have what I suspect is an easy one, but was unable to find 
something similar in the archives (it's a tough one to search for...).

Basically I have a table with a text block column.  The actual content 
that lives in column contains php variables that I want to be able to 
use when I pull the text out of the database.  Let me give you an 
example:

Content:
"Hi there.  My name is $name.  This is a bunch of text that $othername 
is telling me to populate with some data.  Hopefully you will be able 
to help $othername and I get this to work.  Thanks!"

Now, in my script I want to be able to pull names out of another table, 
initialize the $name and $othername variables, then pull out the 
content above, parse the "names" variables and display it in the 
browser.

My problem is the variables don't get parsed.  I've tried a few obvious 
things, like storing the text in a variable, using print or echo, and 
so-on, even processing it with the various text-to-html functions 
hoping that it would process the variables, but it seems like it's 
treating the text as a literal and not actually parsing the variables.

I suspect it has something to do with either the order, the method of 
output, or some pre-processing that I'm missing, but after a few hours 
I simply can't get it.

Thanks for any advice!
-b
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php