Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/06/2011, 09:21
Avatar de SirDuque
SirDuque
 
Fecha de Ingreso: febrero-2009
Ubicación: Paso del Rey, Buenos Aires, Argentina
Mensajes: 975
Antigüedad: 15 años, 2 meses
Puntos: 89
Respuesta: Importando CSV no me toma DOUBLE, INT, DATE en MySQL

Cita:
Iniciado por the_web_saint Ver Mensaje
Intenta algo como esto,

Código SQL:
Ver original
  1. INSERT sistema_cuota (`importe`) VALUES (CAST('11.85' AS DECIMAL(22,2)))

Slds
tiene el mismo efecto, al recibir del fgetcsv() el $data[8] que es el decimal,
lo inserta como '0', lo que no entiendo es por que los INT DATE y demas los toma como '0' si uso el mismo screep para otras tablas y inserta bien.
Lo peor de todo esta es la principal.

$sql = "INSERT sistema_cuota (`importe`) values (CAST('$importe' as decimal (22,2)) )";

Tabla:
Código MySQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `sistema_cuota` (
  2.   `socio` text COLLATE latin1_general_ci NOT NULL,
  3.   `periodo` text COLLATE latin1_general_ci NOT NULL,
  4.   `forma_pago` text COLLATE latin1_general_ci NOT NULL,
  5.   `factura` text COLLATE latin1_general_ci NOT NULL,
  6.   `articulo` text COLLATE latin1_general_ci NOT NULL,
  7.   `vencimiento` date NOT NULL,
  8.   `totalcuota` text COLLATE latin1_general_ci NOT NULL,
  9.   `cuota` text COLLATE latin1_general_ci NOT NULL,
  10.   `importe` decimal(22,2) NOT NULL,
  11.   `tipo` text COLLATE latin1_general_ci NOT NULL,
  12.   `comprobante` text COLLATE latin1_general_ci NOT NULL,
  13.   `recpag` text COLLATE latin1_general_ci NOT NULL,
  14.   `concepto` text COLLATE latin1_general_ci NOT NULL,
  15.   `fecha` date NOT NULL,
  16.   `hora` time NOT NULL,
  17.   `opera_id` text COLLATE latin1_general_ci NOT NULL,
  18.   `fecha_ob` date NOT NULL,
  19.   `observacion` text COLLATE latin1_general_ci NOT NULL,
  20.   PRIMARY KEY (`id`)
  21. ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=36075 ;
la cambien a UTF8 y tampo doy con el clavo.
__________________
Mono programando!
twitter.com/eguimariano