Simple QueryBuilder like ASP.NET Entity Framework.
I created this layer for my own project use and I find it very useful. This is not a super big many function framework but I build the crucial features for simple LINQ operation.
Few reasons I didn't apply lambda expressions
- Reflection in php? There is no way to parse .where(x => x.id == 1) into values, it will directly turn into boolean.
- There is no => arrow in php, if you want lambda it would look like
.where(function ($x) { $x.id == 1 }; ); //which is nonsense
Package includes
- Core DbSet code file for query builder and 1 BaseContext for mysqli $conn DI.
- Template for DbContext and DbSet, since there is no DbSet<> in php you have to extend DbSet
- NO $db->saveChanges(), this is only query builder that looks like Entity Framework.
- Table name -> plural
- Primary key -> id
- Foreign key -> target_table_id
The join demonstrated above is for one to many only. I will do custom join like the one in C# if my project needs it.