2017 © Pedro Peláez
 

library yepsql

SQL templating helper for PHP inspired by yesql.

image

yepsql/yepsql

SQL templating helper for PHP inspired by yesql.

  • Tuesday, September 12, 2017
  • by LionsHead
  • Repository
  • 1 Watchers
  • 9 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

YepSQL Build Status

SQL templating helper for PHP inspired by yesql., (*1)

Requirements: php >= 5.6; pdo_extension;, (*2)

Install: composer require yepsql/yepsql, (*3)

Usage

Create a file containing your SQL queries, (*4)

File example:

-- name: sqlQueryName
-- query annotation
SELECT count(*) FROM `table`;

-- name: getUsersInfo
-- request annotation 1 ...
-- request annotation 2 ...
SELECT *
FROM `table`
WHERE `user_id` = ? ;

-- name: updateUserName
UPDATE `table`
SET `user_name` = :user_name
WHERE `user_id` = :user_id ;

And call them in your code. Notice: "query-name" is converted to "query_name", php does not support this name methods., (*5)

Example:


$sql_template = new \YepSQL\Builder( new PDO_instance('sqlite::memory:'), // you instance of PDO '/path/to/file.sql' // file with queries ); // prepare SELECT * FROM `table` WHERE `user_id` = ? ; // and send query "getUsersInfo": // SELECT * FROM `table` WHERE `user_id` = 128; $user_id = 128; // request arguments $stmt = $sql_template->getUsersInfo($user_id); // returned PDOStatement instance $user_data = $stmt->fetch(PDO::FETCH_ASSOC); // send query "updateUserName": // UPDATE `table` SET `user_name` = 'NewUSerName' WHERE `user_id` = '128'; $sql_template->updateUserName([ ':user_name' => 'NewUSerName', ':user_id' => 128 ]);

Enjoy., (*6)

The Versions

12/09 2017

dev-master

9999999-dev https://github.com/LionHeads/YepSQL

SQL templating helper for PHP inspired by yesql.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-pdo *

 

The Development Requires

by Alexandr Savin

sql postgresql pdo mysql sqlite yesql

07/02 2016

v0.1.0

0.1.0.0 https://github.com/LionHeads/YepSQL

SQL templating helper for PHP inspired by yesql.

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-pdo *

 

The Development Requires

by Alexandr Savin

sql postgresql pdo mysql sqlite yesql