Re: Passing array from class to class produces more than one result...

From: Date: Wed, 10 Mar 2004 20:24:35 +0000
Subject: Re: Passing array from class to class produces more than one result...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-180044@lists.php.net to get a copy of this message
mmmh... i think its not coded the right way, first of all, you shouldn't put this: $this->setArray(@mysql_fetch_array($this->getResultID())); in the Select method, you should do it in your FetchArray method, every time it gets called, and return the value directly or false if there are no more rows, an example: function FetchArray() { return @mysql_fetch_array($this->getResultID()); } or something like that "Jonathan Villa" <jvilla@isdesigndev.com> escribió en el mensaje news:1078932426.3002.17.camel@jonathan... > I'm writing a DBI class with the following function > > function Select($sql) > { > $this->setResultID(@mysql_query($sql,$this->getDBConn())); > if ($this->getResultID() == false) > Error::fatalError(__FILE__.' ('.__LINE__.') : Unable to run query : > '.mysql_error().'('.mysql_errno().')'); > > $this->setNumRows(@mysql_num_rows($this->getResultID())); > $this->setArray(@mysql_fetch_array($this->getResultID())); > } > > > When I call this, I want to be able to run > > while($data = $objDBI->FetchArray) > { > echo $data['username']; > } > > but the results I get are > > jvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvilla.... etc.... > > my $sql query is simple > > SELECT username FROM staff; > > and there are four rows in the db... > > > For some reason, I can't pass the value of mysql_fetch_array out of the > Select function.

« previous php.general (#180044) next »