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]
  • #211 / Oct 18, 2011 4:28pm

    web-johnny

    235 posts

    I think, I found a solution and I tried it to something similar. This will work

    function requests()
    {
    $crud = new grocery_CRUD();
    $crud->set_table('fq_request');
    $crud->set_subject('Request');
    $crud->unset_add();
    $crud->fields('request_service', 'request_name', 'request_email', 'region_id', 'request_phone', 'request_fax', 'request_for');
    $crud->set_relation('region_id','fq_region','region_name');
    $crud->unset_texteditor('request_for');
    $crud->columns('id', 'request_service', 'request_name', 'request_email', 'request_count');
    $crud->order_by('fq_request.id', 'desc');
    $output = $crud->render();
    $this->_crud_output($output);
    }

    The only problem is that there is a let’s say it BUG to groceryCRUD that it don’t “read” the order by that you tell (fq_request.id). The order by works but there is not working with the symbol “/\” or “\/” . I hope there is no problem with this. The search works fine with this and the id is shown normally

  • #212 / Oct 18, 2011 5:04pm

    CI Simon

    18 posts

    I think, I found a solution and I tried it to something similar. This will work

    $crud->order_by('fq_request.id', 'desc');

    The only problem is that there is a let’s say it BUG to groceryCRUD that it don’t “read” the order by that you tell (fq_request.id). The order by works but there is not working with the symbol “/\” or “\/” . I hope there is no problem with this. The search works fine with this and the id is shown normally

    It doesn’t seem to work for me. Maybe I’m missing something obvious now…

  • #213 / Oct 18, 2011 5:24pm

    web-johnny

    235 posts

    I think, I found a solution and I tried it to something similar. This will work

    $crud->order_by('fq_request.id', 'desc');

    The only problem is that there is a let’s say it BUG to groceryCRUD that it don’t “read” the order by that you tell (fq_request.id). The order by works but there is not working with the symbol “/\” or “\/” . I hope there is no problem with this. The search works fine with this and the id is shown normally

    It doesn’t seem to work for me. Maybe I’m missing something obvious now…

    Can you post the syntax of your table to tested local? for example :

    CREATE TABLE IF NOT EXISTS `user_profiles` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `user_id` int(11) NOT NULL,
      `fname` varchar(255) COLLATE utf8_bin NOT NULL,
      `lname` varchar(255) COLLATE utf8_bin NOT NULL,
      `uid_pref` varchar(255) COLLATE utf8_bin NOT NULL,
      `phone` varchar(255) COLLATE utf8_bin NOT NULL,
      `branch` varchar(255) COLLATE utf8_bin NOT NULL,
      `address` varchar(255) COLLATE utf8_bin NOT NULL,
      `country` varchar(20) COLLATE utf8_bin DEFAULT NULL,
      `website` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=10 ;

    I will try your code to see what is wrong. Did you delete the cookies/session before you try it again? Perhaps some cookie is stored and do the sorting wrong.

  • #214 / Oct 18, 2011 5:50pm

    CI Simon

    18 posts

    Thanks for you help with this. The two tables are:

    CREATE TABLE IF NOT EXISTS `fq_region` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `region_name` varchar(255) NOT NULL DEFAULT '',
      `region_url` varchar(255) NOT NULL DEFAULT '',
      `region_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
    
    CREATE TABLE IF NOT EXISTS `fq_request` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `request_service` varchar(255) NOT NULL,
      `request_name` varchar(255) NOT NULL,
      `request_email` varchar(255) NOT NULL,
      `region_id` int(11) NOT NULL,
      `request_phone` varchar(255) NOT NULL,
      `request_fax` varchar(255) DEFAULT NULL,
      `request_for` text NOT NULL,
      `request_time` int(11) NOT NULL,
      `request_checktime` int(11) DEFAULT '0',
      `request_count` int(11) DEFAULT '0',
      `request_manualtime` int(11) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10066963 ;
  • #215 / Oct 19, 2011 5:36pm

    web-johnny

    235 posts

    Thanks for you help with this. The two tables are:

    CREATE TABLE IF NOT EXISTS `fq_region` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `region_name` varchar(255) NOT NULL DEFAULT '',
      `region_url` varchar(255) NOT NULL DEFAULT '',
      `region_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
    
    CREATE TABLE IF NOT EXISTS `fq_request` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `request_service` varchar(255) NOT NULL,
      `request_name` varchar(255) NOT NULL,
      `request_email` varchar(255) NOT NULL,
      `region_id` int(11) NOT NULL,
      `request_phone` varchar(255) NOT NULL,
      `request_fax` varchar(255) DEFAULT NULL,
      `request_for` text NOT NULL,
      `request_time` int(11) NOT NULL,
      `request_checktime` int(11) DEFAULT '0',
      `request_count` int(11) DEFAULT '0',
      `request_manualtime` int(11) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10066963 ;

    I looked at it and you are right this is actually a BUG . For now you can just choose the theme datatables with one search . And after this I will try to figure the BUG and fix it and you will just change the theme. This is of course just a quick solution for your problem. If you find something for the BUG you can also share it here to the forum 😉. Thank you to mention your problem.

  • #216 / Oct 20, 2011 1:53am

    CI Simon

    18 posts

    For now you can just choose the theme datatables with one search.

    Sorry didn’t understand this. What do you mean?

    Thanks for all your help on this. I had tried to write my own model to work around this before I asked for help - do you think this would be an appropriate course of action?

    If I come up with a solution I will off course post it.

    Once again thank you for you support and also just for creating GroceryCrud in the first place.

    Cheers,
    Simon

  • #217 / Oct 20, 2011 11:47am

    web-johnny

    235 posts

    For now you can just choose the theme datatables with one search.

    Sorry didn’t understand this. What do you mean?

    Thanks for all your help on this. I had tried to write my own model to work around this before I asked for help - do you think this would be an appropriate course of action?

    If I come up with a solution I will off course post it.

    Once again thank you for you support and also just for creating GroceryCrud in the first place.

    Cheers,
    Simon

    I have a method named set_theme . I have two themes till now the flexigrid theme - that is default - and the datatables theme. So just with one line of code you will change your theme to datatables. Datatables theme has client side sorting paging searching etc. So you will not have any problem for a while. Your search will work normally and the forms etc without any problem. When the bug is fixed, or from me or from you, just comment this line of code and use the default theme that is flexigrid.
    The line of code will be (always before the render):

    $this->grocery_crud->set_theme("datatables");

    You can see an example at
    http://www.grocerycrud.com/crud/example/employees_example

  • #218 / Oct 20, 2011 1:12pm

    CI Simon

    18 posts

    Datatables theme has client side sorting paging searching etc. So you will not have any problem for a while. Your search will work normally and the forms etc without any problem.

    I’m sorry to do this but i tried Datatables and i run out of memory on that table - it has 50000 records.

  • #219 / Oct 20, 2011 1:29pm

    web-johnny

    235 posts

    Datatables theme has client side sorting paging searching etc. So you will not have any problem for a while. Your search will work normally and the forms etc without any problem.

    I’m sorry to do this but i tried Datatables and i run out of memory on that table - it has 50000 records.

    That’s bad if you have so many records to do it in a client side grid. I will try to figure out a quick solution for your problem. Till then if you find a solution before me, just let me know.

    Kind Regards

  • #220 / Oct 24, 2011 6:53pm

    Winar

    1 posts

    I have 2 User Group, the first group can access A,B and C department, and then second group can Access A,C&D Department. 1st group can 2nd group can create member in each department. the question is, how to create a combo (dropdown) in form add member with each group with different content (different array of department) 

    the departement store in table t_department with table structure
    code varchar(1)PK
    name_dept varchar (50)


    I can show the combobox(dropdown) like this
    1st Group
    A - A DEPARTEMENT
    B - B DEPARTEMENT
    C - C DEPARTMENT

    and if 2nd Group access, it will be like this

    2nd Group
    A - A DEPARTEMENT
    C - C DEPARTEMENT
    D - D DEPARTMENT

    how to create the dropdown like this?
    Thanks before

  • #221 / Oct 27, 2011 1:36am

    vinalask3

    5 posts

    Just what I am looking for! Man you’ve saved me a lot!

  • #222 / Oct 29, 2011 1:36am

    web-johnny

    235 posts

    I have 2 User Group, the first group can access A,B and C department, and then second group can Access A,C&D Department. 1st group can 2nd group can create member in each department. the question is, how to create a combo (dropdown) in form add member with each group with different content (different array of department) 

    the departement store in table t_department with table structure
    code varchar(1)PK
    name_dept varchar (50)


    I can show the combobox(dropdown) like this
    1st Group
    A - A DEPARTEMENT
    B - B DEPARTEMENT
    C - C DEPARTMENT

    and if 2nd Group access, it will be like this

    2nd Group
    A - A DEPARTEMENT
    C - C DEPARTEMENT
    D - D DEPARTMENT

    how to create the dropdown like this?
    Thanks before

    You can use callback_edit_field method (  http://www.grocerycrud.com/crud/example/callback_edit_field ) and callback_add_field method ( http://www.grocerycrud.com/crud/example/callback_add_field ) to add your custom drop-down list or whatever input you like.

  • #223 / Nov 10, 2011 8:30pm

    goFrendiAsgard

    125 posts

    Dear, web-johnny

    First of all I want to thank you for your great job. It helps me to save a lot of time.
    I’ve several questions related to groceryCRUD.

    1. I try to use a primary key which is not in INT data type. I use user_name as a primary key of table_user. I’ve successfully add a user, but when I click “edit” (a link that appear after I insert new data), It showed error. I guess it is related to “auto increment” (Maybe you assume that all primary key should be integer and auto increment). It is not a big problem since I can change my table structure so that each table will have “auto increment primary key”. The question is: Is it right that current groceryCRUD version only support “auto increment primary key”?

    2. I also try to make a navigation table which is used as “tree structure” representation.

    table_navigation(id, parent_id, is_root, title, url)

    “parent_id” is a foreign key to “id”, and it is allowed to be null.
    I use before_insert and before_update callback, both are directed to before_insert_or_update_navigation function.

    public function before_insert_or_update_navigation($post_array){
      if($post_array['is_root']==1){
        unset($post_array['parent_id']); //this doesn't work, there is no change for the value of parent_id
        $post_array['parent_id'] = NULL; //doesn't work as above
        $post_array['parent_id'] = ''; //doesn't work, produce error
      }
      return $post_array;
    }

    Is that any way to do what I want correctly?


    thank you in advance
    goFrendiAsgard;

  • #224 / Nov 11, 2011 8:49pm

    goFrendiAsgard

    125 posts

    Look at this : http://www.grocerycrud.com/forums/topic/18-non-auto-increment-primary-key-nullable-foreign-key/
    I still need better solution for second issue, but for temporary solution I think it can be accepted

  • #225 / Nov 17, 2011 7:45am

    web-johnny

    235 posts

    New version 1.1.4 is released that is fully compatible with codeigniter 2.1. Enjoy 😊

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

ExpressionEngine News!

#eecms, #events, #releases