⚠ 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

Needed primary key to a Table ?



theor

theor
  • profile picture
  • Member

Posted 24 November 2017 - 16:17 PM

Hello,

In my Database, i have a Table witch have no primary key. It only refer to others Tables. When i do a render(), they said there is an error in my request SQL. My code:

    public function test()
    {
      
        $crud = new grocery_CRUD();
       
        $crud->set_table('film_actor');

        $crud->columns('actor_id','film_id','priority');
     
        $output = $crud->render();

        $this->_example_output($output);

    }

Can you help me ?

Thanks a lot for a reply


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 24 November 2017 - 23:49 PM

Yes, my friend, GC needs the table to have a primary key. Even if it just just refer to the other tables, if you want to use it with GC .. you need a primary key. GC is a generic library. Now imagine if it were to delete a record / edit a record / view a record - on what basis / criteria it will do it? It cannot go back and query up values for all the values in a row!!

 

And even if it just refers to other tables - there aint much cost adding a primary key.

 

Happy GCing:)