Exemple #1
0
 public function __construct(Classmap $classMap, $index = NULL)
 {
     $this->classMap = $classMap;
     $this->baseObject = $this->classMap->getObject();
     $this->manager = PersistentManager::getInstance();
     $this->index = $index;
 }
 public function queryAction()
 {
     $q = new Query();
     $q->addAggregation(SelectAggregation::AGTN_DISTINTC, 'p', 'nombre')->addFrom('hello_world_persona', 'p')->setCondition(Condition::GT('p', "edad", 25));
     $pm = PersistentManager::getInstance();
     $result = $pm->findByQuery($q);
     return $this->renderString(print_r($result, true));
 }
 public function __construct(ClassMap $fromClassMap, $name)
 {
     $this->manager = PersistentManager::getInstance();
     $this->fromClassMap = $fromClassMap;
     $this->fromClassName = $fromClassMap->getName();
     $this->name = $name;
     $this->inverse = FALSE;
 }
Exemple #4
0
 public function __construct($name, $databaseName, \IPersistentManager $manager = null)
 {
     $this->name = $name;
     $p = strrpos($name, '\\');
     $this->namespace = substr($name, 0, $p);
     $this->databaseName = $databaseName;
     $this->manager = $manager ?: PersistentManager::getInstance();
     $this->db = $this->manager->getConnection($databaseName);
     $this->platform = $this->db->getPlatform();
     $this->hasTypedAttribute = FALSE;
 }
 public function __construct($classMap = NULL)
 {
     $this->manager = PersistentManager::getInstance();
     $this->setClassMap($classMap);
     // Fill tables with tableMaps
     // Create CriteriaCondition for the WHERE part of this criteria
     $this->whereCondition = $this->getNewCondition();
     //$this->whereCondition->setCriteria($this);
     // Create condition for the HAVING part of this criteria
     $this->havingCondition = $this->getNewCondition();
     //$this->havingCondition->setCriteria($this);
 }
 public function test1()
 {
     PersistentManager::getInstance()->generateAll();
     echo YuppConventions::tableName('Pagina') . "<br/>";
     /**
      * Resultado>
      * 
      * CREATE TABLE test_a004_pagina (id INT(11) DEFAULT 1 PRIMARY KEY, titulo VARCHAR(255) NULL, contenido MEDIUMTEXT NULL, class TEXT NOT NULL, deleted BOOL NOT NULL, owner_id INT(11) NULL);
      * 
      * CREATE TABLE test_a004_pagina_subpages_test_a004_pagina (id INT(11) DEFAULT 1 PRIMARY KEY, owner_id INT(11) NOT NULL, ref_id INT(11) NOT NULL, type INT(11) NOT NULL, deleted BOOL NOT NULL, class TEXT NOT NULL, ord INT(11) NULL);
      * 
      * ALTER TABLE test_a004_pagina_subpages_test_a004_pagina ADD FOREIGN KEY (owner_id) REFERENCES test_a004_pagina(id);
      * 
      * ALTER TABLE test_a004_pagina_subpages_test_a004_pagina ADD FOREIGN KEY (ref_id) REFERENCES test_a004_pagina(id);
      * 
      * ALTER TABLE test_a004_pagina ADD FOREIGN KEY (owner_id) REFERENCES test_a004_pagina(id);
      * 
      */
     // TODO: verificar si la tabla para Nariz y Cara fue creada.
     //$dal = DAL::getInstance();
     $dal = new DAL('tests');
     $this->assert($dal->tableExists(YuppConventions::tableName('Pagina')), 'TestCaseA004: Test generar tabla');
 }
Exemple #7
0
 private function test1()
 {
     PersistentManager::getInstance()->generateAll();
     echo YuppConventions::tableName('M010_Persona') . "<br/>";
     /**
      * Resultado>
      * 
      * CREATE TABLE test_m010_persona (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   nombre TEXT NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL
      * );
      * 
      * CREATE TABLE test_m010_persona_hijos_test_m010_persona (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   owner_id INT(11) NOT NULL,
      *   ref_id INT(11) NOT NULL,
      *   type INT(11) NOT NULL,
      *   deleted BOOL NOT NULL,
      *   class TEXT NOT NULL,
      *   ord INT(11) NULL
      * );
      * 
      */
     // TODO: verificar si la tabla para Nariz y Cara fue creada.
     //$dal = DAL::getInstance();
     $dal = new DAL('tests');
     if ($dal->tableExists(YuppConventions::tableName('M010_Persona'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
 }
 public static function find($select = '*', $where = '', $orderBy = '')
 {
     $className = get_called_class();
     $classMap = PersistentManager::getInstance()->getClassMap($className);
     $criteria = new RetrieveCriteria($classMap);
     $criteria->select($select)->where($where)->orderBy($orderBy);
     return $criteria;
 }
Exemple #9
0
 private function test1()
 {
     PersistentManager::getInstance()->generateAll();
     echo YuppConventions::tableName('Contenido1') . "<br/>";
     echo YuppConventions::tableName('Recipiente1') . "<br/>";
     echo YuppConventions::tableName('Vaso1') . "<br/>";
     /**
      * Resultado>
      * 
      * CREATE TABLE test_i006_contenido1 (id INT(11) DEFAULT 1 PRIMARY KEY, elemento VARCHAR(30) NULL, volumen FLOAT NULL, class TEXT NOT NULL, deleted BOOL NOT NULL);
      * 
      * CREATE TABLE test_i005_contenido (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   elemento VARCHAR(30) NULL,
      *   volumen FLOAT NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL
      * );
      * 
      * CREATE TABLE test_i006_vaso1 (id INT(11) DEFAULT 1 PRIMARY KEY, marca TEXT NULL, class TEXT NOT NULL, deleted BOOL NOT NULL, contenido_id INT(11) NULL, super_id_recipiente1 INT(11) NOT NULL);
      * 
      * CREATE TABLE test_i005_vaso (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   marca TEXT NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL,
      *   contenido_id INT(11) NULL,
      *   super_id_recipiente INT(11) NOT NULL
      * );
      * 
      * CREATE TABLE test_i006_recipiente1 (id INT(11) DEFAULT 1 PRIMARY KEY, material VARCHAR(30) NULL, capacidad FLOAT NULL, tieneTapa BOOL NULL, class TEXT NOT NULL, deleted BOOL NOT NULL);
      * 
      * CREATE TABLE test_i005_recipiente (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   material VARCHAR(30) NULL,
      *   capacidad FLOAT NULL,
      *   tieneTapa BOOL NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL
      * );
      * 
      * ALTER TABLE test_i006_vaso1 ADD FOREIGN KEY (super_id_recipiente1) REFERENCES test_i006_recipiente1(id);
      * 
      * ALTER TABLE test_i005_vaso
      *   ADD FOREIGN KEY (super_id_recipiente)
      *   REFERENCES test_i005_recipiente(id);
      * 
      * ALTER TABLE test_i006_vaso1 ADD FOREIGN KEY (contenido_id) REFERENCES test_i005_contenido(id);
      * 
      * ALTER TABLE test_i005_vaso
      *   ADD FOREIGN KEY (contenido_id)
      *   REFERENCES test_i005_contenido(id);
      */
     // TODO: verificar si la tabla para Nariz y Cara fue creada.
     //$dal = DAL::getInstance();
     $dal = new DAL('tests');
     if ($dal->tableExists(YuppConventions::tableName('Contenido1'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
     if ($dal->tableExists(YuppConventions::tableName('Recipiente1'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
     if ($dal->tableExists(YuppConventions::tableName('Vaso1'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
 }
Exemple #10
0
 public static function getTableName($className)
 {
     $manager = PersistentManager::getInstance();
     $classMap = $manager->getClassMap($className);
     return $classMap->getTableName();
 }
Exemple #11
0
 public function __construct()
 {
     $this->conn = PersistentManager::getInstance()->get_connection();
 }
 /**
  * Elimina un elemento de la base de datos, eliminacion fisica por defecto.
  * @param boolean $logical indica si la eliminacion es logica (true) o fisica (false).
  * @todo: hacer delete por clase/id, esta es solo por instancia.
  */
 public function delete($logical = false)
 {
     Logger::getInstance()->po_log("delete {$logical}");
     // FIXME: devolver algo que indique si se pudo o no eliminar.
     // FIXME: si no esta salvado (no tiene id), no se puede hacer delete.
     PersistentManager::getInstance()->delete($this, $this->getId(), $logical);
     // FIXME: no necesita pasarle el id, el objeto ya lo tiene...
     // http://code.google.com/p/yupp/issues/detail?id=127
     if ($logical) {
         $this->setDeleted(true);
     }
 }
Exemple #13
0
 private function test1()
 {
     PersistentManager::getInstance()->generateAll();
     echo YuppConventions::tableName('Dedo') . "<br/>";
     echo YuppConventions::tableName('Mano') . "<br/>";
     /**
      * Resultado>
      * 
      * CREATE TABLE test_m003_dedo (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   uniaLarga BOOL NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL
      * );
      * 
      * CREATE TABLE test_m003_mano (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   tamanio TEXT NULL,
      *   class TEXT NOT NULL,
      *   deleted BOOL NOT NULL
      * );
      * 
      * CREATE TABLE test_m003_mano_dedos_test_m003_dedo (
      *   id INT(11) DEFAULT 1 PRIMARY KEY,
      *   owner_id INT(11) NOT NULL,
      *   ref_id INT(11) NOT NULL,
      *   type INT(11) NOT NULL,
      *   deleted BOOL NOT NULL,
      *   class TEXT NOT NULL,
      *   ord INT(11) NULL
      * );
      * 
      * ALTER TABLE test_m003_mano_dedos_test_m003_dedo
      *   ADD FOREIGN KEY (owner_id)
      *   REFERENCES test_m003_mano(id);
      * 
      * ALTER TABLE test_m003_mano_dedos_test_m003_dedo
      *   ADD FOREIGN KEY (ref_id)
      *   REFERENCES test_m003_dedo(id);
      * 
      */
     // TODO: verificar si la tabla para Nariz y Cara fue creada.
     //$dal = DAL::getInstance();
     $dal = new DAL('tests');
     if ($dal->tableExists(YuppConventions::tableName('Dedo'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
     if ($dal->tableExists(YuppConventions::tableName('Mano'))) {
         echo "Test 1 correcto";
     } else {
         echo "Test 1 Incorrecto";
     }
 }
 /**
  * Get Criteria
  *
  */
 public static function getCriteria($className = '')
 {
     $criteria = NULL;
     if ($className != '') {
         $manager = PersistentManager::getInstance();
         $classMap = $manager->getClassMap($className);
         $criteria = new RetrieveCriteria($classMap);
     }
     return $criteria;
 }