Custom query
- Single Page
Posted 08 February 2012 - 13:32 PM
how do I add a custom query?
[color=#339933]where stato = 1;[/color]
[color=#000088]$crud[/color][color=#339933]->[/color][color=#004000]set_relation[/color][color=#009900]([/color][color=#0000ff]'idUser'[/color][color=#339933],[/color][color=#0000ff]'name'[/color][color=#339933],[/color][color=#0000ff]'surname'[/color][color=#009900])[/color][color=#339933];[/color]
Posted 09 February 2012 - 18:56 PM
$crud->set_relation('idUser','users','surname',array('stato' => 1));
I think that you doing it wrong anyway if you want to take multiple fields from your related table you can do this:
$crud->set_relation('idUser','users','{surname} {name}');
the "{" and"}" symbol is the field from the related table you can write whatever you like for example:
$crud->set_relation('idUser','users','{surname} {name} ({email})');
Just make sure that the fields exists to the other table.
Posted 09 February 2012 - 20:51 PM
In the new version, you can also add a condition for the table?
[color=#339933]where id = $_SESSION['id'];[/color]
$crud->set_table('tb_users');
$crud->columns('email','fname','lname','dob','gender','country','state','city','address');
Posted 09 February 2012 - 22:18 PM
$crud->where('id',$_SESSION['id']);
It works exactly the same way as codeigniter's where.
Posted 12 February 2012 - 21:03 PM
when released the new version?
Posted 12 February 2012 - 22:57 PM
Posted 22 August 2012 - 04:55 AM
I mean, can we do this:
$crud->set_relation_n_n('items',
'tb_bill_detail', 'tb_items',
'bill_id', 'item_id', '{id} - {name}');
In my case it doesn't work. I wonder if it is unsupported (yet) feature or a bug
Posted 22 August 2012 - 06:25 AM
Posted 22 August 2012 - 07:17 AM
[*]relation_n_n_queries
[*]get_relation_n_n_selection_array
[*]get_relation_n_n_unselected_array
[/list]
I've successfully make it for add & edit form (related to the 2 last functions).
But still get some horrible error when trying to deal with the first function.
I'll inform you later.
[b]EDIT:[/b] already done, I'll make a pull request soon
Posted 22 August 2012 - 07:37 AM
https://github.com/scoumbourdis/grocery-crud/pull/87
Posted 22 August 2012 - 23:03 PM
I just accepted and everything seems to work fine.
Posted 22 August 2012 - 23:42 PM
And I think I've just discover that strpos will return false if there is no character in the string http://php.net/manual/en/function.strpos.php I think I've do a lot of "mistakes" in my general code, by assuming it will return -1. Thanks for your fix