In this article I’m going to walk you through Medoo, a lightweight database abstraction library for PHP. Its main features include:
Support for multiple databases – it supports MySQL, MariaDB, Sybase, MS SQL, PostgreSQL, and Oracle.
Secure – prevents SQL injection, it uses PDO.
Easy to use – its API is very intuitive.
While Medoo is nothing revolutionary, and the fact that it sports a very small filesize matters little to few, it’s still an interesting project that went from being outright dismissed to vaguely accepted, as evident in these threads. It’s on its way up, and that’s our reason for taking a look at it.
Installation
Even though the website recommends installing it by downloading a file and including it in your project, you should use Composer to do so.
I read the article, if that’s all there is to this library it’s a complete waste of time. It offers no advantages over straight SQL if you know what you’re doing. You end up spending time learning their syntax instead of learning PDO + SQL’s syntax to do the same thing. For example how is this?
Well, either I use a very sophisticated DBAL, like Propel, Doctrine, or I go directly with Native SQL.
A Lisp-like grammar “AND(a, b)” is NOT intuitive at all. It may be easier for the wrapper to parse, but it is against all human reading and SQL grammar presentation.
This looks a lot like Zend Framework 1.x’s ZendDb layer.
If your query is built using complex logic, abstracting the query into an object is pretty helpful.
I probably won’t be using this.
This is too complex for the simple case and not that different from Zend Db.