Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new Models structure as instantiation of Class. #195

Open
arnisjuraga opened this issue Oct 17, 2017 · 4 comments
Open

Implement new Models structure as instantiation of Class. #195

arnisjuraga opened this issue Oct 17, 2017 · 4 comments

Comments

@arnisjuraga
Copy link
Contributor

arnisjuraga commented Oct 17, 2017

The idea of centralizing models - what are your thoughts about getting rid of the model loader altogether, simply having models in a Model directory, and then just initializing them with $model = new ProductModel(); for instance? Would go a long way toward de-duplicating models.

Comments?

@lucasjkr
Copy link
Contributor

Pinging in here to see what people say

@prhost
Copy link
Contributor

prhost commented Oct 17, 2017

If they accept ORM and help to test, it is almost ready (:

@prhost
Copy link
Contributor

prhost commented Oct 17, 2017

What I said to @arnisjuraga

in the implementation of ORM, I already have a new structure of Models, still need to convert all the tables into models, plus the relationship between them and the business rule within them, of course this requires time and testing.

but to support the new structure is already a beginning, then only gradually converting the models

@lucasjkr
Copy link
Contributor

I'm pushing ahead on my version too :)

I've put ALL the models for the project in a new directory,/common/models

I did some refactoring:

All the models that were in admin, have had Admin appended to their class name, and all the controllers have been refactored to load those models:

$this->load->model('user/user') became $this->load->model('user/user_admin')

I had been converting the models in Admin to use prepared statements, but realized I was going in the wrong order. So now that the model files are combined together, I can do the refactoring once, then compare models, and merge missing functions together.

I also have to do a LITTLE tweaking to the database class. Since I'm only supporting mySql through PDO, I need to get migrate the functions in library/db/mpdo into library/db.php.

Other databases COULD be supported through PDO, but some queries would need to be rewritten (just like they would anyways).

Here's where I'm at so far:

https://github.com/lucasjkr/opencommerce/tree/combine-models

look in /common/model/

the first half of the admin models were refactored to prepared statements, so if you look at /common/model/catalog/product_admin.php, you can see what I've done.

Not sure if it helps with the ORM, but feel free!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants