3
votes

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_afiliadoint (11) NOT NULL,
  Id_escuelaint (11) NOT NULL,   Priorityint (11) NOT NULL,
  PRIMARY KEY (id_afiliado,id_escuela) )
ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_swedish_ci;

the other

TABLE Escuela (   Id_escuelaint (11) NOT NULL AUTO_INCREMENT,
  Numerovarchar (10) NOT NULL utf8_spanish_ci COLLATE,
  Name varchar (200) NOT NULL utf8_spanish_ci COLLATE,
  Domiciliovarchar (100) NOT NULL utf8_spanish_ci COLLATE,
  Id_nivelint (11) NOT NULL,   Id_modalidadint (11) NOT NULL,
  Id_ciudadint (11) NOT NULL,  
 Cod_postalvarchar (30) NOT NULL utf8_spanish_ci COLLATE,
  Telefonovarchar (50) NOT NULL utf8_spanish_ci COLLATE,
  Celular varchar (50) NOT NULL utf8_spanish_ci COLLATE,
  Mailvarchar (100) NOT NULL utf8_spanish_ci COLLATE,
  Mail_altvarchar (100) NOT NULL utf8_spanish_ci COLLATE,
  Mail_alt_2varchar (100) NOT NULL utf8_spanish_ci COLLATE,
  Observacionesint (11) NOT NULL,
  Clave_cobrovarchar (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_afiliadoint (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,
  Domiciliovarchar (200) NOT NULL utf8_spanish2_ci COLLATE,
  Id_situacionint (11) NOT NULL,   Id_localidadint (11) NOT NULL,
  Id_provinciaint (11) NOT NULL,
  Cod_postalvarchar (30) NOT NULL utf8_spanish2_ci COLLATE,
  Telefono_fijovarchar (30) NOT NULL utf8_spanish2_ci COLLATE,
  Telefono_altvarchar (30) NOT NULL utf8_spanish2_ci COLLATE,  
 Celularvarchar (30) NOT NULL utf8_spanish2_ci COLLATE,
  Mailvarchar (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_escuelaid_afiliado =' 5 'ORDER BY Docente_Escuela.`pri' at line 3

SELECT * FROM s7a675883 name as Docente_Escuela EscuelaON 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

1
Check the missing comma in your $crud->set_relation between 'id_afiliado' and 'id_escuela' . - sotoz
Thanks!! I clean the white spaces in the sentences and works fine now!! thanks!! - Bruno Gelman
happy to be helpful. I added my comment as an answer so you can accept it. - sotoz

1 Answers

1
votes

You have a syntax error on your crud call.

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