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]
  • #316 / Jul 05, 2012 8:31am

    goFrendiAsgard

    125 posts

    Hi,@Ashirra
    In my case I have article and comment table.
    An article can have more than one comment.

    This is my code:

    public function comment($article_id=NULL){
         $crud = new grocery_CRUD();     
         $crud->set_table('blog_comment');
         if(isset($article_id)){
          $crud->where('blog_comment.article_id', $article_id);
         }     
         $output = $crud->render();
         
         $this->view('grocery_CRUD', $output, 'blog_comment');
        }

    The most important thing here is you can use $crud->where(‘your_field’, $value);
    it works perfectly….

  • #317 / Jul 05, 2012 9:25am

    Ashirra

    4 posts

    Hi Asgard

    thanks for your reply.

    An article can have more than one comment.

    That’s an 1:n relation and it works very well in my project too.

    But I have problems with n:n relations

    frontuser
    id / name
    1     asgard
    2     ashirra

    frontuser_client
    frontuser / client
    1               1
    1               2
    1               3
    2               1
    2               2

    client
    id / name
    1     peter
    2     phil
    3     petra

    One solution is to use the pivot directly.

    from frontuser
    ../index.php/back/frontuser
    to the pivot
    ../index.php/back/frontuser_client
    to the client (details)
    ../index.php/back/client

    “divide et impera”. Because an n:n can be splitted into two 1:n.
    but is it the best solution?

  • #318 / Jul 05, 2012 10:56am

    goFrendiAsgard

    125 posts

    But I have problems with n:n relations

    frontuser
    id / name
    1     asgard
    2     ashirra

    frontuser_client
    frontuser / client
    1               1
    1               2
    1               3
    2               1
    2               2

    client
    id / name
    1     peter
    2     phil
    3     petra

    One solution is to use the pivot directly.

    from frontuser
    ../index.php/back/frontuser
    to the pivot
    ../index.php/back/frontuser_client
    to the client (details)
    ../index.php/back/client

    “divide et impera”. Because an n:n can be splitted into two 1:n.
    but is it the best solution?

    Ah, sorry, I think I have misunderstand it :p
    Do you mean something like this? http://www.grocerycrud.com/examples/set_a_relation_n_n
    I think it is better to have 2 grids, the frontuser and the client. You can then add n_n relation field to the both grids (please see the link).

  • #319 / Jul 05, 2012 11:17am

    Ashirra

    4 posts

    function linkToClients($value,$row){
          return "<a href="http://.site_url">id)."'>clients</a>";
     }

    ‘.$row - >id).”’

    This link invokes directly my client site. So the question was “it’s possible with set_model or other solutions, to take the ID fromt the link and start a own query with this value ($row->id).

    SQL Code like this

    SELECT * FROM client, client_frontuser 
             where client.id = client_frontuser.client_id 
             and client_frontuser.frontuser_id = $ID

    Now I found a solution.

    Instead of taking one step (frontuser -> client). I take two with one step in the middle (frontuser->frontuser_client->client). So it works.

    Now, I’m interested if there is a better solution.

    thanks asgard for your inputs 😉

    gn8

     

     

     

  • #320 / Aug 27, 2012 6:54pm

    web-johnny

    235 posts

    Proud to announce the new version 1.3 😊

    The new version 1.3 is out with brand new features

    After almost three months of development I am proud to announce you the new version 1.3 with brand new features and not only bug fixes this time. You can download it straight away from http://www.grocerycrud.com/downloads .

    For more check the forum topic at grocery CRUD’s forum

  • #321 / Sep 12, 2012 4:39pm

    C1t1zen

    7 posts

    hi
    i have a problem i never can use dates with Grocery CRud

    the calander neverh showen

    please help
    so tell me what i need to setup database table and grocery crud to make all work out
    for sure i did searched alot in google and in forum of grocery crud but still not working

    thank you in advance

  • #322 / Sep 12, 2012 5:13pm

    web-johnny

    235 posts

    Hello @C1t1zen.

    If you have any problem to use dates you can easily use the change_field_type method. So in your case you can simply have:

    $crud->change_field_type('inserted_date', 'date');

    If you have any JavaScript problem you have to give a print-screen of your problem.

  • #323 / Sep 12, 2012 6:50pm

    C1t1zen

    7 posts

    Hey Johnny!
    i did waste about 2 days with crud
    but now i’m still stuck with it

    i did used this line code

    $crud->change_field_type(‘inserted_date’, ‘date’);

    look to my code in code in controller

    <?php
    
    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
    
    class Examples extends CI_Controller {
    
        function __construct() {
            parent::__construct();
    
            $this->load->database();
            $this->load->helper('url');
    
            $this->load->library('grocery_CRUD');
        }
    
        function _example_output($output = null) {
            $this->load->view('example.php', $output);
        }
        function index() {
            $this->_example_output((object) array('output' => '', 'js_files' => array(), 'css_files' => array()));
        }
    
    
        function payments() {
    
            /* This is only for the autocompletion */
            $crud = new grocery_CRUD();
       
            $crud->set_table('payments');
            $crud->set_subject('مجموعات الرجيم ::  :: ');
            $crud->required_fields(' title');
            $crud->columns(' title', 'desc', 'group_slug');
            $crud->change_field_type('birthdate', 'date');
            $output = $crud->render();
           $this->_example_output($output);
        }
    }

    so i dont know why calander is not loading

    Also when i update i get this message:


    {"success":true,"insert_primary_key":true,"success_message":"Your data has been successfully updated. <a href='http:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/www.domain.com\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/examples\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/diet'>Go back to list<\/a><\/p>","success_list_url":"http:\/\/www.domain.com\/examples\/diet\/success\/1"}

    this message only appears when i use date field in mysql table
    if i removed this date field it does not appears and everything go fine.

    thank you in advance

  • #324 / Sep 14, 2012 2:36am

    web-johnny

    235 posts

    Ok I think I know where the problem should be. Can you please tell me:
    - PHP Version
    - Codeigniter Version
    - grocery CRUD version
    - default language

    Probably there is something with the default language, perhaps a bug. Can you please check if you change it to english (application/config/grocery_crud.php):

    $config['grocery_crud_default_language'] = 'english';

    This now works for you?  If yes then just let me know and I will check it further.

    Cheers
    Johnny

  • #325 / Sep 14, 2012 8:00am

    C1t1zen

    7 posts

    Hey
    thank you for reply
    PHP Version 5.2.17
    - Codeigniter Version :2.1.2
    - grocery CRUD version : last version

    application/config/grocery_crud.php settings;

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     //For view all the languages go to the folder assets/grocery_crud/languages/
     $config['grocery_crud_default_language'] = 'english';
    
     // There are only three choices: "uk-date" (dd/mm/yyyy), "us-date" (mm/dd/yyyy) or "sql-date" (yyyy-mm-dd) 
     $config['grocery_crud_date_format']   = 'sql-date';
    
     // The default per page when a user firstly see a list page
     $config['grocery_crud_default_per_page'] = 25; //Can only take values 10,25,50,100
     
     $config['grocery_crud_file_upload_allow_file_types']   = 'gif|jpeg|jpg|png|tiff|doc|docx|txt|odt|xls|xlsx|pdf|ppt|pptx|pps|ppsx|mp3|m4a|ogg|wav|mp4|m4v|mov|wmv|flv|avi|mpg|ogv|3gp|3g2';
     $config['grocery_crud_file_upload_max_file_size']    = '20MB'; //ex. '10MB' (Mega Bytes), '1067KB' (Kilo Bytes), '5000B' (Bytes)
     
     //You can choose 'ckeditor','tinymce' or 'markitup'
     $config['grocery_crud_default_text_editor'] = 'ckeditor';
     //You can choose 'minimal' or 'full'
     $config['grocery_crud_text_editor_type']  = 'full'; 
     
     //The character limiter at the list page, zero(0) value if you don't want character limiter at your list page
     $config['grocery_crud_character_limiter']  = 30;

     

  • #326 / Sep 15, 2012 4:02am

    web-johnny

    235 posts

    I think I found where the problem can be, try this one:

    function payments() {
    
            /* This is only for the autocompletion */
            $crud = new grocery_CRUD();
       
            $crud->set_table('payments');
            $crud->set_subject('مجموعات الرجيم ::  :: ');
            $crud->required_fields('title'); // instead you had ' title' with whitespace
            $crud->columns('title', 'desc', 'group_slug'); // instead you had ' title' with whitespace
            $output = $crud->render();
           $this->_example_output($output);
        }
  • #327 / Sep 15, 2012 8:50am

    C1t1zen

    7 posts

    thank you,
    i did changed like you said

    function payments() {
    
            /* This is only for the autocompletion */
            $crud = new grocery_CRUD();
            //$crud->set_theme('datatables');
            $crud->set_table('payments');
            $crud->set_subject('payment new');
            $crud->required_fields('title');
            $crud->columns('title', 'desc', 'group_slug');
            $crud->change_field_type('birthdate', 'date');
            $output = $crud->render();
           $this->_example_output($output);
        }

    i will send you in private my url maybe there is js files not loaded

  • #328 / Sep 15, 2012 8:57am

    web-johnny

    235 posts

    You forgot to send me the URL in the private message. Please try to email me. Thanks.

  • #329 / Sep 15, 2012 9:21am

    C1t1zen

    7 posts

    thank you again
    i did send you URL

    i hope you can determine the problem

    thank you in advance

  • #330 / Oct 11, 2012 3:56am

    Maxmadknight

    1 posts

    Good day, how to connect 2 table are in a relationship 1-n, where the main table no pointer to the secondary

    ‘Application’,‘Colors’,‘Image’ - not in base

    $crud->add_fields('prod_set_name', 'vendor_id','arcticle', 'id_type', 'add_data','Application','Colors','Image');   
    
    
    $crud->set_relation('Image','images','{url} alt text |{alt}| ');
    //$crud->set_relation_n_n('Image', 'prod_set_images', 'images', 'prod_set_id', 'images_id', '{url} alt text |{alt}| ');
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases