tags:

views:

123

answers:

1

I've almost got a basic set of helper functions done for accessing ADO through PHP. I'm running into a problem when trying to execute a stored procedure with the adExecuteNoRecords option set for $cmd->Execute(,,adExecuteNoRecords);

I've tried null's for the first two parameters, new VARAINT(), new VARIANT(null), new VARIANT(VT_EMPTY), etc...

I either get back a "Cannot pass parameter 1 by reference" or a com_exception of Type Mismatch, and ->Execute(,,adExecuteNoRecords) doesn't pass the PHP parsing.

I've done quite a bit of searching, but I haven't found a single example of anyone using this.

So in PHP when calling a COM object's method that has optional parameters, how do you set the beginning parameter's to nothing?

Thanks.

+1  A: 

Try passing $missing = new Variant(VT_ERROR) in place of the optional params.

Btw, in COM params, even optional, still have types. If an optional param is BSTR then omitting it is usually like passing an empty string. What might seem strange is that the default value for the optional param is specified in the type library. I.e. an optional BSTR param might have an "abc" default value. So you should research this before constructing the call in PHP. In your particular case Execute has 3 optional VARIANT params without specific defaults, so we use VT_ERROR to signify missing VARIANT param.

wqw