Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/06/2011, 12:21
Avatar de Kodee
Kodee
 
Fecha de Ingreso: junio-2011
Mensajes: 11
Antigüedad: 12 años, 10 meses
Puntos: 0
Pregunta Doctrine Posgree Error, usando CodeIgniter.

Hola a todos y gracias por su tiempo anticipadamente.
Les cuento que estoy desarrollando una App usando CodeIgniter 1.7.2 y Doctrine 1.2.2 ambos integrados perfectamente, el formato de Base de Datos es Postgrees.
8.4.1
Sin embargo a la hora de insertar un obj de la forma clasica

Código PHP:
obj->save() 
Estoy obteniendo un extraño error por parte de Doctrine.

El codigo implicado es el siguiente.


METODO DEL CONTROLADOR QUE RECIBE LOS PARAMETROS
fichero: paciente_controller.php extiende de Controller

Código PHP:
function salvar() {

        
$paciente = new Paciente(PacienteTable::getInstance(), true);
        
$carnet $this->input->post('carnet');
        
$nombre $this->input->post('nombre');
        
$apellidos $this->input->post('apellidos');
        
$grado $this->input->post('grado');
        
$estado_civil $this->input->post('estado_civil');
        
$sexo $this->input->post('sexo');
        
$color_piel $this->input->post('color_piel');
        
$fecha_nacimiento $this->input->post('fecha_nacimiento');
        
$lugar_nacimiento $this->input->post('lugar_nacimiento');
        
$um $this->input->post('um');
        
$edad $this->input->post('edad');
        
$direccion $this->input->post('direccion');
        
        
$paciente->salvar($carnet$nombre$apellidos$grado$estado_civil$sexo$color_piel$fecha_nacimiento$lugar_nacimiento$um$edad$direccion);

    } 
METODO QUE SE ENCARGA DE SALVAR EL OBJETO, ESTA ALOJADO EN LA CLASE DEL MODELO QUE EXTIENDE DE LA BASE.
fichero: Paciente.php extiende de BasePaciente

Código PHP:
public function salvar($carnet,$nombre,$apellidos$grado$estado_civil$sexo$color_piel,
                         
$fecha_nacimiento,$lugar_nacimiento,$um$edad$direccion)
  {

      
$this->carnet $carnet;
      
$this->nombre $nombre;
      
$this->apellidos $apellidos;
      
$this->grado $grado;
      
$this->estado_civil $estado_civil;
      
$this->sexo $sexo;
      
$this->color_piel $color_piel;
      
$this->fecha_nacimiento $fecha_nacimiento;      
      
$this->lugar_nacimiento =  $lugar_nacimiento;
      
$this->um $um;
      
$this->edad $edad;
      
$this->direccion =  $direccion;

          try {
              
$this->save();
              
$result["success"] = true;
          }
          catch (
Doctrine_Validator_Exception $e) {
              
$errors $this->getErrorStackAsString();
              
$errorStack $this->getErrorStack();
              
$result["success"] = false;
              
$result["errors"]["reason"] = $errors;
                foreach(
$errorStack as $fieldName => $errorCodes) {
                   
$result["errors"][$fieldName]= $fieldName " - " implode(', '$errorCodes);// . "\n";
                 
}
          }

      echo 
json_encode($result);
      return  
json_encode($result);
    } 
Y a continuacion les muestro la excepcion que lanza Doctrine, es de tipo Doctrine_Connection_Pgsql_Exception

Uncaught exception 'Doctrine_Connection_Pgsql_Exception' with message 'SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(1)' in C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doc trine\Connection.php:1082


El codigo anterior funciona perfectamente, con una BD mysql, les adelanto, que los parametros del objetos son correctamente enviados, lo notaran en la validacion que se hace en el metodo salvar, la cual verifica que no halla errores en los paramentros.

Alguna idea de porque se produce este error? De donde proviene o como puede ser resuelto?

Para los mas avezados publico el Stack trace, quizas peudan definir la causa del mismo.

Código HTML:
<b>Fatal error</b>:  Uncaught exception 'Doctrine_Connection_Pgsql_Exception' with message 'SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(1)' in C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection.php:1082
Stack trace:
#0 C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection\Statement.php(269): Doctrine_Connection-&gt;rethrowException(Object(PDOException), Object(Doctrine_Connection_Statement))
#1 C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection.php(1042): Doctrine_Connection_Statement-&gt;execute(Array)
#2 C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection\Pgsql.php(244): Doctrine_Connection-&gt;exec('INSERT INTO pac...', Array)
#3 C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(635): Doctrine_Connection_Pgsql-&gt;insert(Object(PacienteTable), Array)
#4 C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(566): Doctrine_Connection in <b>C:\wamp\www\Peritaje\apps\plugins\doctrine\lib\Doctrine\Connection.php</b> on line <b>1082</b><br /> 
Saludos y gracias por la ayuda.