Welcome Guest, Not a member yet? Register   Sign In
v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD

[eluser]WCDi[/eluser]
[quote author="fabgonber" date="1308642473"]If it's "B" your model is right BUT you
need ProductEanProductId to ProductId.

¿Are you trying select it from product crud? It's easier do it
from ean crud:


Code:
function blah()
    {
            $crud = new grocery_CRUD();
            $crud->set_table('ean');
            $crud->set_relation('product_id','product','product_name');
            $crud->render();
    }

You can make new eans with one product.[/quote]
Tnx for your reply Smile I am indeed trying to (multiple) select/enter EAN's from the product CRUD. This is more efficient for the end-user. But if this isn't possible, I will have to do it the other way around, as you described Smile

@web-johnny > Thank you for the example, that really helps Smile

[eluser]web-johnny[/eluser]
[quote author="dodulz" date="1308682875"]I'M newbie use grocery CRUD ...
it's great plugin for CRUD, but I'Have problem with function set_model

in my model I use this code
Code:
<?php
class MAsset extends grocery_Model {

    function __construct(){
        parent::__construct();
    }
    
    function getAll(){
                $this->db->select('nama,email');
                $this->db->from('newsletter');
                $this->db->limit(10);
                $this->db->order_by('id_newslatter','ASC');
                $query = $this->db->get();
                return $query->result();
    }
    

}

and in controller I use

Code:
$this->load->library('grocery_Exceptions');
        try{
            /* This is only for the autocompletion */
            $crud = new grocery_CRUD();

            //$crud->set_theme('datatables');
            $this->load->model('MAsset');
            $datase = $this->MAsset->getAll();
            $crud->set_model($datase);
            $crud->set_subject('NewsLetter');
            $crud->required_fields('nama','email');
            $crud->columns('nama','email');
            $crud->render();
            
        }catch(Exception $e){
            $this->grocery_exceptions->show_error($e->getMessage(), $e->getTraceAsString());
        }

Error in Output :

Code:
Fatal error: Class 'grocery_Model' not found in C:\XXXX\XXX\application\models\MAsset.php on line 2

How to Fix this problem ?[/quote] For your CRUD that you say you don't need any model. Forgot the models. The set_model is for more complicated projects. For your example you can do it like this:

Code:
function my_newsletter(){
            $crud = new grocery_CRUD();

            $crud->order_by('id_newslatter','ASC');
            $crud->set_table('newsletter');
            $crud->set_subject('NewsLetter');
            $crud->required_fields('nama','email');
            $crud->columns('nama','email');
            $crud->render();
}
It's an easy codeigniter CRUD , no need of models, views, javascripts. It's easier than you think. Read the documentation and the installation for codeigniter 2 and see the working examples.

Hope I help.

Now if you want to use models in the future for your reasons - you will do it like this:

Code:
$crud = new grocery_CRUD();

            $crud->set_theme('datatables');
            $crud->set_model('MAsset');
            $crud->set_subject('NewsLetter');
            $crud->required_fields('nama','email');
            $crud->columns('nama','email');
            $crud->render();
and you MUST use your model by extending grocery_Model (That extends CI_Model) So if your model is something like this:
Code:
class MAsset extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
mpla mpla mpla....
}
Now it will be:
Code:
class MAsset extends grocery_Model {
//No need to have a contruct
function getAll(){

}
mpla mpla mpla....
}

[eluser]fabgonber[/eluser]
Web-Jhony

i'm having some problems with mysql stricted mode... the methods works fine in my laptop (ubuntu + mysql server + php5) but not in my server (debian + mysql + php5).

In debian when i make a "add" i only see the "clock" rounding.... i can note the problem is because Grocery don't make a insert with all the "campos",

example
table person(id,dni,name,age) and i put $crud->fields(dni,name) grocery do insert into person(id,dni,name) values(x,y,z) but mysql fails because age is not defined in the insert stament.

I feel is a problem in the mode of mysql... but i don't know how i can change it.

[eluser]web-johnny[/eluser]
[quote author="fabgonber" date="1308729099"]Web-Jhony

i'm having some problems with mysql stricted mode... the methods works fine in my laptop (ubuntu + mysql server + php5) but not in my server (debian + mysql + php5).

In debian when i make a "add" i only see the "clock" rounding.... i can note the problem is because Grocery don't make a insert with all the "campos",

example
table person(id,dni,name,age) and i put $crud->fields(dni,name) grocery do insert into person(id,dni,name) values(x,y,z) but mysql fails because age is not defined in the insert stament.

I feel is a problem in the mode of mysql... but i don't know how i can change it.[/quote]
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?

[eluser]fabgonber[/eluser]
[quote author="web-johnny" date="1308744289"]
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?
[/quote]

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.

[eluser]web-johnny[/eluser]
[quote author="fabgonber" date="1308783791"][quote author="web-johnny" date="1308744289"]
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?
[/quote]

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.[/quote] 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.

[eluser]mrwbsn[/eluser]
hello.. i've this error after i install to try this awesome timesaving stuff..

Code:
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. Big Grin

[eluser]web-johnny[/eluser]
[quote author="mrwbsn" date="1308843214"]hello.. i've this error after i install to try this awesome timesaving stuff..

Code:
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. Big Grin[/quote] 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-gui...ation.html

[eluser]mrwbsn[/eluser]
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. Big Grin

[eluser]javidhb[/eluser]
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




Theme © iAndrew 2016 - Forum software by © MyBB