Ejemplo n.º 1
0
 public static function instance()
 {
     if (!self::$instancia instanceof self) {
         self::$instancia = new self();
     }
     return self::$instancia;
 }
Ejemplo n.º 2
0
 /**
  * Se debe explorar el Criteria Result para ver el tipo de objeto que retorna
  * @param <type> Object
  * @return <type> CriteriaResult
  */
 public function find($object)
 {
     $oReflectionClass = new ReflectionClass($object);
     //$properties = $oReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC);
     $properties = $oReflectionClass->getProperties();
     $this->className = $class = $oReflectionClass->getName();
     foreach ($properties as $key => $reflectionProperty) {
         $datos_where[$reflectionProperty->getName()] = $reflectionProperty->getValue($object);
     }
     $this->setList(null);
     $this->setObject(null);
     $table = $this->table = CriteriaEntityMgr::instance()->findTable($this->className);
     $this->SQL = MySQL_DB::instance()->DBSQLSelect($table, null, $datos_where, $this->array_order, $this->type_order);
     $this->execute();
     $list = array();
     if ($this->getNumRows() == 1) {
         $row = MySQL_DB::instance()->DBFetchArray($this->result);
         $object = $this->iterateProperty($class, $object, $row, $properties);
         $this->setObject($object);
         $list[] = $object;
     }
     if ($this->getNumRows() > 1) {
         while ($row = MySQL_DB::instance()->DBFetchArray($this->result)) {
             $object_new = $oReflectionClass->newInstance($oReflectionClass);
             $object_new = $this->iterateProperty($class, $object_new, $row, $properties);
             $list[] = $object_new;
         }
     }
     $this->setList($list);
     return $this;
 }