For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > July 2005 > DB_DataObjects : orderBy + getLink doesn't work









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DB_DataObjects : orderBy + getLink doesn't work
David Alia

2005-07-25, 9:28 am

Hi,

I currently use this (lightened) code, inside a class definition :

function getArrayOfB($order) {

$A = $this->factory('A');
$A->synagogueID = $id;

$prop = $this->factory('B');

$i = 0;
if ($A->find()) {
while ($A->fetch()) {
$prop->orderBy($order);
$prop =& $A->getLink('b_ID');
$arr[$i] = $prop;
$i++;
}
return $a
}

that returns an array of B objects.

Problem : the orderBy clause is not taken into account.

What's wrong ?

Thanks

David
Alan Knowles

2005-07-25, 10:05 pm

On Mon, 2005-07-25 at 15:21 +0200, David Alia wrote:
> Hi,
>
> I currently use this (lightened) code, inside a class definition :
>
> function getArrayOfB($order) {
>
> $A = $this->factory('A');
> $A->synagogueID = $id;
>
> $prop = $this->factory('B');
>
> $i = 0;
> if ($A->find()) {
> while ($A->fetch()) {
> $prop->orderBy($order);
> $prop =& $A->getLink('b_ID');

You have just deleted the $prop var here.. and replaced it with the link
results..

To explain this, turn debugging on, look at the SQL statements being
run, then say what you wanted to be run... - that way I can understand
the purpose of this..

Regards
Alan



> $arr[$i] = $prop;
> $i++;
> }
> return $a
> }
>
> that returns an array of B objects.
>
> Problem : the orderBy clause is not taken into account.
>
> What's wrong ?
>
> Thanks
>
> David

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com