public function getDBType($type, $constraints) { $dbms_type = NULL; if (Datatypes::isText($type)) { $maxLength = NULL; // TODO: Falta ver si tengo restricciones de maxlength!!! $maxLengthConstraint = NULL; if ($constraints !== NULL) { foreach ($constraints as $constraint) { if (get_class($constraint) === 'MaxLengthConstraint') { $maxLengthConstraint = $constraint; break; // rompe for } } } //$maxLengthConstraint = $obj->getConstraintOfClass( $attr, MaxLengthConstraint ); if ($maxLengthConstraint !== NULL) { $maxLength = $maxLengthConstraint->getValue(); } $dbms_type = $this->getTextType($type, $maxLength); // Devuelve VARCHAR, TEXT, o el tipo correcto dependiendo del maxlength. } else { if (Datatypes::isNumber($type)) { $dbms_type = $this->getNumericType($type); } else { if (Datatypes::isDateTime($type)) { $dbms_type = $this->getDateTimeType($type); } else { throw new Exception("DatabasePosgreSQL.getDBType: el tipo ({$type}) no esta definido."); } } } return $dbms_type; }
public function getDBType($type, $constraints) { $dbms_type = NULL; if (Datatypes::isText($type)) { $maxLength = NULL; $maxLengthConstraint = NULL; if ($constraints !== NULL) { foreach ($constraints as $constraint) { if (get_class($constraint) === 'MaxLengthConstraint') { $maxLengthConstraint = $constraint; break; // rompe for } } } // FIXME: no tengo este metodo? para que se hace la busqueda aca? En MySQL debe estar igual... //$maxLengthConstraint = $obj->getConstraintOfClass( $attr, MaxLengthConstraint ); if ($maxLengthConstraint !== NULL) { $maxLength = $maxLengthConstraint->getValue(); } $dbms_type = $this->getTextType($type, $maxLength); // Devuelve VARCHAR, TEXT, o el tipo correcto dependiendo del maxlength. } else { if (Datatypes::isNumber($type)) { $dbms_type = $this->getNumericType($type); } else { if (Datatypes::isDateTime($type)) { $dbms_type = $this->getDateTimeType($type); } else { throw new Exception("DatabaseMySQL.getDBType: el tipo ({$type}) no esta definido."); } } } return $dbms_type; }