LessQL is a lightweight and efficient alternative to Object-Relational Mapping for PHP.

A novel, intuitive approach to SQL databases that performs:

	// Connect to database
	$pdo = new PDO( 'sqlite:blog.sqlite3' );
	$db = new LessQL\Database( $pdo );

	// Find posts, their authors and categories efficiently:
	// Eager loading of references happens automatically.
	// This example only needs FOUR queries, one for each table.
	foreach ( $db->post()
		->where( 'is_published', 1 )
		->orderBy( 'date_published', 'DESC' ) as $post ) {

		$author = $post->user()->fetch();

		foreach ( $post->categorizationList()->category() as $category ) {

			// ...



Less Code

No models, no configuration, no glue code. Just start working with your existing database immediately.

Less Queries

Find associated data from multiple database tables using a minimal amount of queries. No more N+1 problems.

Less Hassle

The concise and intuitive API is easily learned and provides all the capabilities you need.


Work closely to your database instead of using an inadequate abstraction layer.


Save complex, nested structures with one method call, blend with raw SQL at any time, and more.


Fully tested with MySQL, PostgreSQL, and SQLite3.

Build Status Test Coverage Join the chat at https://gitter.im/morris/lessql

Get started >