⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

set_relation problem



jcasanova
  • profile picture
  • Member

Posted 20 April 2012 - 16: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[b], parametros.descripcion as 'parametros.descripcion'[/b] 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?

jcasanova
  • profile picture
  • Member

Posted 20 April 2012 - 20: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...

HumbleMonk
  • profile picture
  • Member

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...

jcasanova
  • profile picture
  • Member

Posted 04 May 2012 - 18:42 PM

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

Any ideas???

jcasanova
  • profile picture
  • Member

Posted 04 May 2012 - 19: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...

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 04 May 2012 - 23: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.

jcasanova
  • profile picture
  • Member

Posted 04 May 2012 - 23: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 =)

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 04 May 2012 - 23: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.

jcasanova
  • profile picture
  • Member

Posted 04 May 2012 - 23:49 PM

deleted

jcasanova
  • profile picture
  • Member

Posted 07 May 2012 - 13:16 PM

deleted

jcasanova
  • profile picture
  • Member

Posted 07 May 2012 - 15: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!!

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 07 May 2012 - 22:48 PM

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