Re: [PHP] COM - Assigning to method.

2013-07-24 Thread Richard Quadling
On 15 July 2013 16:27, Andrew Ballard  wrote:

> On Mon, Jul 15, 2013 at 4:21 AM, Adam Nicholls 
> wrote:
> > Hi Andrew
> >
> > Thanks for this.
> >
> > But I'm still getting errors. I think I need to explain a bit more.
> >
> > Unfortunately there isn't a PHP API for this application I'm trying to
> > interact with, my goal really is to be able to expose the COM
> > functionality over a web-service such as SOAP so I can use it in a
> > CMS. The application I'm trying to integrate with is Blackbuad's
> > Raiser's Edge - API documentation here:
> > https://www.blackbaud.com/files/support/guides/re7ent/api.pdf
> >
> > I think part of the problem is that the field names are also
> > represented by an integer. So to get data out I would do:
> >
> > $oBank->Fields(22);   // which maps to BANK_fld_BRANCH_NAME.
> >
> > When I do:
> >
> > $oBank->22 = 'blah blah';
> >
> > I get an error because a property can't be numeric, it has to start as
> > alpha character. If I use:
> >
> > $oBank->BANK_fld_BRANCH_NAME = 'blah blah blah';
> >
> > I get the following error:
> >
> > Fatal error: Uncaught exception 'com_exception' with message 'Unable
> > to lookup `BANK_fld_BRANCH_NAME': Unknown name.
> >
> > I've also tried using your Value property returned by Fields():
> >
> > $oBank->Fields(22)->Value = 'Blah Blah blah blah';
> >
> > Which I then get:
> > PHP Warning:  Creating default object from empty value in [C:\Users]
> > Fatal error: Call to undefined method variant::Save()
> >
> > Soo seems nearly impossible to implement a safe way to write to the COM
> API.
> >
> >
> > At the moment, I'm still in the scoping/prototype stage of my project,
> > so I'm beginning to think that using this COM API for this project is
> > a no-go, which is unfortunate. I'm also guessing even if we did
> > implement this API, exposing it as a Web Service is going to be tricky
> > for performance sake (given that I've read that COM doesn't
> > multithread very well??)
> >
> > Many Thanks
> > Adam.
>
> It's definitely possible to do, once you figure out the syntax you
> need for this object.
>
> I'm guessing you must have gotten past the $oBank->Init() method call
> without issues.
>
> What happens if you just use this for the value assignment?
>
> $oBank->Fields(BANK_fld_ACCOUNT_NAME) = "Test account";
> $oBank->Fields(BANK_fld_ACCOUNT_NO) = "12345";
> $oBank->Fields(BANK_fld_BANK) = "Bank of the Nation";
> $oBank->Fields(BANK_fld_BRANCH_NAME) = "State Street Branch";
>
> It also looks like you're getting errors from the call to
> $oBank->Save() saying that the method is not defined.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I used to use PHP+Windows+COM+Crystal Reports.

I'm in the middle of something else, but a few things. Does the library you
are using have a valid COM interface? Some of the .NET libraries simply
don't. The last version of CR that was COM enabled was CR XI R 2. After
that it was .NET and Java only. No COM. Having said that, I never got
around to using http://uk1.php.net/manual/en/class.dotnet.php, so I don't
know how this all worked. From memory the DOTNET layer of PHP was just a
wrapper around COM and still required COM exposure in the lib. I think.

Use a TypeLib Explorer to see exactly what interface is available - from
memory, the right tool is all you need. I was able to code anything I
needed with Crystal Reports.

There is also a PHP function
http://uk1.php.net/manual/en/function.com-load-typelib.php which I used to
allow the various constants within the typelib to be exposed and usable
within PHP.

And also look at
http://uk1.php.net/manual/en/function.com-print-typeinfo.php and the user
notes. Not used it but "bucket loads of info" is a good thing to see
normally.


-- 
Richard Quadling
Twitter : @RQuadling


Re: [PHP] COM - Assigning to method.

2013-07-15 Thread Andrew Ballard
On Mon, Jul 15, 2013 at 4:21 AM, Adam Nicholls  wrote:
> Hi Andrew
>
> Thanks for this.
>
> But I'm still getting errors. I think I need to explain a bit more.
>
> Unfortunately there isn't a PHP API for this application I'm trying to
> interact with, my goal really is to be able to expose the COM
> functionality over a web-service such as SOAP so I can use it in a
> CMS. The application I'm trying to integrate with is Blackbuad's
> Raiser's Edge - API documentation here:
> https://www.blackbaud.com/files/support/guides/re7ent/api.pdf
>
> I think part of the problem is that the field names are also
> represented by an integer. So to get data out I would do:
>
> $oBank->Fields(22);   // which maps to BANK_fld_BRANCH_NAME.
>
> When I do:
>
> $oBank->22 = 'blah blah';
>
> I get an error because a property can't be numeric, it has to start as
> alpha character. If I use:
>
> $oBank->BANK_fld_BRANCH_NAME = 'blah blah blah';
>
> I get the following error:
>
> Fatal error: Uncaught exception 'com_exception' with message 'Unable
> to lookup `BANK_fld_BRANCH_NAME': Unknown name.
>
> I've also tried using your Value property returned by Fields():
>
> $oBank->Fields(22)->Value = 'Blah Blah blah blah';
>
> Which I then get:
> PHP Warning:  Creating default object from empty value in [C:\Users]
> Fatal error: Call to undefined method variant::Save()
>
> Soo seems nearly impossible to implement a safe way to write to the COM API.
>
>
> At the moment, I'm still in the scoping/prototype stage of my project,
> so I'm beginning to think that using this COM API for this project is
> a no-go, which is unfortunate. I'm also guessing even if we did
> implement this API, exposing it as a Web Service is going to be tricky
> for performance sake (given that I've read that COM doesn't
> multithread very well??)
>
> Many Thanks
> Adam.

It's definitely possible to do, once you figure out the syntax you
need for this object.

I'm guessing you must have gotten past the $oBank->Init() method call
without issues.

What happens if you just use this for the value assignment?

$oBank->Fields(BANK_fld_ACCOUNT_NAME) = "Test account";
$oBank->Fields(BANK_fld_ACCOUNT_NO) = "12345";
$oBank->Fields(BANK_fld_BANK) = "Bank of the Nation";
$oBank->Fields(BANK_fld_BRANCH_NAME) = "State Street Branch";

It also looks like you're getting errors from the call to
$oBank->Save() saying that the method is not defined.

Andrew

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



Re: [PHP] COM - Assigning to method.

2013-07-15 Thread Přemysl Fiala

Hello,

did you tried var_dump or print_r the $oBank object to see his structure ?

Also you can try:

 $BANK_fld_BRANCH_NAME = 22;
 $oBank->$BANK_fld_BRANCH_NAME  = 'something';


Premek.


On Mon, 15 Jul 2013 10:21:48 +0200, Adam Nicholls   
wrote:



Hi Andrew

Thanks for this.

But I'm still getting errors. I think I need to explain a bit more.

Unfortunately there isn't a PHP API for this application I'm trying to
interact with, my goal really is to be able to expose the COM
functionality over a web-service such as SOAP so I can use it in a
CMS. The application I'm trying to integrate with is Blackbuad's
Raiser's Edge - API documentation here:
https://www.blackbaud.com/files/support/guides/re7ent/api.pdf

I think part of the problem is that the field names are also
represented by an integer. So to get data out I would do:

$oBank->Fields(22);   // which maps to BANK_fld_BRANCH_NAME.

When I do:

$oBank->22 = 'blah blah';

I get an error because a property can't be numeric, it has to start as
alpha character. If I use:

$oBank->BANK_fld_BRANCH_NAME = 'blah blah blah';

I get the following error:

Fatal error: Uncaught exception 'com_exception' with message 'Unable
to lookup `BANK_fld_BRANCH_NAME': Unknown name.

I've also tried using your Value property returned by Fields():

$oBank->Fields(22)->Value = 'Blah Blah blah blah';

Which I then get:
PHP Warning:  Creating default object from empty value in [C:\Users]
Fatal error: Call to undefined method variant::Save()

Soo seems nearly impossible to implement a safe way to write to the COM  
API.



At the moment, I'm still in the scoping/prototype stage of my project,
so I'm beginning to think that using this COM API for this project is
a no-go, which is unfortunate. I'm also guessing even if we did
implement this API, exposing it as a Web Service is going to be tricky
for performance sake (given that I've read that COM doesn't
multithread very well??)

Many Thanks
Adam.

On 14 July 2013 22:16, Andrew Ballard  wrote:
On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls   
wrote:


Richard - I've tried that I get an error about it not being defined as
property of the object.

Andrew - do you mean try using the method Richard has shown?

Cheers
Adam.

On 13 July 2013 17:11, Richard Quadling  wrote:
>
>
>
> On 13 July 2013 01:24, Andrew Ballard  wrote:
>>
>> On Jul 12, 2013 4:53 AM, "Adam Nicholls"   
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



--
Adam Nicholls


Richard has

Re: [PHP] COM - Assigning to method.

2013-07-15 Thread Adam Nicholls
Hi Andrew

Thanks for this.

But I'm still getting errors. I think I need to explain a bit more.

Unfortunately there isn't a PHP API for this application I'm trying to
interact with, my goal really is to be able to expose the COM
functionality over a web-service such as SOAP so I can use it in a
CMS. The application I'm trying to integrate with is Blackbuad's
Raiser's Edge - API documentation here:
https://www.blackbaud.com/files/support/guides/re7ent/api.pdf

I think part of the problem is that the field names are also
represented by an integer. So to get data out I would do:

$oBank->Fields(22);   // which maps to BANK_fld_BRANCH_NAME.

When I do:

$oBank->22 = 'blah blah';

I get an error because a property can't be numeric, it has to start as
alpha character. If I use:

$oBank->BANK_fld_BRANCH_NAME = 'blah blah blah';

I get the following error:

Fatal error: Uncaught exception 'com_exception' with message 'Unable
to lookup `BANK_fld_BRANCH_NAME': Unknown name.

I've also tried using your Value property returned by Fields():

$oBank->Fields(22)->Value = 'Blah Blah blah blah';

Which I then get:
PHP Warning:  Creating default object from empty value in [C:\Users]
Fatal error: Call to undefined method variant::Save()

Soo seems nearly impossible to implement a safe way to write to the COM API.


At the moment, I'm still in the scoping/prototype stage of my project,
so I'm beginning to think that using this COM API for this project is
a no-go, which is unfortunate. I'm also guessing even if we did
implement this API, exposing it as a Web Service is going to be tricky
for performance sake (given that I've read that COM doesn't
multithread very well??)

Many Thanks
Adam.

On 14 July 2013 22:16, Andrew Ballard  wrote:
> On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls  wrote:
>>
>> Richard - I've tried that I get an error about it not being defined as
>> property of the object.
>>
>> Andrew - do you mean try using the method Richard has shown?
>>
>> Cheers
>> Adam.
>>
>> On 13 July 2013 17:11, Richard Quadling  wrote:
>> >
>> >
>> >
>> > On 13 July 2013 01:24, Andrew Ballard  wrote:
>> >>
>> >> On Jul 12, 2013 4:53 AM, "Adam Nicholls"  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
>>
>>
>>
>> --
>> Adam Nicholls
>
> Richard has th

Re: [PHP] COM - Assigning to method.

2013-07-14 Thread Andrew Ballard
On Sun, Jul 14, 2013 at 3:18 PM, Adam Nicholls  wrote:
>
> Richard - I've tried that I get an error about it not being defined as
> property of the object.
>
> Andrew - do you mean try using the method Richard has shown?
>
> Cheers
> Adam.
>
> On 13 July 2013 17:11, Richard Quadling  wrote:
> >
> >
> >
> > On 13 July 2013 01:24, Andrew Ballard  wrote:
> >>
> >> On Jul 12, 2013 4:53 AM, "Adam Nicholls"  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
>
>
>
> --
> Adam Nicholls

Richard has the general idea correct, but as I recall it is a little
more involved because it's COM. I've never done that much with COM in
PHP because it was always such a pain. The example you posted probably
used to require com_set() in PHP 4, although it looks like that has
been deprecated in favor of a more typical OO syntax in PHP 5. Is
there any chance there is a PHP version of the library that you can
work with to avoid COM? If not, hopefully what follows will help start
you on the right direction.

A more explicit version of your original VBScript example looks like this:

Set oBank = New CBank
oBank.Init Application.SessionContext

Set oField = oBank.Fields(BANK_fld_ACCOUNT_NAME)
oField.Value = "Test account"
Set oField = oBank.Fields(BANK_fld_ACCOUNT_NO)
oField.Value = "12345"
Set oField = oBank.Fields(BANK_fld_BANK)
oField.Value = "Bank of the Nation"
Set oField = oBank.Fields(BANK_fld_BRANCH_NAME)
oField.Value = "State Street Branch"

oBank.Save


I'm not familiar with your CBank COM class, but the rest of it looks
like it is similar to the COM('ADODB.Recordset'). If so, a rough
translation of your original example should resemble this:

Init($config);

/**
I am assuming that BANK_fld_ACCOUNT_NAME and such are constant names
that were already defined with the names of the actual column names in
a recordset returned by $oBank.
*/
$oBank->Fields(BANK_fld_ACCOUNT_NAME)->Value = "Test account";
$oBank->Fields(BANK_fld_ACCOUNT_NO)->Value = "12345";
$oBank->Fields(BANK_fld_BANK)->Value = "Bank of the Nation";
$oBank->Fields(BANK_fld_BRANCH_NAME)->Value = "State Street Branch";

$oBank->Save();

?>

I don't know if you could leave out the ->Value part of the syntax in
PHP like you can in the VBScript example you posted. If so, then
Richard's syntax would have been pretty close:

$oBank->Fields(BANK_fld_BRANCH_NAME) = "State Street Bra

Re: [PHP] COM - Assigning to method.

2013-07-14 Thread Adam Nicholls
Richard - I've tried that I get an error about it not being defined as
property of the object.

Andrew - do you mean try using the method Richard has shown?

Cheers
Adam.

On 13 July 2013 17:11, Richard Quadling  wrote:
>
>
>
> On 13 July 2013 01:24, Andrew Ballard  wrote:
>>
>> On Jul 12, 2013 4:53 AM, "Adam Nicholls"  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



-- 
Adam Nicholls

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



Re: [PHP] COM - Assigning to method.

2013-07-13 Thread Richard Quadling
On 13 July 2013 01:24, Andrew Ballard  wrote:

> On Jul 12, 2013 4:53 AM, "Adam Nicholls"  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


Re: [PHP] COM - Assigning to method.

2013-07-12 Thread Andrew Ballard
On Jul 12, 2013 4:53 AM, "Adam Nicholls"  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


[PHP] COM - Assigning to method.

2013-07-12 Thread Adam Nicholls
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

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