Return creates empty record on database on Cakephp 1.3

40 views Asked by At

I have a very strange issue and I can't find any fix for it. I have the following code:

function convertToComponent($idPryComponent) {
    $pryComponentData = $this->{$this->modelClass}->findByIdPryComponent ( $idPryComponent );
    $this->loadModel ('ComponentSource' );

    if ($this->ComponentSource->save ( $pryComponentData [$this->modelClass] )) {
        $idComponent = $this->ComponentSource->id;
        $pryComponentData [$this->modelClass] ['ID_COMPONENT'] = $idComponent;
        $save=array();
        $save['PryComponent']['ID_PRY_COMPONENT']=$idPryComponent;
        $save['PryComponent']['ID_COMPONENT']=$idComponent;
        $return= $this->PryComponent->save ($save);
        return  $idComponent;
    } 
    return false;
}

And after the save actiond, the sentence "return $idComponent;", inserts another empty record on the database, and I don't know why!!! Could you help?

0

There are 0 answers