/** * Returns a new ProveedoritradearchivoQuery object. * * @param string $modelAlias The alias of a model in the query * @param ProveedoritradearchivoQuery|Criteria $criteria Optional Criteria to build the query from * * @return ProveedoritradearchivoQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ProveedoritradearchivoQuery) { return $criteria; } $query = new ProveedoritradearchivoQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Returns the number of related Proveedoritradearchivo objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Proveedoritradearchivo objects. * @throws PropelException */ public function countProveedoritradearchivos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collProveedoritradearchivosPartial && !$this->isNew(); if (null === $this->collProveedoritradearchivos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collProveedoritradearchivos) { return 0; } if ($partial && !$criteria) { return count($this->getProveedoritradearchivos()); } $query = ProveedoritradearchivoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByProveedoritrade($this)->count($con); } return count($this->collProveedoritradearchivos); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ProveedoritradearchivoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ProveedoritradearchivoQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function dropzonedownloadAction() { $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); //obtnemos el id del archivo $id = $post_data['id']; $entity = \ProveedoritradearchivoQuery::create()->findPk($id); $file_path = $entity->getProveedoritradearchivoArchivo(); $file_name = explode('/files/proveedores/' . $entity->getIdproveedoritrade() . '/', $entity->getProveedoritradearchivoArchivo()); $file_name = $file_name[1]; $taget_file = $_SERVER['DOCUMENT_ROOT'] . $entity->getProveedoritradearchivoArchivo(); $file_base64 = base64_encode(file_get_contents($taget_file)); $file_type = mime_content_type($taget_file); return $this->getResponse()->setContent(json_encode(array('base64' => $file_base64, 'type' => $file_type, 'name' => $file_name))); } }