anthonygauthier / MySimpleORM

Simple, lightweight and effective PHP ORM using MySQLi.
MIT License
7 stars 4 forks source link

SQLite support? #9

Closed pwFoo closed 4 years ago

pwFoo commented 5 years ago

Hi, searching for a MySQL and SQLite solution. Any plans to add SQLite?

anthonygauthier commented 5 years ago

Hey @pwFoo,

Glad to see this ORM getting some attraction 😄 ! It for sure is something we could implement in the future. I believe a few things would have to be done to do it right however.

First of all, the current structure should change a little bit. The Database class could become an interface which would implement the basic methods:

setup()
connect()
disconnect()
select()
insert()
delete()
update()
getQuery()
getError()

This means that the Database class would then become something like mysqlAdapter and it would implement Database. Also, the setup() method in Database would require an array as an argument to define certain parameters (adapter, connection info, etc.).

What do you think? 😄

pwFoo commented 5 years ago

At the moment you use mysqli. I think it need to moved to pdo?

pwFoo commented 5 years ago

Maybe https://github.com/rene-s/SimpleOrm cloud be interesting example / starting point to move to PDO? It's based on PDO and supports msql / sqlite. Had a quick look into it, but don't see different "drivers" for mysql and sqlite. Maybe the used features / methods of PDO are identical used for both database types?

pwFoo commented 5 years ago

From readme:

Immature. Do not use.

This is a no-frills simple ORM class for PHP/sqlite and MySQL. Project goals are to

  • provide ORM functionality
  • be as simple and small as possible
  • be clean.
pwFoo commented 5 years ago

Maybe also good for inspiration. https://github.com/nextras/orm uses PDO, but not support sqlite, active maintained.

anthonygauthier commented 5 years ago

Moving to PDO shouldn't be an issue. However, I would still move to a structure similar to what I've described to be able to use the ORM for more databases. Meaning it could be used for Mongo, Cassandra, etc.

pwFoo commented 5 years ago

Another example: https://github.com/ForestryCodes/orm

First look that example uses a structure similiar to your suggestion.

The methods above are fine to me. You should add query () or raw() to execute custom database queries?

Should each table defined by a class which extends a base class or a generic class which get the table name as parameter?

pwFoo commented 4 years ago

Hi @delirius325 sqlite support isn't important for now... So you could close that issue if you want?