简体   繁体   中英

Set_relation_n_n grocery crud and condeigniter and MYSQL

I have a problem when i use set_relation_n_n in grocery crud

The problem is that the mysql tells me that the query that the database to retrieve the data has bad syntax for MySQL 5.6.23 is the version of my server. and do not know where I can find a solution that does not allow me to edit the fields in the system

I put the two tables in conflict

TABLE Docente_Escuela ( Id_afiliado int (11) NOT NULL,
Id_escuela int (11) NOT NULL, Priority int (11) NOT NULL,
PRIMARY KEY ( id_afiliado , id_escuela ) )
ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_swedish_ci;

the other

TABLE Escuela ( Id_escuela int (11) NOT NULL AUTO_INCREMENT,
Numero varchar (10) NOT NULL utf8_spanish_ci COLLATE,
Name varchar (200) NOT NULL utf8_spanish_ci COLLATE,
Domicilio varchar (100) NOT NULL utf8_spanish_ci COLLATE,
Id_nivel int (11) NOT NULL, Id_modalidad int (11) NOT NULL,
Id_ciudad int (11) NOT NULL,
Cod_postal varchar (30) NOT NULL utf8_spanish_ci COLLATE,
Telefono varchar (50) NOT NULL utf8_spanish_ci COLLATE,
Celular varchar (50) NOT NULL utf8_spanish_ci COLLATE,
Mail varchar (100) NOT NULL utf8_spanish_ci COLLATE,
Mail_alt varchar (100) NOT NULL utf8_spanish_ci COLLATE,
Mail_alt_2 varchar (100) NOT NULL utf8_spanish_ci COLLATE,
Observaciones int (11) NOT NULL,
Clave_cobro varchar (10) NOT NULL utf8_spanish_ci COLLATE,
Status tinyint (1) NOT NULL DEFAULT '1' PRIMARY KEY ( id_escuela ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_spanish_ci AUTO_INCREMENT = 2;

and table affiliate

TABLE Afiliado ( Id_afiliado int (11) NOT NULL AUTO_INCREMENT,
Name varchar (100) NOT NULL utf8_spanish2_ci COLLATE,
Apellido varchar (100) NOT NULL utf8_spanish2_ci COLLATE,
Documento varchar (11) NOT NULL utf8_spanish2_ci COLLATE,
Domicilio varchar (200) NOT NULL utf8_spanish2_ci COLLATE,
Id_situacion int (11) NOT NULL, Id_localidad int (11) NOT NULL,
Id_provincia int (11) NOT NULL,
Cod_postal varchar (30) NOT NULL utf8_spanish2_ci COLLATE,
Telefono_fijo varchar (30) NOT NULL utf8_spanish2_ci COLLATE,
Telefono_alt varchar (30) NOT NULL utf8_spanish2_ci COLLATE,
Celular varchar (30) NOT NULL utf8_spanish2_ci COLLATE,
Mail varchar (100) NOT NULL utf8_spanish2_ci COLLATE,
Mail_alt varchar (100) NOT NULL utf8_spanish2_ci COLLATE,
Clave_cobro varchar (20) NOT NULL utf8_spanish2_ci COLLATE,
Valor_cuota varchar (20) NOT NULL utf8_spanish2_ci COLLATE,
Status tinyint (1) NOT NULL DEFAULT '1' PRIMARY KEY ( id_afiliado ) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_spanish2_ci AUTO_INCREMENT = 6;

so I call on the system

$ Crud-> set_relation_n_n ('Schools', 'Docente_Escuela', 'School', 'id_afiliado' 'id_escuela', 'name', 'priority');

and this is the error

Error Number: 1064

You have an error in your SQL syntax; check the Manual That corresponds to your MySQL server version for the right syntax to use near 'WHERE `` Escuela . id_escuela id_afiliado =' 5 'ORDER BY Docente_Escuela .`pri' at line 3

SELECT * FROM s7a675883 name as Docente_Escuela Escuela ON LEFT JOIN Docente_Escuela . Id_escuela = `` WHERE Escuela . id_escuela id_afiliado = '5' ORDER BY Docente_Escuela . priority

Filename: models / Grocery_crud_model.php

Line Number: 336

Someone can give me a hand where I can advance? I'm locked

Thank you!! Bruno

You have a syntax error on your crud call.

Check the missing comma in your $crud->set_relation between 'id_afiliado' and 'id_escuela' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM