0
Working with an API (PHP) question
LEGEND
,
/t5/dreamweaver-discussions/working-with-an-api-php-question/td-p/921557
Jan 31, 2008
Jan 31, 2008
Copy link to clipboard
Copied
I am building a mini-app using an API into another back-end
system. To
extract data from this system, I can use PHP lines like this -
$stats = $q->campaignStats($cid);
where the variable "$q" has been previously loaded with values.
What I want to know is - can I programatically generate this line? What I'd
LIKE to do would be something like this (analogous to the way that DW builds
query strings) -
$statsQuery = 'campaign' . $command . "($cid)"
and then I can set $command to any of a number of different values, e.g.,
"ClickStats", "Bounces", "Unsubscribes", etc.
Now - what I don't know how to do is to then reference this string in a way
that executes the command, as I'm fairly sure that -
$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
Is there a special way to handle such things?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
extract data from this system, I can use PHP lines like this -
$stats = $q->campaignStats($cid);
where the variable "$q" has been previously loaded with values.
What I want to know is - can I programatically generate this line? What I'd
LIKE to do would be something like this (analogous to the way that DW builds
query strings) -
$statsQuery = 'campaign' . $command . "($cid)"
and then I can set $command to any of a number of different values, e.g.,
"ClickStats", "Bounces", "Unsubscribes", etc.
Now - what I don't know how to do is to then reference this string in a way
that executes the command, as I'm fairly sure that -
$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
Is there a special way to handle such things?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/working-with-an-api-php-question/m-p/921558#M138506
Jan 31, 2008
Jan 31, 2008
Copy link to clipboard
Copied
.oO(Murray *ACE*)
>I am building a mini-app using an API into another back-end system. To
>extract data from this system, I can use PHP lines like this -
>
>$stats = $q->campaignStats($cid);
>
>where the variable "$q" has been previously loaded with values.
>
>What I want to know is - can I programatically generate this line? What I'd
>LIKE to do would be something like this (analogous to the way that DW builds
>query strings) -
>
>$statsQuery = 'campaign' . $command . "($cid)"
>
>and then I can set $command to any of a number of different values, e.g.,
>"ClickStats", "Bounces", "Unsubscribes", etc.
>
>Now - what I don't know how to do is to then reference this string in a way
>that executes the command, as I'm fairly sure that -
>
>$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
The function name can be taken from a variable, so you can use something
like
$statsQuery = "campaign$command";
$stats = $q->$statsQuery($cid);
For other ways of calling such "dynamic" functions have a look at
call_user_func() and call_user_func_array() if necessary.
Micha
>I am building a mini-app using an API into another back-end system. To
>extract data from this system, I can use PHP lines like this -
>
>$stats = $q->campaignStats($cid);
>
>where the variable "$q" has been previously loaded with values.
>
>What I want to know is - can I programatically generate this line? What I'd
>LIKE to do would be something like this (analogous to the way that DW builds
>query strings) -
>
>$statsQuery = 'campaign' . $command . "($cid)"
>
>and then I can set $command to any of a number of different values, e.g.,
>"ClickStats", "Bounces", "Unsubscribes", etc.
>
>Now - what I don't know how to do is to then reference this string in a way
>that executes the command, as I'm fairly sure that -
>
>$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
The function name can be taken from a variable, so you can use something
like
$statsQuery = "campaign$command";
$stats = $q->$statsQuery($cid);
For other ways of calling such "dynamic" functions have a look at
call_user_func() and call_user_func_array() if necessary.
Micha
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/working-with-an-api-php-question/m-p/921559#M138507
Jan 31, 2008
Jan 31, 2008
Copy link to clipboard
Copied
Thanks, Micha! My earlier imagined way didn't work, not
surprisingly!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"Michael Fesser" <netizen@gmx.de> wrote in message
news:k7n4q39jppjrpi3sn2bcqvgdfu2s7g7geo@4ax.com...
> .oO(Murray *ACE*)
>
>>I am building a mini-app using an API into another back-end system. To
>>extract data from this system, I can use PHP lines like this -
>>
>>$stats = $q->campaignStats($cid);
>>
>>where the variable "$q" has been previously loaded with values.
>>
>>What I want to know is - can I programatically generate this line? What
>>I'd
>>LIKE to do would be something like this (analogous to the way that DW
>>builds
>>query strings) -
>>
>>$statsQuery = 'campaign' . $command . "($cid)"
>>
>>and then I can set $command to any of a number of different values, e.g.,
>>"ClickStats", "Bounces", "Unsubscribes", etc.
>>
>>Now - what I don't know how to do is to then reference this string in a
>>way
>>that executes the command, as I'm fairly sure that -
>>
>>$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
>
> The function name can be taken from a variable, so you can use something
> like
>
> $statsQuery = "campaign$command";
> $stats = $q->$statsQuery($cid);
>
> For other ways of calling such "dynamic" functions have a look at
> call_user_func() and call_user_func_array() if necessary.
>
> Micha
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
"Michael Fesser" <netizen@gmx.de> wrote in message
news:k7n4q39jppjrpi3sn2bcqvgdfu2s7g7geo@4ax.com...
> .oO(Murray *ACE*)
>
>>I am building a mini-app using an API into another back-end system. To
>>extract data from this system, I can use PHP lines like this -
>>
>>$stats = $q->campaignStats($cid);
>>
>>where the variable "$q" has been previously loaded with values.
>>
>>What I want to know is - can I programatically generate this line? What
>>I'd
>>LIKE to do would be something like this (analogous to the way that DW
>>builds
>>query strings) -
>>
>>$statsQuery = 'campaign' . $command . "($cid)"
>>
>>and then I can set $command to any of a number of different values, e.g.,
>>"ClickStats", "Bounces", "Unsubscribes", etc.
>>
>>Now - what I don't know how to do is to then reference this string in a
>>way
>>that executes the command, as I'm fairly sure that -
>>
>>$stats = $q->$statsQuery; would fail (but I'm going to try it of course).
>
> The function name can be taken from a variable, so you can use something
> like
>
> $statsQuery = "campaign$command";
> $stats = $q->$statsQuery($cid);
>
> For other ways of calling such "dynamic" functions have a look at
> call_user_func() and call_user_func_array() if necessary.
>
> Micha
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/dreamweaver-discussions/working-with-an-api-php-question/m-p/921560#M138508
Jan 31, 2008
Jan 31, 2008
Copy link to clipboard
Copied
.oO(Murray *ACE*)
>Thanks, Micha!
You're welcome.
>My earlier imagined way didn't work, not surprisingly!
It would have required eval(), but usually you don't want to use that,
since eval() is evil and there's almost always a better way.
Micha
>Thanks, Micha!
You're welcome.
>My earlier imagined way didn't work, not surprisingly!
It would have required eval(), but usually you don't want to use that,
since eval() is evil and there's almost always a better way.
Micha
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

