/**
  * @see BackendAdapter::createResource
  */
 public function createResource(Resource $resource)
 {
     $id = $this->conn->getDatabasePlatform()->getName() == 'mysql' ? null : $this->conn->fetchColumn($this->conn->getDatabasePlatform()->getSequenceNextValSQL('xi_filelib_resource_id_seq'));
     $this->conn->insert('xi_filelib_resource', array('id' => $id, 'uuid' => $resource->getUuid(), 'hash' => $resource->getHash(), 'date_created' => $resource->getDateCreated()->format('Y-m-d H:i:s'), 'mimetype' => $resource->getMimetype(), 'exclusive' => $resource->isExclusive(), 'filesize' => $resource->getSize(), 'data' => json_encode($resource->getData()->toArray())), array(PDO::PARAM_INT, PDO::PARAM_STR, PDO::PARAM_STR, PDO::PARAM_STR, PDO::PARAM_STR, PDO::PARAM_BOOL, PDO::PARAM_INT, PDO::PARAM_STR));
     $id = $this->conn->getDatabasePlatform()->getName() == 'mysql' ? $this->conn->lastInsertId() : $id;
     $resource->setId($id);
     return $resource;
 }
Пример #2
0
 /**
  * @see BackendAdapter::createResource
  */
 public function createResource(Resource $resource)
 {
     $document = array('hash' => $resource->getHash(), 'uuid' => $resource->getUuid(), 'mimetype' => $resource->getMimetype(), 'size' => $resource->getSize(), 'date_created' => $resource->getDateCreated()->format('Y-m-d H:i:s'), 'data' => $resource->getData()->toArray(), 'exclusive' => $resource->isExclusive());
     $document['id'] = $this->createId();
     $this->create('resources', $document['id'], $document);
     $resource->setId($document['id']);
     return $resource;
 }
 /**
  * @see BackendAdapter::createResource
  */
 public function createResource(Resource $resource)
 {
     $resourceRow = new $this->resourceEntityName();
     $resourceRow->setUuid($resource->getUuid());
     $resourceRow->setHash($resource->getHash());
     $resourceRow->setDateCreated($resource->getDateCreated());
     $resourceRow->setMimetype($resource->getMimetype());
     $resourceRow->setSize($resource->getSize());
     $resourceRow->setExclusive($resource->isExclusive());
     $this->em->persist($resourceRow);
     $this->em->flush($resourceRow);
     $resource->setId($resourceRow->getId());
     return $resource;
 }
Пример #4
0
 /**
  * @see BackendAdapter::createResource
  */
 public function createResource(Resource $resource)
 {
     $document = array('uuid' => $resource->getUuid(), 'hash' => $resource->getHash(), 'mimetype' => $resource->getMimetype(), 'size' => $resource->getSize(), 'date_created' => new MongoDate($resource->getDateCreated()->getTimestamp()), 'data' => $resource->getData()->toArray(), 'exclusive' => $resource->isExclusive());
     $this->getMongo()->resources->ensureIndex(array('hash' => 1), array('unique' => false));
     $this->getMongo()->resources->insert($document, array('w' => true));
     $resource->setId((string) $document['_id']);
     return $resource;
 }