Jump to content

Undefined Method?


Lamez

Recommended Posts

I have an error that I seem to find curious. Let me explain what I have. I have a Database class that has a function (the culprit) that is called fetchAll. It is suppose to call the mysqli method mysqli_result::fetch_all(). This method does exist, I have looked it up: The PHP Manual, however do note the last comment on the page, it describes my problem, but does not explain how I can fix it. Now, here is my error:

 

Fatal error: Call to undefined method mysqli_result::fetch_all() in /var/www/core/includes/Database.php on line 36

 

Here is line 36:

$row = $this->result->fetch_all($mode);

 

Here is the entire function, or is it called a method since it is in a class?

	function fetchAll($mode = 'MYSQLI_ASSOC'){

		$row = $this->result->fetch_all($mode);

		return !empty($row) ? $row : array();//if not empty return row, else return an array?

	}

 

I could post the entire class, but I think it might be irrelevant so I will spear you guys.

 

Do you guys think you might be able to help me out?

 

Thanks!

Link to comment
Share on other sites

Since the error message indicates you are using a mysqli_result object, the PDO information out of the phpinfo() has nothing to do with the current problem. Also, the mysqlnd (mysql Native Driver) sits between either the mysql/mysqli extension and the database itself.

 

You should be looking (searching on the phpinfo() output page) for a reference to mysqlnd

Link to comment
Share on other sites

After quick thought, I figured it out. I have tested it and it seems to work, here is how I solved my problem:

 

	function fetchRow(){

		return $this->result->fetch_assoc();

	}

	function fetchAll($mode = 'MYSQLI_ASSOC'){

		/*$row = $this->result->fetch_all($mode); */

		//return !empty($row) ? $row : array();//if not empty return row, else return an array?

		$row = array();

		while($f = $this->fetchRow())

			$row[] = $f;

		return !empty($row) ? $row : array();

	}

 

Any suggestions?

 

 

Note: I also don't code with double spaces. I am using Linux and I think it might have something to do with the text-encoding, but I am not sure.

Link to comment
Share on other sites

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.