⚠ 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

CRUD in a view, with set_primary_key, no work



jariberi

jariberi
  • profile picture
  • Member

Posted 15 May 2013 - 22:52 PM

Hello! Sorry for my english, i have a problem.

 

I have 2 tables:

 

entidades (cuit, denominacion, direccion)

detalle_clientes (idclientes, limite_credito)

 

and a view:

clientes defined as:

 

 

select entidades.cuit, detalle_clientes.idclientes, entidades.denominacion,entidades.direccion, detalle_clientes.limite_credito from entidades inner join detalle_clientes on entidades.cuit=detalle_clientes.entidades_cuit;
 
Show the data, the grid, but when i want add or edit, not work. No inform any error, just freeze.
 
Here is my code:
 
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('clientes');
$crud->set_subject('Clientes');
$crud->set_language('spanish');
$crud->set_primary_key('idclientes','clientes');
$crud->columns(
       'idclientes',
       'cuit',
       'denominacion',
       'direccion',
       'limite_credito'
       );


     $output = $crud->render();
$this->load->view('entidades/clientes',$output);

 

 

Can you help me please?

 

Thanks!!!!

 
 

 

 


davidoster

davidoster
  • profile picture
  • Member

Posted 16 May 2013 - 05:29 AM

Hello and welcome!

 

This SQL "select entidades.cuit, detalle_clientes.idclientes, entidades.denominacion,entidades.direccion, detalle_clientes.limite_credito from entidades inner join detalle_clientes on entidades.cuit=detalle_clientes.entidades_cuit;", where is it in your code?


victor

victor
  • profile picture
  • Member

Posted 16 May 2013 - 15:55 PM

my small daughter says in this case 'nu-nu-nu'. :)

Sanjay Pant

Sanjay Pant
  • profile picture
  • Member

Posted 16 May 2013 - 16:03 PM

I faced a similar problem earlier and realised that grocery crud does not work with views. I created a custom model using the sql used in view along with other tables and was able to get the desired output.


jariberi

jariberi
  • profile picture
  • Member

Posted 16 May 2013 - 17:32 PM

The SQL is how is defined the view in mysql, is not in the code.

davidoster

davidoster
  • profile picture
  • Member

Posted 16 May 2013 - 22:07 PM

The SQL is how is defined the view in mysql, is not in the code.

 

Oh! I am sorry! It's a MySQL view! Allright!

Why do you need to use a view? Is there a specific reason?

 

 

 

I faced a similar problem earlier and realised that grocery crud does not work with views. I created a custom model using the sql used in view along with other tables and was able to get the desired output.

It's true what Sanjay says. GC doesn't work well with MySQL views. It was build for using views to be honest!

Try the custom model, it might give you the solution you need. If not come back here to try to find another solution.


mnish

mnish
  • profile picture
  • Member

Posted 31 August 2013 - 16:58 PM

GC not work with custom sql join.

set_relation show all rows from second table.


davidoster

davidoster
  • profile picture
  • Member

Posted 01 September 2013 - 01:42 AM

GC not work with custom sql join.

set_relation show all rows from second table.

 

Please post your issue here.