Jump to content


Member Since 01 Sep 2017
Offline Last Active Apr 16 2018 12:41 PM

Posts I've Made

In Topic: setRelationNtoN not working anymore?

10 April 2018 - 08:24 AM

Hi again, 


are there anyone else who have this issue?



In Topic: Set Relation with where clause

14 January 2018 - 10:58 AM

Okay, so after some looking into the code I did find that it was the other way around. 

public function setRelation($fieldName , $relatedTable, $relatedTitleField, $where = null, $orderBy = null)

So I did move the order of the 2 last attributes, that did work perfect! 


But now I've got 2 columns that relates to the same table and then I get this error;

Message: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'tbl_tablename'

How do I manage to set an alias on these 2 or work around this, anybody knows?

In Topic: how to show all related data1 to many using $crud->setRelation()

06 September 2017 - 06:32 AM

Hi there, 


If you look under:



You can see that you'll need to set:

$crud->setRelation('1', '2', '3') 

1 = The field name at our basic table that we need to related with the foreign key ( in your case: fk_table_B)

2 = The relation table (in your case: table B)

3 = The field that it is recognisable as the title of the related table (in your case: id_table_B)


If I understood you correctly. 


Hope it helps!

In Topic: Export with relations not showing data

06 September 2017 - 06:15 AM



I'm using CI 3.1.5 with GC Enterprise 2.3.2. 

    public function computers() {
        //Setting variable and loading library.
        $crud = $this->_getGroceryCrudEnterprise();


        $crud->displayAs('computer_hostname', 'Hostname');
        $crud->displayAs('computer_sn', 'SN');
        $crud->displayAs('computer_brand', 'Brand');
        $crud->displayAs('computer_model', 'Model');
        $crud->displayAs('computer_employee', 'User');
        $crud->displayAs('computer_vendor', 'Vendor');
        $crud->displayAs('computer_comment', 'Comment');

        //Unsetting columns that are not for the regular CRUD
        $crud->unsetColumns(['computer_id', 'computer_ram', 'computer_cpu', 'computer_warranty', 'computer_mac_wlan', 'computer_mac_lan', 'computer_windows_license', 'computer_hdd', 'computer_bought_date']);
        $crud->setRelation('computer_employee', 'tbl_employees', '{employee_lastname}, {employee_firstname}');
        $crud->setRelation('computer_brand', 'tbl_datasys_brands', 'brand_name');
        $crud->setRelation('computer_vendor', 'tbl_datasys_vendors', 'vendor_name');
        //Setting order_by
        $crud->defaultOrdering('computer_hostname', 'asc');

        //Redering and sending data to view.
        $output = $crud->render();

The export is using ID's but at print its correct.. Hmm..