Save pclasses to database

@param string $uri pclass uri

@throws KlarnaException
@return void
762774
public function save($uri)
    {
        $this->splitURI($uri);

        $this->connect();
        if (!is_array($this->pclasses) || count($this->pclasses) == 0) {
            return;
        }

        foreach ($this->pclasses as $pclasses) {
            foreach ($pclasses as $pclass) {
                //Remove the pclass if it exists.
                mysql_query(
                    "DELETE FROM `{$this->dbName}`.`{$this->dbTable}`
                     WHERE `id` = '{$pclass->getId()}'
                     AND `eid` = '{$pclass->getEid()}'"
                );

                //Insert it again.
                $result = mysql_query(
                    "INSERT INTO `{$this->dbName}`.`{$this->dbTable}`
                       (`eid`,
                        `id`,
                        `type`,
                        `description`,
                        `months`,
                        `interestrate`,
                        `invoicefee`,
                        `startfee`,
                        `minamount`,
                        `country`,
                        `expire`
                        )
                     VALUES
                       ('{$pclass->getEid()}',
                        '{$pclass->getId()}',
                        '{$pclass->getType()}',
                        '{$pclass->getDescription()}',
                        '{$pclass->getMonths()}',
                        '{$pclass->getInterestRate()}',
                        '{$pclass->getInvoiceFee()}',
                        '{$pclass->getStartFee()}',
                        '{$pclass->getMinAmount()}',
                        '{$pclass->getCountry()}',
                        '{$pclass->getExpire()}')", $this->link
                );
                if ($result === false) {
                    throw new Klarna_DatabaseException(
                        'INSERT INTO query failed! ('.mysql_error().')'
                    );
                }
            }
        }
    }
1092205
public function saveUnit(Unit $unit)
    {
        $propelUnit = UnitQuery::create()->findOneByDomainAndKey($unit->getDomain(), $unit->getKey());
        if (!$propelUnit) {
            $propelUnit = new PropelUnit();
        }
        $propelUnit->updateFromModel($unit);
        $propelUnit->save();
    }
1067620
public function save() { 
        $array = KernelDB::save($this, $this->tuples, static::$model);
        $routeModel = Dir::apiModel(static::$model);
        $this->id = $array['id'];
    }
1338440
public function setClass($pClass)
    {
        if (is_string($pClass)) {
            $this->createControllerClass($pClass);
        } elseif (is_object($pClass)) {
            $this->controller = $pClass;
        } else {
            $this->controller = $this;
        }
    }
355643
private function registerSchema(stdClass $schema, Uri $uri)
    {
        if (!isset($this->schemas[$uri->getPrimaryResourceIdentifier()])) {
            $this->schemas[$uri->getPrimaryResourceIdentifier()] = $schema;
        }
    }
261415
private function saveInCache(string $class, ClassMetadataInterface $classMetadata): void
    {
        if (null === $this->cache) {
            return;
        }

        if ($this->cache instanceof Cache) {
            $this->cache->save($class, $classMetadata);
        } else {
            $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class));
            $item = $this->cache->getItem($class);
            $item->set($classMetadata);

            $this->cache->save($item);
        }
    }
202168
public function save() {
        $pk = $this->getPkField();
        //主键是id
        if (($pk == 'id' && $this->$pk) || $this->to_updata) {
            $this->update();
        } else {
            if ($this->$pk) {
                $this->checkHas();
            }
            if ($this->to_updata) {
                $this->update();
            } else {
                $this->insert();
            }
        }
    }
145946
public function save()
    {
        if ($this->_state == CRUD::CREATE_STAT) {
            $this->add();
        } elseif ($this->_state == CRUD::UPDATE_STAT) {
            $this->edit();
        }
    }
1067224
public function save()
    {


        $component = Component::findOneByName('api');
        $options   = $component->options;

        if (!isset($options['auth_drivers'])) {
            $options['auth_drivers'] = [];
        }
        $options['auth_drivers'] = $this->driversToUpdate;
        $component->options      = $options;
        $component->save();

        $this->cache->forget(self::$cacheKey);

        $this->container->make('antares.memory')->make('component')->getHandler()->forgetCache();
        $this->driversToUpdate = [];
    }
69219
function save($args)
    {
        $args = parent::save($args);

        $this->_load_drivers();

        $data = $args['path'] ? file_get_contents($args['path']) : $args['data'];

        $args['data'] = null;

        $key  = $this->_key($args);
        $data = base64_encode($data);

        $status = $this->cache->write($key, $data);

        if (!$status && $this->mem_cache) {
            $status = $this->mem_cache->write($key, $data);
        }

        if ($status) {
            $args['id'] = $key;
            $args['status'] = true;
        }

        return $args;
    }
99874
function saveFile($pFileName, $pContent)
    {
        $directory = \dirname($pFileName);

        if (!\is_dir($directory)) {
            try {
                $madeDir = \mkdir($directory, 0755, TRUE);

            } catch (\Exception $err) {
                throw new \Exception("mkdir: Unable make directory '{$directory}'.");
            }
        }

        // Save data to a file.
        $fileSaved = \file_put_contents($pFileName, $pContent); //, \LOCK_EX );

        if ($fileSaved === FALSE) {
            throw new \Exception("file_put_contents: Unable to save file '{$pFileName}'.");
        }

        return $fileSaved;
    }
944552
public function save(string $object, ...$options)
    {
        if (!$this->exists($object)) {
            $this->registry[$object] = [];
        }

        return;
    }
957355
public function saveGroups ($dc)
	{
		$db = Database::getInstance();
					
		// Change predefined groups
		if ($dc->activeRecord->type == 'protection' && !$dc->activeRecord->canChangeGroups)
		{
			// Serialize array if not
			$groups = is_array($dc->activeRecord->groups) ? serialize($dc->activeRecord->groups) : $dc->activeRecord->groups;
			
			// Save alias to database
			$db->prepare("UPDATE tl_content SET groups=? WHERE type=(SELECT alias FROM tl_elements WHERE id=?)")
			   ->execute($groups, $dc->activeRecord->pid);
		}
	}
1103709
public function save(array $data)
    {
		// All the services we need
		$main = $this->getServiceLocator()->get('neobazaar.service.main');
		$em = $main->getEntityManager();
		$documentRepository = $main->getDocumentEntityRepository();
		$userRepository = $main->getUserEntityRepository();
		$cache = $this->getServiceLocator()->get('ClassifiedCache');
		$form = $this->getServiceLocator()->get('document.form.classifiedimageadd');
    	
		$classifiedId = !empty($data['classifiedid']) ? $data['classifiedid'] : null;
	    $classified = null !== $classifiedId ? 
	        $documentRepository->findByEncryptedId($classifiedId, 'documentId') : null;
	    
	    // remove parent cache
		$cache = $this->getServiceLocator()->get('ClassifiedCache');
		if (!empty($classifiedId) && $cache->hasItem($classifiedId)) {
			$cache->removeItem($classifiedId);
		}
	    
		$userId = !empty($data['userid']) ? $data['userid'] : null;
	    $user = null !== $userId ? 
	        $userRepository->findByEncryptedId($userId, 'userId') : null;
		
		$entity = new Document();
		$form->setData($data);
		
		if (!$form->isValid()) {
			throw new \Exception(serialize($form->getMessages('files')));
		}
		
		$data = $form->getData();
			
		// @todo Better recover this in a smarter way
		$files = isset($data['files']) ? $data['files'] : array();
		$firstFile = reset($files);
		
		if(empty($firstFile)) {
			throw new \Exception(serialize(array('Empty file')));
		}
		
		$title = is_array($firstFile) && isset($firstFile['name']) ? 
			$firstFile['name'] : '';
			
		$entity->setDocumentType(Document::DOCUMENT_TYPE_IMAGE);
		$entity->setTitle($title);
		$entity->setParent($classified);
		$entity->setUser($user);
		$entity->setState(Document::DOCUMENT_STATE_ACTIVE);
		
		$em->persist($entity);
		$em->flush();
		
    	// trigger saveClassified event with the saved entity
    	$this->getEventManager()->trigger('imageSaved', null, $entity);
    	
    	return $entity;
    }
389412
private function saveSeed(Connection $connection, string $class): void
    {
        $format = $connection->getSchemaManager()->getDatabasePlatform()->getDateTimeFormatString();
        $now    = (new DateTimeImmutable())->format($format);
        $connection->insert($this->getSeedsTable(), [
            static::SEEDS_COLUMN_CLASS     => $class,
            static::SEEDS_COLUMN_SEEDED_AT => $now,
        ]);
    }
797396
public function save()
    {
        $query = new QueryBuilder(self::$_connection);

        if($this->_isInsert) {
            $query->insert($this->getTable())
                  ->values($this->_changed);

            $id = self::$_connection->insert($query->getQuery());
            $this->_data[$this->_primaryKey] = $id;

            $this->_isInsert = false;
            $this->_changed  = [];

            return;
        }

        $query->update($this->getTable())
              ->set($this->_changed)
              ->where([
                  $this->_primaryKey => $this->_data[$this->_primaryKey]
              ])
              ->execute();

        $this->_changed = [];
    }
822376
protected function save($flush = true)
    {
        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $em->persist($this);
        if ($flush) {
            $em->flush();
        }
    }