Jump to content

Problem with "fetchRow" function


Adam

Recommended Posts

I'm trying to setup my own db class, but have a problem with the "fetchRow" function. The query is being executed fine and this method does return part of the result but only the first field :S

 

Been looking at this for a while and can't work it out...

 

	public function fetchRow() {
	if ($this->rowCount() == 0)
		return false;

	if (@$this->result = mysql_result($this->query, $this->row_id)) {
		$this->row_id++;
		return $this->result;
	} else {
		$this->row_id = 0;
		return false;
	}

	return true;
}

 

It's called in this way:

 

while ($row = $db->fetchRow()) {
    print_r($row);
}

 

Can anybody spot the problem :S

 

Cheers for any help! Adam[/code]

Link to comment
https://forums.phpfreaks.com/topic/131119-problem-with-fetchrow-function/
Share on other sites

Hah I've come to realise that mysql_result only returns one field from the row. But looking and I can't find another function that returns a whole row at a given row number? Like say:

 

mysql_fetch_assoc($query, $rowNum);

 

anybody know of one??

 

Cheers. Adam!

maxudaskin:

 

while($row = mysql_fetch_array($query))
{
    // Do whatever
}

 

I'm trying to create a db handler class, using the standard functions would kind of defeat the point..

 

corbin:

 

Ahh I wasn't aware the mysql_fetch_row function would return the next row every time it's called..

 

Cheers!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.