Giter Club home page Giter Club logo

fluentpdo's Introduction

FluentPDO

FluentPDO - smart SQL builder for PHP.

FluentPDO is small PHP library for rapid query building. Killer feature is "Smart join builder" which generates joins automatically.

Features

  • Fluent interface for creating queries step by step
  • Smart join builder
  • Simple API based on PDO and SQL syntax
  • Build SELECT, INSERT query (UPDATE and DELETE comming soon)
  • Small and fast
  • Type hinting with code completion in smart IDEs
  • requires PHP 5.1+ with any database supported by PDO

Install

Just copy /FluentPDO directory into your libs/ directory then:

include "libs/FluentPDO/FluentPDO.php";
$pdo = new PDO("mysql:dbname=fblog", "root");
$fpdo = new FluentPDO($pdo);

First example

FluentPDO is easy to use:

$query = $fpdo->from('article')
			->where('published_at > ?', $date)
			->orderBy('published_at DESC')
			->limit(5);
if ($user_id) {
	$query = $query
			->where('user_id', $user_id)
			->select('user.name');        // this join table user
}
foreach ($query as $row) {
	echo "$row[name] - $row[title]\n";
}

And executed query is:

SELECT article.*, user.name
FROM article
		LEFT JOIN user ON user.id = article.user_id
WHERE published_at > ? AND user_id = ?
ORDER BY published_at DESC
LIMIT 5

Full documentation can you find on FluentPDO homepage

Licence

Free for commercial and non-commercial use (Apache License or GPL).

Copyright (c) 2012, Marek Lichtner

fluentpdo's People

Stargazers

Dan Smith avatar

Watchers

Dan Smith avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.