Concrete5 MVC parent::save() having trouble finding database insert function, how to save to database

338 Views Asked by At

I am editing a concrete5 add-on and am trying to figure out how the program is saving values to the database. The following function is where the database save is happening but I am not sure where the "parent::save()" function is.

protected function SaveRecord() {
        $func = 'jso'.'n_encode';
        $this->errors = is_array($this->errors) ? $func($this->errors) : $this->errors;

        $this->effectiveDate = is_numeric($this->effectiveDate) ? date('Y-m-d', $this->effectiveDate) : $this->effectiveDate;
        $this->expirationDate = is_numeric($this->expirationDate) ? date('Y-m-d', $this->expirationDate) : $this->expirationDate;

        //var_dump($this); die();
        parent::Save();

        // a bit hacky, but we are saving the errors as JSON, and we might need to access them later.
        $this->errors = (array) json_decode($this->errors);
    }

I have followed the class up to its parent and it does not have a save function. I followed the parent up to its parent until I found a save function in the "adodb" class, but die() never happens when put in this function. Please help me figure out how I am supposed to save values in Concrete5 to the database! (More of my code at: https://stackoverflow.com/questions/26940176/concrete5-add-on-extension-save-value-to-database).

1

There are 1 best solutions below

5
On BEST ANSWER

@CaitlinHavener Your SaveRecord method should be like this.

public function SaveRecord($data){
    $data['my_array'] = serialize($data['my_array']);
    parent::save($data);
}

refer this link concrete5 document