查询codeigniter仅在具有位数据类型的mysql DB中插入1

时间:2022-01-25 15:44:11

Hi i'm having problems with this queries, when i run the CI query, this inserts only '1' in all the columns, i tried running the query directly in phpmyadmin and do the same,then i inserted data by phpmyadmin and this create a different query and inserted correctly. This is created by phpmyadmin:

嗨我有这个查询的问题,当我运行CI查询时,这在所有列中只插入'1',我尝试直接在phpmyadmin中运行查询并执行相同的操作,然后我通过phpmyadmin插入数据并创建一个不同的查询并正确插入。这是由phpmyadmin创建的:

INSERT INTO `estancias`.`instalacion` (`idINSTALACION`, `sala_lactantes`, `sala_maternales`, `sala_preescolar`, `sala_usos_mult`, `a_recepcion`, `a_administrativa`, `sillas`, `archiveros`, `cuna_observacion`, `basc_estadimetro`, `botiquin`, `s_atencion_cunas`, `colchonetas`, `mesas_sillas_infantiles`, `muebles_guarda`, `area_lactancia`, `cocina_com_desp`, `consultorio`, `inst_sanitarias_ninos`, `inst_sanitarias_personal`, `area_juegos`, `area_educacion_preescolar`, `ventilacion`, `iluminacion`, `agua_potable`, `espacio_ninos`) VALUES (NULL, b'1', b'1', b'1', b'1', b'1', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0', '', b'0', b'0', b'0', b'0', b'0', b'0');

And this by codeigniter with the data from $_REQUEST and setted into $instalacion:

这是通过codeigniter与来自$ _REQUEST的数据并设置为$ instalacion:

$this->db->insert('instalacion',$instalacion);

INSERT INTO `instalacion` (`sala_lactantes`, `sala_maternales`, `sala_preescolar`, `sala_usos_mult`, `a_recepcion`, `a_administrativa`, `sillas`, `archiveros`, `cuna_observacion`, `basc_estadimetro`, `botiquin`, `s_atencion_cunas`, `colchonetas`, `mesas_sillas_infantiles`, `muebles_guarda`, `area_lactancia`, `cocina_com_desp`, `consultorio`, `inst_sanitarias_ninos`, `inst_sanitarias_personal`, `area_juegos`, `area_educacion_preescolar`, `ventilacion`, `iluminacion`, `agua_potable`, `espacio_ninos`) VALUES ('1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');

Thank you by advance for your participation!

提前感谢您的参与!

2 个解决方案

#1


0  

You may select varchar2 data type for all field except the id which must be integer.

您可以为除了必须为整数的id之外的所有字段选择varchar2数据类型。

#2


0  

foreach($_REQUEST as $key => $value){
           $instalacion->$key=(bool)$value;
        }

This was the problem, always you have to convert to bool cause if leave the data without convert this still like a STRING and gives problems.

这是问题,总是你必须转换为bool导致如果保留数据而不转换这仍然像STRING并给出问题。

Hope someone else help this!

希望其他人帮忙!

#1


0  

You may select varchar2 data type for all field except the id which must be integer.

您可以为除了必须为整数的id之外的所有字段选择varchar2数据类型。

#2


0  

foreach($_REQUEST as $key => $value){
           $instalacion->$key=(bool)$value;
        }

This was the problem, always you have to convert to bool cause if leave the data without convert this still like a STRING and gives problems.

这是问题,总是你必须转换为bool导致如果保留数据而不转换这仍然像STRING并给出问题。

Hope someone else help this!

希望其他人帮忙!