Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.