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]
  • #31 / Apr 19, 2011 10:32pm

    electronik_0

    10 posts

    looks great Thanks

  • #32 / Apr 20, 2011 1:01am

    tieungao

    30 posts

    this is also good if can make new version to work with template (header, footer,..) and easy to merge with HMVC.

    I love this plugin so much but difficult for me to enroll in HMVC.

  • #33 / Apr 20, 2011 1:30am

    web-johnny

    235 posts

    this is also good if can make new version to work with template (header, footer,..) and easy to merge with HMVC.

    I love this plugin so much but difficult for me to enroll in HMVC.

    Its really worth it to learn to write in MVC . In the beginning it’s a little difficult but after you learn it , there is no way back to write php scripts from the scratch again 😊.

    I have a suggestion for you . I do it in many projects that don’t use frameworks or use another framework like kohana, cakephp etc. You can create a folder to your project . For example “admin” and copy all your codeigniter code there. So you have your project that works fine and you also have your administrator in codeigniter. Its really really easy (espacially with CI 2.0.0 that there is no need to config anything). The only config that you will add is the database config and the CRUD. That’s it.

    I think its simple.

    PS. grocery CRUD has template at templates/frontend/default/template.php

  • #34 / Apr 22, 2011 12:35am

    Joker

    3 posts

    Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

    For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

    SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

    Still Blank white in page ?...... any sugested what’s wrong in my styntac

  • #35 / Apr 22, 2011 3:14am

    web-johnny

    235 posts

    Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

    For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

    SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

    Still Blank white in page ?...... any sugested what’s wrong in my styntac

    The blank wepbage is because you have the error_reporting(0); Go to your index.php and change the error_reporting to E_ALL ( if you have 1.7.3 - 2.0.1) or define(‘ENVIRONMENT’, ‘development’); if you use 2.0.2 . Please do this first, because the error can be everywhere. If you are more specific I can help you. As you have seen ALL the code for the database is on the model. You are in the right place…

  • #36 / Apr 22, 2011 8:25am

    geaper

    1 posts

    I just downloaded g-crud and now I have an error

    Fatal error: Call to undefined method CI_Output::set_template() in C:\xampp\htdocs\test\application\controllers\crud.php on line 20

    and line 20

    $this->output->set_template('custom_cms');

    how to solve it, any idea?

    PS: I’m using CI 2.02

  • #37 / Apr 22, 2011 11:42am

    web-johnny

    235 posts

    I just downloaded g-crud and now I have an error

    Fatal error: Call to undefined method CI_Output::set_template() in C:\xampp\htdocs\test\application\controllers\crud.php on line 20

    and line 20

    $this->output->set_template('custom_cms');

    how to solve it, any idea?

    PS: I’m using CI 2.02

    You have to copy-paste all the files and not only the library.  This error means that you didn’t copy the folder core. And there I have MY_Output that have the function set_template

  • #38 / Apr 22, 2011 12:56pm

    Joker

    3 posts

    Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

    For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

    SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

    Still Blank white in page ?...... any sugested what’s wrong in my styntac

    The blank wepbage is because you have the error_reporting(0); Go to your index.php and change the error_reporting to E_ALL ( if you have 1.7.3 - 2.0.1) or define(‘ENVIRONMENT’, ‘development’); if you use 2.0.2 . Please do this first, because the error can be everywhere. If you are more specific I can help you. As you have seen ALL the code for the database is on the model. You are in the right place…

    Thanks for quick answer ,... i will try your suggestion, yup the error was on the model , when SET NAMES = UTF8 firts error (i was disable it) after that on SHOW COLUMN for looking Structure of table (i create view on mssql with name Show_column)i change with EXE Show_column ‘table_name’
    After that was blank ....

    OK i will inform next ...


    Hem the result was
    “Fatal error: Cannot access empty property in I:\susilo\xampp\htdocs\crudme\application\third_party\grocery_crud\libraries\grocery_crud.php on line 852

    maybe can u try it


    CREATE procedure [dbo].[Show_Columns]
    (
      @table_name       nvarchar(384)
    ) as
    begin
      Select
      column_name as Field,
      data_type+cast(’(’ as varchar)+cast(character_maximum_length as varchar)+cast(’)’ as varchar) as ‘Type’,
      is_nullable as ‘Null’,
      ‘’ as ‘Key’,
      column_default as ‘Default’,
      ‘’ as Extra
      from information_schema.columns WHERE table_name = @table_name
    end

    the result was like SHOW COLUMN on mysql…

    now need help about it

  • #39 / Apr 22, 2011 4:46pm

    web-johnny

    235 posts

    I didn’t tested in mssql . I worked with mssql and only with visual studio and linq is good . Without this really I hate MSSQL and I didn’t tested on it. I didn’t even install it on my computer . Sorry…
    But why you use mssql ? Ok if you find the problem please send it to me (just post the code of the model) , so and other people knows about this.

    Thank you very much

  • #40 / Apr 22, 2011 11:43pm

    Joker

    3 posts

    I didn’t tested in mssql . I worked with mssql and only with visual studio and linq is good . Without this really I hate MSSQL and I didn’t tested on it. I didn’t even install it on my computer . Sorry…
    But why you use mssql ? Ok if you find the problem please send it to me (just post the code of the model) , so and other people knows about this.

    Thank you very much

    I know i got bad choice when i chosee mssql for this project.

    ok the model


    function __construct()
      {
    parent::__construct();

    $this->db->query('set names utf8'); === this line made the firts error
    }


    then i disable it () i didn’t made change just // next it


    after then this function

      function get_field_types_basic_table()
      {
    $db_field_types = array();
      //foreach($this->db->query(“SHOW COLUMNS FROM {$this->table_name}”)->result() as $db_field_type)
     
      foreach($this->db->query(“EXEC Show_Columns {$this->table_name}”)->result() as $db_field_type)
         
          {

    $type = explode("(",$db_field_type->Type);
    $db_type = $type[0];

    if(isset($type[1]))
    {
    $length = substr($type[1],0,-1);
    }
            else
            {
    $length = '';
    }
            $db_field_types[$db_field_type->Field][‘db_max_length’] = $length;
            $db_field_types[$db_field_type->Field][‘db_type’] = $db_type;
            $db_field_types[$db_field_type->Field][‘db_null’] = $db_field_type->Null;
            $db_field_types[$db_field_type->Field][‘db_default’] = $db_field_type->Default;
            $db_field_types[$db_field_type->Field][‘db_extra’] = $db_field_type->Extra;
          }
     
    the blue was the originial made change with the red one

    i made some procedure on mssql like i sad before

    after that

    was on lib

    line 852

    =====
    protected function showList($ajax = false)
      {
    $ci = &get;_instance();

    $data = $this->get_common_data();

    $data->order_by = $this->order_by;

    $data->types = $this->get_field_types();

    $data->list = $this->get_list();
    $data->list = $this->change_list($data->list , $data->types);

    $data->total_results = $this->get_total_results();

    $data->columns = $this->get_columns();
    $data->primary_key = $this->get_primary_key();
    $data->add_url = $this->getAddUrl();
    $data->edit_url = $this->getEditUrl();
    $data->delete_url = $this->getDeleteUrl();
    $data->ajax_list_url = $this->getAjaxListUrl();
    $data->ajax_list_info_url = $this->getAjaxListInfoUrl();

    $data->unset_add = $this->unset_add;
    $data->unset_edit = $this->unset_edit;
    $data->unset_delete = $this->unset_delete;

    if($data->list === false)
    {
    throw new Exception('It is impossible to get data. Please check your model and try again.', 13);
    $data->list = array();
    }
         
          foreach($data->list as $num_row => $row)
          {
    $data->list[$num_row]->edit_url = $data->edit_url.'/'.$row->{$data->primary_key};
            $data->list[$num_row]->delete_url = $data->delete_url.’/’.$row->{$data->primary_key};
          }
         
          if(!$ajax)
          {
    $data->list_view = $this->_theme_view('list.php',$data,true);
    $this->_theme_view('list_template.php',$data);
    }
          else
          {
    $ci->output->unset_template();
    $this->_theme_view('list.php',$data);
    }
      }
     

    I think ... i was enable read from the model that i was made EXEC show_column

    NOt like Show Column on Mysql


    ok that was i found on mssql

    thank’s

    maybe other can help this great crud u have made

  • #41 / Apr 25, 2011 10:04am

    ReyPM

    86 posts

    Ok, I’ve found this amazing tool and trying to use in my development but I’m doing something wrong because don’t work. See what I’ve done until now:
    1. Load needed libraries in __construct() (The other libraries needed are autoloaded).

    public function __construct() {
          parent::__construct();
          $this->load->add_package_path(APPPATH . 'third_party/grocery_crud/');
          $this->output->set_template('custom_cms');
          $this->load->library('grocery_CRUD');
    }

    2. Write this piece of code in index():

    public function index() {
          if ($this->my_usession->logged_in) {
          $this->grocery_crud->set_table('trasegados')
                     ->set_subject('Trasegados')
                     ->columns('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->required_fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->render();
             $this->load->view('trasegados/form', $data);
          } else {
             redirect('user/login');
          }
       }

    3. Echo $output at trasegados/form template:

    <?php $this->load->view('layout_login_header'); ?>
    <?php echo $output ?>
    <?php $this->load->view('layout_login_footer'); ?>

    4. Add the needed code at layout_login_header:

    <?php foreach ($css as $file): ?>
          <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
          <?php endforeach; ?>
          [removed]var base_url = '<?= base_url() ?>';[removed]
          <?php foreach ($js as $file): ?>
             [removed][removed]
          <?php endforeach; ?>

    But I got a lot of errors:

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: css

    Filename: views/layout_login_header.php

    Line Number: 11

    A PHP Error was encountered

    Severity: Warning

    Message: Invalid argument supplied for foreach()

    Filename: views/layout_login_header.php

    Line Number: 11
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: js

    Filename: views/layout_login_header.php

    Line Number: 15
    A PHP Error was encountered

    Severity: Warning

    Message: Invalid argument supplied for foreach()

    Filename: views/layout_login_header.php

    Line Number: 15

    See the entire output image here http://www.dropmocks.com/mUTRR. Why this? What I’m doing wrong?

    Cheers and thanks

  • #42 / Apr 25, 2011 10:15am

    web-johnny

    235 posts

    To your template you must write this :

    <?php $this->load->view('layout_login_header', array('css' => $css, 'js' => $js)); ?>
    <?php echo $output ?>
    <?php $this->load->view('layout_login_footer'); ?>

    I think the wrong is only in the $this->load->view(‘layout_login_header’); . Hope this will solve your problem

  • #43 / Apr 25, 2011 10:17am

    ReyPM

    86 posts

    Nope :( I changed as you suggest and still no working

  • #44 / Apr 25, 2011 10:26am

    web-johnny

    235 posts

    Ok I think I find it 😊
    You will not use the view $this->load->view(‘trasegados/form’, $data);
    You have to this code to your template : (templates/frontend/custom-cms/template.php). So your template will be something like the template below: (the application/views/ is needed in the template, I still don’t know why)

    <?php $this->load->view('application/views/layout_login_header', array('css' => $css, 'js' => $js)); ?>
    <?php echo $output ?>
    <?php $this->load->view('application/views/layout_login_footer'); ?>

    delete you line $this->load->view(‘trasegados/form’, $data);  and if you want to add more views you can do it like this…

    function test()
    {
        $this->load->view(...); // for a view before the crud
        $this->grocery_crud->....
        $this->grocery_crud->render();
    
        $this->load->view(...); // for a view after the crud
    }

    and your index function will be like this:

    public function index() {
          if ($this->my_usession->logged_in) {
          $this->grocery_crud->set_table('trasegados')
                     ->set_subject('Trasegados')
                     ->columns('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->required_fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
             $this->grocery_crud->render();
             //$this->load->view('trasegados/form', $data);
          } else {
             redirect('user/login');
          }
       }
  • #45 / Apr 25, 2011 10:32am

    ReyPM

    86 posts

    Hmmm OK, this solve the problem but what about my layout? Now I’m only have the CRUD and I want, of course, the layout working togheter. Any way? Also I can see that you use Flexigrid 😉 where I can change default settings? I don’t want this to be collapsible

    Cheers and thanks for your support

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

ExpressionEngine News!

#eecms, #events, #releases