Jump to content


set_relation problem


  • Please log in to reply
11 replies to this topic

#1 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 20 April 2012 - 04:46 PM

Hi... I'm facing a problem here don't know why...

when I set the relation $crud->set_relation('id_tipo','tipos_parametros','descripcion');
I get a DB error.



ERROR: syntax error at or near "'parametros.descripcion'" LINE 1: ...scripcion as sb55f4aee, parametros.descripcion as 'parametro... ^

SELECT parametros.*, jb55f4aee.descripcion as sb55f4aee, parametros.descripcion as 'parametros.descripcion' FROM "parametros" LEFT JOIN "tipos_parametros" as jb55f4aee ON "jb55f4aee"."id_tipo" = "parametros"."id_tipo" LIMIT 10


the string in bold, it should be there If I remove the query is correct.

web-johnny can you help me here?

#2 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 20 April 2012 - 08:33 PM

So wierd... I made another new name same columns and worked... I think the problem was some name repited in name table or field tables...

#3 HumbleMonk

HumbleMonk

    Member

  • Members
  • PipPip
  • 25 posts

Posted 22 April 2012 - 02:20 AM

Weird.. I just had this same problem.

Tried to set a a relation and got a DB error. Dropped the table and recreated exactly the same and then it worked...

#4 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 04 May 2012 - 06:42 PM

shit the same problem again with relation =/ but re-create the table doesn't work this time...

Any ideas???

#5 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 04 May 2012 - 07:22 PM

worked again, due to add unique index. , problem kkeeps.. it worked to show the add form... but not working in list.
gives the same sql error...

#6 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 04 May 2012 - 11:09 PM

Can you please copy the structure of the two tables? I am sorry but I cannot reproduce the error. If you just post the structure of the basic table and the structure of the relation table to check it out it would be great.
Posted Image

#7 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 04 May 2012 - 11:27 PM

CREATE TABLE detalle_zonas
(
  id_detzona integer NOT NULL DEFAULT nextval('sec_id_detzona'::regclass),
  nombre character varying,
  descripcion character varying,
  usuario character varying,
  fecha_creacion timestamp without time zone DEFAULT now(),
  fecha_mod timestamp without time zone,
  codigo_comuna integer
)


CREATE UNIQUE INDEX pkdetalle_zona
  ON detalle_zonas
  USING btree
  (id_detzona );


CREATE TABLE geo_comunas
(
  codigo_region integer,
  codigo_provincia integer,
  nombre character varying,
  codigo_comuna integer
)


CREATE UNIQUE INDEX pk_asdasd
  ON geo_comunas
  USING btree
  (codigo_comuna );



$crud->set_table('detalle_zonas2');
$crud->columns('nombre','descripcion','usuario','fecha_creacion','codigo_comuna');
$crud->display_as('codigo_comuna','Comuna');
$crud->set_relation('codigo_comuna','geo_comunas','nombre');



please help =)

#8 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 04 May 2012 - 11:35 PM

The problem is that the grocery CRUD supports only mysql databases and mysqli only :( sorry but I cannot help you with your situation you have to change the model to make it work correctly.Perhaps someone else can help you but not me. Sorry again.
Posted Image

#9 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 04 May 2012 - 11:49 PM

deleted

#10 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 07 May 2012 - 01:16 PM

deleted

#11 jcasanova

jcasanova

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts

Posted 07 May 2012 - 03:50 PM

@web-johnny, I fixed the problem, it was a problem with the char ' in the get_list function in the model, because pg uses " instead of ' so the problem is fixed.


if($this->field_exists($related_field_title)){ 
     $select .= ", {$this->table_name}.$related_field_title as '{$this->table_name}.$related_field_title' ";
}

changed to:


if($this->field_exists($related_field_title)){ 
     $select .= ", {$this->table_name}.$related_field_title as \"{$this->table_name}.$related_field_title\"";
}



Thanks for your consern =)

I'm fixing this issues for a postgres version maybe you should add in the future.

Great Work!!

#12 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 07 May 2012 - 10:48 PM

Sorry jcasanova for the delayed answer. I am glad that you find the solution :)
Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users