Re: [PHP] COM - Assigning to method.

[email protected] (Richard Quadling)
Newsgroups php.general
Message-ID <CAKUjMCVu3Vp98gD+W-hvju9MmyMPWbpaSuMP0ZhvoWChYA2WbA@mail.gmail.com>
On 13 July 2013 01:24, Andrew Ballard <[email protected]> wrote:

> On Jul 12, 2013 4:53 AM, "Adam Nicholls" <[email protected]> wrote:
> >
> > Hi Guys/Gals,
> >
> > I'm doing some integration work with a COM API and according to their
> > documentation to save data in the API, you have to assign to the
> > method.
> >
> > This is their example in Visual Basic:
> >
> >
>
> -------------------------------------------------------------------------------------
> >     Set oBank = New CBank
> >     oBank.Init Application.SessionContext
> >     With oBank
> >         .Fields(BANK_fld_ACCOUNT_NAME) = "Test account"
> >         .Fields(BANK_fld_ACCOUNT_NO) = "12345"
> >         .Fields(BANK_fld_BANK) = "Bank of the Nation"
> >         .Fields(BANK_fld_BRANCH_NAME) = "State Street Branch"
> >     End With
> >     oBank.Save
> >
>
> -------------------------------------------------------------------------------------
> >
> > Obviously in PHP is isn't possible to assign to a method in this way
> > (thats what parameters are for!) So I'm at a bit of a loose end. I'm
> > wondering if anyone else has come across this? Or am I missing
> > something obvious in PHP's implementation of the COM that allows me to
> > work around this?
> >
> > My PHP Code is looks like this:
> >
>
> -------------------------------------------------------------------------------------
> > $API = new COM('API7.API');
> > $API->Init($SerialNo, $Login, '', 1, '', 1);
> > $API->SignOutOnTerminate = True;
> >
> > $Record = new COM("Data.Record");
> > $Record->Init($API->SessionContext);
> >
> > $Record->Fields('BANK_fld_ACCOUNT_NAME') = 'Test Account';//doesn't work
> >
>
> -------------------------------------------------------------------------------------
> >
> > I've also tried (below) but the API says wrong number of parameters
> > $Record->Fields('BANK_fld_ACCOUNT_NAME', 'Test Account');
> >
> > I've also tried something crazy like this (below) but that overwrites
> > the $Record object.
> > $_R = &$Record->Fields('BANK_fld_ACCOUNT_NAME');
> > $_R = 'Test Account';
> >
> >
> > Any ideas? Is it possible?
> >
> >
> > Many Thanks
> > Adam Nicholls
> >
>
> That example isn't assigning values to method return value. Fields is a
> collection of ADO Field objects. The default property of a Field object is
> its Value property, so the shorthand is simply assigning the values of the
> variables to the value of each field in a record within a Recordset.
>
> Andrew
>

So ..

$oBank->BANK_fld_ACCOUNT_NAME = "Test account";

sort of thing.

-- 
Richard Quadling
Twitter : @RQuadling
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.