Closed pwFoo closed 4 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? 😄
At the moment you use mysqli. I think it need to moved to pdo?
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?
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.
Maybe also good for inspiration. https://github.com/nextras/orm uses PDO, but not support sqlite, active maintained.
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.
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?
Hi @delirius325 sqlite support isn't important for now... So you could close that issue if you want?
Hi, searching for a MySQL and SQLite solution. Any plans to add SQLite?