Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grocery_crud_model - get_relation_n_n_selection_array issue #474

Open
Akshay-Hegde opened this issue Mar 15, 2019 · 3 comments
Open

Grocery_crud_model - get_relation_n_n_selection_array issue #474

Akshay-Hegde opened this issue Mar 15, 2019 · 3 comments

Comments

@Akshay-Hegde
Copy link

Akshay-Hegde commented Mar 15, 2019

$results = $this->db->get($field_info->relation_table)->result();

In method

function get_relation_n_n_selection_array($primary_key_value, $field_info)
{

}

Take a example : relation and selection table both are empty, then set relation_n_n something like below

$crud->set_relation_n_n('fields_callback', $this->db->dbprefix('wf_relation_field_callback'), $this->db->dbprefix('wf_field_callback'), 'field_id', 'id', '{field_id}-{name}({remarks})','priority',array());

Will throw you error

{"status":false,"message":"Call to a member function result() on boolean","data":""}

Which is from line 340

$results = $this->db->get($field_info->relation_table)->result();

To fix this issue modify model like below

   	$q = $this->db->get($field_info->relation_table);
	$results = array();
	if($q !== FALSE && $q->num_rows() > 0){
		$results = $q->result();
	}
@Akshay-Hegde
Copy link
Author

@mckaygerhard you may be interested, not sure author could test and fix the issue in latest release

@mckaygerhard
Copy link

interesting:

$q = $this->db->get($field_info->relation_table);
	$results = array();
	if($q !== FALSE && $q->num_rows() > 0){
		$results = $q->result();
	}

we also need to check if "q" are null object or are not an object ... due the $q->num_rows() check, i thing its a limitation also from the CI framework

@mckaygerhard
Copy link

mckaygerhard commented Sep 19, 2019

ka ka ka some time since this problem.. now i made a ugly trick due that workaround does not work at all.. the trick consist on create a new table from the customized query.. later render the grocery crud from that recently created table.. of course has a hit performance I/O related.. but works for little projects ...

the "q" must need too many checks.. and workaround related to individuals check..

due lackof time i not implemented a property made solution.. sorry later time i'll try some piece of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants