Set_relation_n_n杂货店crud和condeigniter以及MYSQL

时间:2015-11-18 15:16:26

标签: php mysql codeigniter mysql-error-1064

我在杂货店crud中使用set_relation_n_n时遇到问题

问题是mysql告诉我,检索数据的数据库有错误的MySQL 5.6.23语法的查询是我服务器的版本。并且不知道在哪里可以找到不允许我编辑系统中字段的解决方案

我把这两张桌子搞错了

  

TABLE Docente_Escuela(Id_afiliado int(11)NOT NULL,
  Id_escuela int(11)NOT NULL,优先级 int(11)NOT NULL,
  PRIMARY KEY(id_afiliadoid_escuela))ENGINE = InnoDB DEFAULT   CHARSET = utf8 COLLATE = utf8_swedish_ci;

另一个

  

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 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,
邮件 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;

和表会员

  

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 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,
  邮件 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;

所以我打电话给系统

  

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

这是错误

  

错误号码:1064

     

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近'WHERE``Escuela . id_escuela id_afiliado ='5'ORDER BY   Docente_Escuela。第3行的'pri'

     

SELECT * FROM s7a675883 name as Docente_Escuela Escuela ON LEFT JOIN Docente_Escuela。 Id_escuela =``WHERE Escuela . id_escuela id_afiliado ='5'订购Docente_Escuelapriority

     

文件名:models / Grocery_crud_model.php

     

行号:336

有人可以帮助我推进一下吗?我被锁了

谢谢!! 布鲁诺

1 个答案:

答案 0 :(得分:1)

您的crud通话中存在语法错误。

$crud->set_relation'id_afiliado'之间检查'id_escuela'中缺少的逗号。