Jump to content

[SOLVED] Fatal error: Trying to clone an uncloneable object of class mysqli_result


Recommended Posts

I get this error on the simple code below. Google did not offer much help.

 

Yes I did make sure that my php.ini file had zend.ze1_compatibility_mode set to "off"- which it was. I restarted apache just to make sure- still no good.

 

also- I have checked the result, it works fine- just I can't clone it.

Am I going about this the wrong way, perhaps?

 

<?php
//code

$result = $db->query($query);
$ted = clone $result;
?>

I am passing the result to a class. I need to use the result in a couple places in the class.

 

if I store the result as I have below, anytime I run $result->fetch_Object, a record of data is lost. I need to be able to run fetch_object a few times within my class and preserve the data. I thought cloning would be a good solution for this.

<?php
 public function __construct($displayFields, $mysqliResult)
 {
 	$this->_data = $mysqliResult;
                $this->somefunction($mysqliResult);

 }
?>

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.