Welcome Guest, Not a member yet? Register   Sign In
The script tried to execute a method or access a property of an incomplete objec
#1

[eluser]Louis![/eluser]
Hi everybody,

I need your help for a little problem. I use jquery to make asynchonous request. In the page which update my Cart, i create new object ItemNdd.

But when i want to save into my database i have this issue :
Quote:A PHP Error was encountered

Severity: Notice

Message: ItemNdd:Confusedave() [function.ItemNdd-save]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Ajax" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition

Filename: libraries/Cart.php

Line Number: 331

I have a method to display my datas, and all informations are ok.

Thanks for your help

Louis
#2

[eluser]InsiteFX[/eluser]
Show your code in code tags!

Enjoy
InsiteFX
#3

[eluser]Louis![/eluser]
The code is :
Code:
<?    function addNdd(){
        
        $ndd = $this->input->post('ndd');        
        $extension = $this->input->post('extension');    
        $etat = $this->input->post('etat');    
        
        
        $this->load->library('cart');
        $cart =& Cart::getInstance();
        
        $type = ($etat==1) ? "commande":"transfert";
        
        
        $o = FabriqueItem::create('ndd',array('ndd'=>$ndd.'.'.$extension,'tps'=>12,'type'=>$type));
        $prix = $this->devise->getAmount($this->mdl_domaine->getPrix($extension));
        
        
        $result = ($cart->addArticle($o));
        if($result){    
            $xml = '<racine><resultat reponse="addNdd" ndd="'.$ndd.'.'.$extension.'" prix="'.$prix.'">true</resultat><description>'.$o->getNdd()." ".$o->getType()." - ".$this->devise->getPrice($o->getPrix()).' - '.$o->getTps().' mois</description></racine>';
            
        } else
        $xml = '<resultat reponse="addNdd">false</resultat>';
    
            
        $data['xml'] = utf8_encode($xml);
        
        log_message('debug', $xml);
        
        
        $this->load->view('ajax/display',$data);        
        
    }?&gt;

The code which create the object :

Code:
class ItemNdd extends Item {
    
    var $ndd='';
    var $type='';
    
    function ItemNdd($ndd,$tps,$type){
            parent::Item($tps);
            $this->ndd = $ndd;        
            $this->type = $type;    // achat ou transfert
            $this->prix = $this->CI->mdl_domaine->getPrix($this->CI->mdl_domaine->getExtension($this->ndd));
    }
    
    function getNdd(){
        return $this->ndd;
    }
    
    function equals($object){
        if(!($object instanceof ItemNdd)) return false;
        if($this->ndd==$object->ndd) return true;
        
        return false;
    }
    
    function toString(){
        
        return "<br>Nom de domaine : ".$this->ndd.
        "<br> DurĂ©e : ".$this->getTps()." mois <br>Prix :".$this->prix;
        
    }
    
    function save($id_commande){
        
        $data = array(
                    'id_item'=>'',
                    'id_commande'=>$id_commande,
                    'type'=>'ndd',
                    'titre'=>$this->type.' nom de domaine : '.$this->ndd,
                    'nbre_mois'=>parent::getTps(),
                    'prix'=>$this->CI->devise->getAmount($this->prix),                    
                    'date'=>date('Y-m-d H:i:s'));
        
        
        $this->CI->db->insert('items',$data);
    }

The library Cart what i use has developed by me.
#4

[eluser]Louis![/eluser]
Is there someone to help me ?

The line below is my issue :

'prix'=>$this->CI->devise->getAmount($this->prix),

However, i don't understand why there is a bug when i called this method on a object created by asynchronous request.
#5

[eluser]Louis![/eluser]
I think that the problem is the CI object, i can't call a method on it.
#6

[eluser]BrianDHall[/eluser]
Perhaps at that point 'devise' was not yet loaded into the CI object?
#7

[eluser]Louis![/eluser]
I think i have found the solution. The problem was i didn't update my $this->CI variable in my library.
Now i begin with this line when i want to use my CI object :

$this->CI =& get_instance();

When i saved the object, the adress of the CI Object was good but when i get the object from the session, the CI object was not at the same.

Sorry for my english.

Louis




Theme © iAndrew 2016 - Forum software by © MyBB