src/PicORM/Model.php
private function update()
    {
        // validate model PHP structure if necessary
        static::_validateModel();

        // build update query on model table
        $helper = new InternalQueryHelper();
        $helper->update(self::formatTableNameMySQL());

        // setting model fields value
        $params = array();
        foreach (static::$_tableFields as $unChamp) {
            // array is for raw SQL value
            if (is_array($this->$unChamp) && isset($this->{$unChamp}[0])) {
                $helper->set($unChamp, $this->{$unChamp}[0]);
            } else {
                // Mysql prepared value
                $helper->set($unChamp, '?');
                $params[] = $this->{$unChamp};
            }
        }

        // restrict with model primary key
        $helper->where(self::formatTableNameMySQL() . ".`" . static::$_primaryKey . "`", "=", "?");
        $params[] = $this->{static::$_primaryKey};

        // update model in database
        $query = static::$_dataSource->prepare($helper->buildQuery());
        $query->execute($params);

        // check for mysql error
        $errorcode = $query->errorInfo();
        if ($errorcode[0] != "00000") {
            throw new Exception($errorcode[2]);
        }

        return true;
    }
private function update()
    {
        // validate model PHP structure if necessary
        static::_validateModel();

        // build update query on model table
        $helper = new InternalQueryHelper();
        $helper->update(self::formatTableNameMySQL());

        // setting model fields value
        $params = array();
        foreach (static::$_tableFields as $unChamp) {
            // array is for raw SQL value
            if (is_array($this->$unChamp) && isset($this->{$unChamp}[0])) {
                $helper->set($unChamp, $this->{$unChamp}[0]);
            } else {
                // Mysql prepared value
                $helper->set($unChamp, '?');
                $params[] = $this->{$unChamp};
            }
        }

        // restrict with model primary key
        $helper->where(self::formatTableNameMySQL() . ".`" . static::$_primaryKey . "`", "=", "?");
        $params[] = $this->{static::$_primaryKey};

        // update model in database
        $query = static::$_dataSource->prepare($helper->buildQuery());
        $query->execute($params);

        // check for mysql error
        $errorcode = $query->errorInfo();
        if ($errorcode[0] != "00000") {
            throw new Exception($errorcode[2]);
        }

        return true;
    }
Update model field in database

@return bool
@throws Exception