Welcome Guest, Not a member yet? Register   Sign In
auto generating models from DB solution
#1

Hello,

I really appreciate codeIgniter wich is my favorite framework but I think that CI need a TOP must have feature : an auto models generating process from db.
This is very important because when I design an application I start by my EER diagram on mysql workbench when it's done I generate my sql for phpmyadmin and then I should create my models by hand for 35 tables... painfull, errors...

In comparison with java/JPA netbeans connect to my db and generate my entities from tables with all relations. according to Doctrine doc this process doesn't work really so what is the solution ?

thanks 4 your help.
Reply
#2

(This post was last modified: 12-19-2016, 04:27 PM by PaulD.)

There are lots of good looking CRUD generators for CI around. Personally I played with one (and it was interesting to say the least) but in the end I never actually used it in a project. I thought I had a link to a good one in my user panel but couldn't find it when I looked for you - sorry.

You can just google for one though. Here is one I found via google

http://www.grocerycrud.com/

Is that the sort of thing you meant?

Edit:
PS I think I didn't use this because I do not adhere to the idea of one model per table. I use my models more for business logic, for instance I would have a user_model, a project_model, a task_model, all of which interact with many tables. I may have misunderstood what you meant but I find this much more compact and fluid and maintainable.
Reply
Reply
#4

I have created my own generator (webbased) wich generates a zip file with an HMVC module with a basic controller (public and admin), a model (with validation rules), admin view file, language files, a migration file and an empty config file. Everything I need to get started quickly.

Such a generator is extremely personalized and anything but a general solution. My admin view file for exemple is full with Bootstrap code, font-awesome and other classes I use in my overall CMS system. It also depends on spesific things in my own MY_Model, MY_Controller (admin and public), MY_Formvalidation, etc etc...
For those same reasons I think making a general system wich makes everyone happy cannot be done.

I believe multiple people here have such generators, most use CLI for file generation. For example: https://github.com/avenirer/codeigniter-matches-cli
There also is an online generator somewhere on the web that you could use.
Reply
#5

(12-20-2016, 12:16 AM)buoncri Wrote: On other hand you can use a my_model like these:

https://github.com/jamierumbelow/codeigniter-base-model or https://github.com/avenirer/CodeIgniter-MY_Model

for a rapid know how read http://www.codebyjeff.com/blog/2012/01/u...s-my_model

Now you say that I recall that for a while I did my own generalised model to which I could post instructions like

PHP Code:
$this->base_model->get_single_row('table_name'$id 127); 

But that was a while ago and I must admit in the end it became more cumbersome than useful. After all the CI query builder can be extremely compact all by itself at times without the need for the general base model.

PHP Code:
$this->db->from('table_name')->where('id'127)->get()->row_array(); 

So for the sake of maintainability I do not do it any more.
Reply
#6

(12-19-2016, 04:24 PM)PaulD Wrote: There are lots of good looking CRUD generators for CI around. Personally I played with one (and it was interesting to say the least) but in the end I never actually used it in a project. I thought I had a link to a good one in my user panel but couldn't find it when I looked for you - sorry.

You can just google for one though. Here is one I found via google

http://www.grocerycrud.com/

Is that the sort of thing you meant?

Edit:
PS I think I didn't use this because I do not adhere to the idea of one model per table. I use my models more for business logic, for instance I would have a user_model, a project_model, a task_model, all of which interact with many tables. I may have misunderstood what you meant but I find this much more compact and fluid and maintainable.
 
Yes I am looking on this orm I want to be sure to use the good one.
Reply
#7

(12-20-2016, 02:11 AM)Diederik Wrote: I have created my own generator (webbased) wich generates a zip file with an HMVC module with a basic controller (public and admin), a model (with validation rules), admin view file, language files, a migration file and an empty config file. Everything I need to get started quickly.

Such a generator is extremely personalized and anything but a general solution. My admin view file for exemple is full with Bootstrap code, font-awesome and other classes I use in my overall CMS system. It also depends on spesific things in my own MY_Model, MY_Controller (admin and public), MY_Formvalidation, etc etc...
For those same reasons I think making a general system wich makes everyone happy cannot be done.

I believe multiple people here have such generators, most use CLI for file generation. For example: https://github.com/avenirer/codeigniter-matches-cli
There also is an online generator somewhere on the web that you could use.

it looks fine but does it comply with all types of relationships ?
Reply
#8

(12-20-2016, 11:35 AM)PaulD Wrote:
(12-20-2016, 12:16 AM)buoncri Wrote: On other hand you can use a my_model like these:

https://github.com/jamierumbelow/codeigniter-base-model or https://github.com/avenirer/CodeIgniter-MY_Model

for a rapid know how read http://www.codebyjeff.com/blog/2012/01/u...s-my_model

Now you say that I recall that for a while I did my own generalised model to which I could post instructions like

PHP Code:
$this->base_model->get_single_row('table_name'$id 127); 

But that was a while ago and I must admit in the end it became more cumbersome than useful. After all the CI query builder can be extremely compact all by itself at times without the need for the general base model.

PHP Code:
$this->db->from('table_name')->where('id'127)->get()->row_array(); 

So for the sake of maintainability I do not do it any more.

It's ok for simple requests but if we need to request through many-to-many relationships we must write query in controller so it's not very clean ?...(java behaviour  Blush )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB