public function __construct(array $config) { parent::__construct(new Adapter\Mapping()); $this->baseUrl = $config["host"] . "/c/" . $config["company"]; $this->sslVersion = isset($config["ssl_version"]) ? (int) $config["ssl_version"] : null; $this->user = isset($config["user"]) ? $config["user"] : null; if ($this->user !== null) { if (isset($config["password"])) { $this->password = $config["password"]; } else { throw new \Exception("Password is required if user set!"); } } }
public function __construct(array $config) { parent::__construct(new Adapter\Mapping()); $this->connection = new \DibiConnection($config); }
private function _save($primaryValue, Adapter $joinAdapter, Adapter $targetAdapter, Entity\Collection $collection, $action = Adapter\IAdapter::ASSOC_ADD) { if ($action === Adapter\IAdapter::ASSOC_REMOVE) { $assocKeys = $collection->getChanges()[Entity::CHANGE_DETACH]; foreach ($collection->getChanges()[Entity::CHANGE_REMOVE] as $targetPrimary) { $targetAdapter->execute($targetAdapter->createDeleteOne($this->targetReflection->getAdapterResource(), $this->targetReflection->getPrimaryProperty()->getName(true), $targetPrimary)); $assocKeys[] = $targetPrimary; } } else { $assocKeys = $collection->getChanges()[Entity::CHANGE_ATTACH]; foreach ($collection->getChanges()[Entity::CHANGE_ADD] as $entity) { $assocKeys[] = $targetAdapter->execute($targetAdapter->createInsert($this->targetReflection->getAdapterResource(), $entity->getData(), $this->targetReflection->getPrimaryProperty()->getName(true))); } } if ($assocKeys) { $adapterQuery = $joinAdapter->createModifyManyToMany($this, $primaryValue, array_unique($assocKeys), $action); $joinAdapter->execute($adapterQuery); } }