ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD

April 11, 2011 3:24am

Subscribe [77]
  • #106 / Jun 22, 2011 4:22pm

    web-johnny

    235 posts

    This is probably a mysql problem as you said. But I still don’t know what. Can you do a php info and see : What Apache version do you use? What PHP version and what mysql?

    Debian http://dl.dropbox.com/u/2891468/phpinfo-debian.pdf (dont’t work)
    Ubuntu http://dl.dropbox.com/u/2891468/phpinfo-ubuntu.pdf (works!)

    when i do in phpmyadmin debian “insert into table(x,y,z) values(1,2,3)” and the table definition has (x,y,z,w) don’t work. BUT when i do the same in ubuntu the insert was
    done and w has a default value.

    Perhaps is the Suhosin Extension . Try to disable it and try again , then try to disable only the features of the sql .I am not sure but is the only thing that it seems wrong. With a quick google search I find that this extension blocks some queries to avoid SQl injections. In CI there is not such a problem, because every query goes first to the validation check of the active record.

  • #107 / Jun 23, 2011 7:33am

    mrwbsn

    4 posts

    hello.. i’ve this error after i install to try this awesome timesaving stuff..

    Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\grocery\application\third_party\grocery_crud\models\grocery_model.php on line 12

    how to fix it?! thx. :D

  • #108 / Jun 23, 2011 7:38am

    web-johnny

    235 posts

    hello.. i’ve this error after i install to try this awesome timesaving stuff..

    Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\grocery\application\third_party\grocery_crud\models\grocery_model.php on line 12

    how to fix it?! thx. :D

    You must configure the database first at the autoload or in the constructor. Read the documenation of the codeigniter database configuration at http://ellislab.com/codeigniter/user-guide/database/configuration.html

  • #109 / Jun 23, 2011 7:44am

    mrwbsn

    4 posts

    i also have my config and autoload configured. but strange this error is happen.

    now its solved after i add some tweaks on it.thx for fast reply dude. :D

  • #110 / Jun 24, 2011 10:38am

    javidhb

    3 posts

    hi, web-johnny

    I have a mysterious problem!!! Grocery CRUD doesn’t show the data in my table.
    all the DB’s configs are ok, and when I use a table-name that doesn’t exist in my db it shows FATAL error! but when i use a existing table-name, it doesn’t show the data ONLY the bottom menu of the grocery CRUD.
    and I used your examples, and I followed every thing correctly but still have the problem.

    I really am sorry for me being newbie! is there any way to help me, please?

    I must say it again that i do every thing right(I’ve checked it many times). I really don’t know where is the problem!

    tnks

  • #111 / Jun 24, 2011 4:45pm

    web-johnny

    235 posts

    hi, web-johnny

    I have a mysterious problem!!! Grocery CRUD doesn’t show the data in my table.
    all the DB’s configs are ok, and when I use a table-name that doesn’t exist in my db it shows FATAL error! but when i use a existing table-name, it doesn’t show the data ONLY the bottom menu of the grocery CRUD.
    and I used your examples, and I followed every thing correctly but still have the problem.

    I really am sorry for me being newbie! is there any way to help me, please?

    I must say it again that i do every thing right(I’ve checked it many times). I really don’t know where is the problem!

    tnks


    Hello there.
    Please be more specific. For example can you attach an image to show me, what it appears to your project when you add an existing table?  Did you try it from the scratch or to an already having project? If you try it from the scratch is really easy to install this codeigniter CRUD. You have tried the examples with my tables (test_database.sql) for the beginning? I just can’t unserstand what the problem is to help you.

  • #112 / Jun 24, 2011 6:57pm

    javidhb

    3 posts

    Hello back,

    I am really really sorry for my stupid post. I was trying the Grocery CRUD with a project which already has had a database. but i did what u said(i tried a new project with ‘test_database.sql’) and everything is working now! I’m going to delete the G. Crud files in my old project and start every thing again. I’m sure it will work this time, I must did sth wrong.

    By the way, you did a fantastic job, thanks for this useful tool.

  • #113 / Jul 09, 2011 5:27am

    web-johnny

    235 posts

    That’s ok javidhb 😉 , there is not a stupid post. Sometime something is in front of our eyes and we don’t see it. Glad to help.

  • #114 / Jul 12, 2011 8:56am

    Snap Shot

    7 posts

    Fantastic tool! I’ve knocked up a prototype app in a few hours that would normally have taken me a few days.
    I’m new to Codeigniter but this is a great introduction.

    I do have two requests, when setting $crud->set_relation_1_n I’d like to be able to set a criteria.

    Such as, using your example;

    $crud = new grocery_CRUD();
     
        $crud->set_table('film');
        $crud->set_relation_1_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');

    If I want to only assign actors that haven’t been assigned to other films. Would it be a good idea to allow;

    $crud->set_relation_1_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority', ('Where actor_id not in (select actor_id from film_actor);');

    I’m sure you could shortcut it to something like

    $crud->set_relation_1_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority', in_use = true);

    I know I can probably do something like this in the model, I just haven’t figured out how yet 😊

    Second request is to be able to add more commands to the flexigrid, so along with edit and delete, it’d be nice to be able to add our own “duplicate” or custom commands pointing to another controller with the current row record id.

    How far away from another release are you?

    Thanks for the sterling work so far!!!

  • #115 / Jul 13, 2011 7:47am

    Snap Shot

    7 posts

    I’ve been looking at grocery_model.php and I think that what I’m trying to achieve can be done by reworking get_relation_1_n_unselected_array.
    In order to get just the rows that aren’t already assigned, we need to exclude those that aren’t in the relation_table. I think an array unset after the generation of $results_array from get_relation_1_n_unselected_array might be an option. Or alternatively if we could do a db->get_where with a != being the records in relation_table.

    Something along the lines of:

    $this->db->where_in($field_info->primary_key_alias_to_selection_table , 'select just the unassigned records and the records this id owns');

    Anyone else have any ideas?

  • #116 / Jul 13, 2011 8:43am

    Snap Shot

    7 posts

    I’ve added:

    $this->db->where_not_in($field_info->primary_key_alias_to_selection_table , 'select '.$field_info->primary_key_alias_to_selection_table.' from '.$field_info->relation_table);

    to grocery_model.php and this is returning the correct query for me.
    But it’s not returning the correct results :-(

  • #117 / Jul 13, 2011 11:48am

    Snap Shot

    7 posts

    I’ve accomplished what I wanted to by using the following cludge to get_relation_1_n_unselected_array in grocery_model.php:

    echo $this->uri->segment(1, 0);
            if($this->uri->segment(1, 0)=='stock_controller'):
                $filtered = $this->db->get('values_not_assigned')->result();
                $filtered_results = array();
                foreach($filtered as $row)
                {
                    if(!isset($selected_values[$row->{$field_info->primary_key_alias_to_selection_table}]))
                        $filtered_results[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->main_id;
                }
    
                $this->db->where_in($field_info->primary_key_alias_to_selection_table , $filtered_results);    
            endif;

    I think I could parameterize this by adding to get_relation_1_n_unselected_array(....) though. I might get the chance to do that later. But it might be better to create a new set_relation_1_n type function.

  • #118 / Jul 14, 2011 2:40am

    web-johnny

    235 posts

    I’ve accomplished what I wanted to by using the following cludge to get_relation_1_n_unselected_array in grocery_model.php:

    echo $this->uri->segment(1, 0);
            if($this->uri->segment(1, 0)=='stock_controller'):
                $filtered = $this->db->get('values_not_assigned')->result();
                $filtered_results = array();
                foreach($filtered as $row)
                {
                    if(!isset($selected_values[$row->{$field_info->primary_key_alias_to_selection_table}]))
                        $filtered_results[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->main_id;
                }
    
                $this->db->where_in($field_info->primary_key_alias_to_selection_table , $filtered_results);    
            endif;

    I think I could parameterize this by adding to get_relation_1_n_unselected_array(....) though. I might get the chance to do that later. But it might be better to create a new set_relation_1_n type function.

    Hello @Snap Shot

    I have an example at
    http://www.grocerycrud.com/crud/function_name/set_model

  • #119 / Jul 15, 2011 12:01pm

    Snap Shot

    7 posts

    That’s just excellent!
    I reset the grocerycrud code to the base install, created the new model.
    Added the model call to the controller.
    Works like a charm!
    That’s just super.

    To pose another question; any chance we’re currently able to add custom commands to the flexigrid? I can see other people on the net are able to do it manually, I’m wondering if you’ve already put a hook into it for us?

  • #120 / Jul 16, 2011 1:31am

    fabgonber

    15 posts

    Grocery Crud is slow with a lot of data (900 records) ... When the table has a lot of rows, grocery do a big select and next paginate the result. This big select it’s slow…

    Ideas? anyone has a example with external pagination (not grocery ajax pagination) and limit with offset? i would like do:

    function full_example($page = 0)
    {
            $limit = 50; 
            $this->grocery_crud->set_table('customers')
                 ->set_subject('Customer')
                 ->display_as('customerName','Name')
                 ->display_as('contactLastName','Last Name');
     
            $this->grocery_crud->required_fields('customerName','contactLastName');
            $this->grocey_crud->limit($limit,$page*$limit);
            $this->grocery_crud->render();
    }

    but don’t work… i feel the problem is in $page parameter and grocery crud ...

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases