Browse Source

initial for idiorm

pull/11/head
Andrew Dolgov 2 months ago
parent
commit
f38be747d1
  1. 1
      .gitignore
  2. 29
      classes/db.php
  3. 77
      classes/pref/users.php
  4. 3
      composer.json
  5. 68
      composer.lock
  6. 30
      vendor/composer/InstalledVersions.php
  7. 5
      vendor/composer/autoload_classmap.php
  8. 5
      vendor/composer/autoload_static.php
  9. 69
      vendor/composer/installed.json
  10. 23
      vendor/composer/installed.php
  11. 16
      vendor/j4mie/idiorm/CONTRIBUTING.md
  12. 239
      vendor/j4mie/idiorm/README.markdown
  13. 49
      vendor/j4mie/idiorm/composer.json
  14. 81
      vendor/j4mie/idiorm/demo.php
  15. 153
      vendor/j4mie/idiorm/docs/Makefile
  16. 242
      vendor/j4mie/idiorm/docs/conf.py
  17. 378
      vendor/j4mie/idiorm/docs/configuration.rst
  18. 80
      vendor/j4mie/idiorm/docs/connections.rst
  19. 29
      vendor/j4mie/idiorm/docs/index.rst
  20. 19
      vendor/j4mie/idiorm/docs/installation.rst
  21. 190
      vendor/j4mie/idiorm/docs/make.bat
  22. 161
      vendor/j4mie/idiorm/docs/models.rst
  23. 34
      vendor/j4mie/idiorm/docs/philosophy.rst
  24. 896
      vendor/j4mie/idiorm/docs/querying.rst
  25. 21
      vendor/j4mie/idiorm/docs/transactions.rst
  26. 2539
      vendor/j4mie/idiorm/idiorm.php

1
.gitignore

@ -11,3 +11,4 @@ Thumbs.db
/cache/*/*
/lock/*
/.vscode/settings.json
/vendor/**/.git

29
classes/db.php

@ -1,27 +1,38 @@
<?php
class Db
{
/* @var Db $instance */
/** @var Db $instance */
private static $instance;
private $link;
/* @var PDO $pdo */
/** @var PDO $pdo */
private $pdo;
function __construct() {
ORM::configure(self::get_dsn());
ORM::configure('username', Config::get(Config::DB_USER));
ORM::configure('password', Config::get(Config::DB_PASS));
ORM::configure('return_result_sets', true);
}
private function __clone() {
//
}
// this really shouldn't be used unless a separate PDO connection is needed
// normal usage is Db::pdo()->prepare(...) etc
public function pdo_connect() {
public static function get_dsn() {
$db_port = Config::get(Config::DB_PORT) ? ';port=' . Config::get(Config::DB_PORT) : '';
$db_host = Config::get(Config::DB_HOST) ? ';host=' . Config::get(Config::DB_HOST) : '';
return Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port;
}
// this really shouldn't be used unless a separate PDO connection is needed
// normal usage is Db::pdo()->prepare(...) etc
public function pdo_connect() : PDO {
try {
$pdo = new PDO(Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port,
$pdo = new PDO(self::get_dsn(),
Config::get(Config::DB_USER),
Config::get(Config::DB_PASS));
} catch (Exception $e) {
@ -49,7 +60,7 @@ class Db
return $pdo;
}
public static function instance() {
public static function instance() : Db {
if (self::$instance == null)
self::$instance = new self();
@ -60,7 +71,7 @@ class Db
if (self::$instance == null)
self::$instance = new self();
if (!self::$instance->pdo) {
if (empty(self::$instance->pdo)) {
self::$instance->pdo = self::$instance->pdo_connect();
}

77
classes/pref/users.php

@ -14,9 +14,9 @@ class Pref_Users extends Handler_Administrative {
$sth = $this->pdo->prepare("SELECT id, login, access_level, email FROM ttrss_users WHERE id = ?");
$sth->execute([$id]);
if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
if ($user = $sth->fetch(PDO::FETCH_ASSOC)) {
print json_encode([
"user" => $row,
"user" => $user,
"access_level_names" => $access_level_names
]);
}
@ -106,21 +106,22 @@ class Pref_Users extends Handler_Administrative {
}
function editSave() {
$login = clean($_REQUEST["login"]);
$uid = (int) clean($_REQUEST["id"]);
$access_level = (int) clean($_REQUEST["access_level"]);
$email = clean($_REQUEST["email"]);
$id = (int)$_REQUEST['id'];
$password = clean($_REQUEST["password"]);
$user = ORM::for_table('ttrss_users')->find_one($id);
if ($user) {
$login = clean($_REQUEST["login"]);
// no blank usernames
if (!$login) return;
if ($id == 1) $login = "admin";
if (!$login) return;
// forbid renaming admin
if ($uid == 1) $login = "admin";
$user->login = $login;
$user->access_level = (int) clean($_REQUEST["access_level"]);
$user->email = clean($_REQUEST["email"]);
$sth = $this->pdo->prepare("UPDATE ttrss_users SET login = LOWER(?),
access_level = ?, email = ?, otp_enabled = false WHERE id = ?");
$sth->execute([$login, $access_level, $email, $uid]);
$user->save();
}
if ($password) {
UserHelper::reset_password($uid, false, $password);
@ -194,11 +195,10 @@ class Pref_Users extends Handler_Administrative {
$sort = "login";
}
$sort = $this->_validate_field($sort,
["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
if (!in_array($sort, ["login", "access_level", "created", "num_feeds", "created", "last_login"]))
$sort = "login";
if ($sort != "login") $sort = "$sort DESC";
?>
<div dojoType='dijit.layout.BorderContainer' gutters='false'>
@ -253,32 +253,28 @@ class Pref_Users extends Handler_Administrative {
</tr>
<?php
$sth = $this->pdo->prepare("SELECT
tu.id,
login,access_level,email,
".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login,
".SUBSTRING_FOR_DATE."(created,1,16) as created,
(SELECT COUNT(id) FROM ttrss_feeds WHERE owner_uid = tu.id) AS num_feeds
FROM
ttrss_users tu
WHERE
(:search = '' OR login LIKE :search) AND tu.id > 0
ORDER BY $sort");
$sth->execute([":search" => $user_search ? "%$user_search%" : ""]);
while ($row = $sth->fetch()) { ?>
<tr data-row-id='<?= $row["id"] ?>' onclick='Users.edit(<?= $row["id"] ?>)' title="<?= __('Click to edit') ?>">
$users = ORM::for_table('ttrss_users')
->table_alias('u')
->left_outer_join("ttrss_feeds", ["owner_uid", "=", "u.id"], 'f')
->select_expr('u.*,COUNT(f.id) AS num_feeds')
->where_like("login", $user_search ? "%$user_search%" : "%")
->order_by_expr($sort)
->group_by_expr('u.id')
->find_many();
foreach ($users as $user) { ?>
<tr data-row-id='<?= $user["id"] ?>' onclick='Users.edit(<?= $user["id"] ?>)' title="<?= __('Click to edit') ?>">
<td align='center'>
<input onclick='Tables.onRowChecked(this); event.stopPropagation();'
dojoType='dijit.form.CheckBox' type='checkbox'>
</td>
<td><i class='material-icons'>person</i> <?= htmlspecialchars($row["login"]) ?></td>
<td><?= $access_level_names[$row["access_level"]] ?></td>
<td><?= $row["num_feeds"] ?></td>
<td><?= TimeHelper::make_local_datetime($row["created"], false) ?></td>
<td><?= TimeHelper::make_local_datetime($row["last_login"], false) ?></td>
<td><i class='material-icons'>person</i> <?= htmlspecialchars($user["login"]) ?></td>
<td><?= $access_level_names[$user["access_level"]] ?></td>
<td><?= $user["num_feeds"] ?></td>
<td><?= TimeHelper::make_local_datetime($user["created"], false) ?></td>
<td><?= TimeHelper::make_local_datetime($user["last_login"], false) ?></td>
</tr>
<?php } ?>
</table>
@ -288,11 +284,4 @@ class Pref_Users extends Handler_Administrative {
<?php
}
private function _validate_field($string, $allowed, $default = "") {
if (in_array($string, $allowed))
return $string;
else
return $default;
}
}

3
composer.json

@ -2,6 +2,7 @@
"require": {
"spomky-labs/otphp": "^10.0",
"chillerlan/php-qrcode": "^3.3",
"mervick/material-design-icons": "^2.2"
"mervick/material-design-icons": "^2.2",
"j4mie/idiorm": "^1.5"
}
}

68
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "923f1c16aa4774d149c9084695110d44",
"content-hash": "e7f23b092328c903b06c8ae31bf13781",
"packages": [
{
"name": "beberlei/assert",
@ -201,6 +201,72 @@
},
"time": "2019-09-10T00:09:44+00:00"
},
{
"name": "j4mie/idiorm",
"version": "v1.5.7",
"source": {
"type": "git",
"url": "https://github.com/j4mie/idiorm.git",
"reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/j4mie/idiorm/zipball/d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4",
"reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"phpunit/phpunit": "^4.8"
},
"type": "library",
"autoload": {
"classmap": [
"idiorm.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause",
"BSD-3-Clause",
"BSD-4-Clause"
],
"authors": [
{
"name": "Jamie Matthews",
"email": "jamie.matthews@gmail.com",
"homepage": "http://j4mie.org",
"role": "Developer"
},
{
"name": "Simon Holywell",
"email": "treffynnon@php.net",
"homepage": "http://simonholywell.com",
"role": "Maintainer"
},
{
"name": "Durham Hale",
"email": "me@durhamhale.com",
"homepage": "http://durhamhale.com",
"role": "Maintainer"
}
],
"description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5",
"homepage": "http://j4mie.github.com/idiormandparis",
"keywords": [
"idiorm",
"orm",
"query builder"
],
"support": {
"issues": "https://github.com/j4mie/idiorm/issues",
"source": "https://github.com/j4mie/idiorm"
},
"time": "2020-04-29T00:37:09+00:00"
},
{
"name": "mervick/material-design-icons",
"version": "2.2.0",

30
vendor/composer/InstalledVersions.php

@ -30,7 +30,8 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'bada1601fc231ecde54a528a545611429d60af21',
'reference' => 'f96abd2b52b9de5eac3651594ca32c6a4023c3e3',
'dev-requirement' => true,
'name' => '__root__',
),
'versions' =>
@ -42,7 +43,8 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => 'bada1601fc231ecde54a528a545611429d60af21',
'reference' => 'f96abd2b52b9de5eac3651594ca32c6a4023c3e3',
'dev-requirement' => false,
),
'beberlei/assert' =>
array (
@ -52,6 +54,7 @@ private static $installed = array (
array (
),
'reference' => 'd63a6943fc4fd1a2aedb65994e3548715105abcf',
'dev-requirement' => false,
),
'chillerlan/php-qrcode' =>
array (
@ -61,6 +64,7 @@ private static $installed = array (
array (
),
'reference' => 'd8bf297e6843a53aeaa8f3285ce04fc349d133d6',
'dev-requirement' => false,
),
'chillerlan/php-settings-container' =>
array (
@ -70,6 +74,17 @@ private static $installed = array (
array (
),
'reference' => 'b9b0431dffd74102ee92348a63b4c33fc8ba639b',
'dev-requirement' => false,
),
'j4mie/idiorm' =>
array (
'pretty_version' => 'v1.5.7',
'version' => '1.5.7.0',
'aliases' =>
array (
),
'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4',
'dev-requirement' => false,
),
'mervick/material-design-icons' =>
array (
@ -79,6 +94,7 @@ private static $installed = array (
array (
),
'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a',
'dev-requirement' => false,
),
'paragonie/constant_time_encoding' =>
array (
@ -88,6 +104,7 @@ private static $installed = array (
array (
),
'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c',
'dev-requirement' => false,
),
'spomky-labs/otphp' =>
array (
@ -97,6 +114,7 @@ private static $installed = array (
array (
),
'reference' => 'f44cce5a9db4b8da410215d992110482c931232f',
'dev-requirement' => false,
),
'thecodingmachine/safe' =>
array (
@ -106,6 +124,7 @@ private static $installed = array (
array (
),
'reference' => 'a8ab0876305a4cdaef31b2350fcb9811b5608dbc',
'dev-requirement' => false,
),
),
);
@ -125,7 +144,6 @@ foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
@ -141,11 +159,12 @@ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
public static function isInstalled($packageName)
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return true;
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev-requirement']);
}
}
@ -164,7 +183,6 @@ return false;
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);

5
vendor/composer/autoload_classmap.php

@ -7,4 +7,9 @@ $baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'IdiormMethodMissingException' => $vendorDir . '/j4mie/idiorm/idiorm.php',
'IdiormResultSet' => $vendorDir . '/j4mie/idiorm/idiorm.php',
'IdiormString' => $vendorDir . '/j4mie/idiorm/idiorm.php',
'IdiormStringException' => $vendorDir . '/j4mie/idiorm/idiorm.php',
'ORM' => $vendorDir . '/j4mie/idiorm/idiorm.php',
);

5
vendor/composer/autoload_static.php

@ -154,6 +154,11 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'IdiormMethodMissingException' => __DIR__ . '/..' . '/j4mie/idiorm/idiorm.php',
'IdiormResultSet' => __DIR__ . '/..' . '/j4mie/idiorm/idiorm.php',
'IdiormString' => __DIR__ . '/..' . '/j4mie/idiorm/idiorm.php',
'IdiormStringException' => __DIR__ . '/..' . '/j4mie/idiorm/idiorm.php',
'ORM' => __DIR__ . '/..' . '/j4mie/idiorm/idiorm.php',
);
public static function getInitializer(ClassLoader $loader)

69
vendor/composer/installed.json

@ -204,6 +204,75 @@
},
"install-path": "../chillerlan/php-settings-container"
},
{
"name": "j4mie/idiorm",
"version": "v1.5.7",
"version_normalized": "1.5.7.0",
"source": {
"type": "git",
"url": "https://github.com/j4mie/idiorm.git",
"reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/j4mie/idiorm/zipball/d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4",
"reference": "d23f97053ef5d0b988a02c6a71eb5c6118b2f5b4",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"phpunit/phpunit": "^4.8"
},
"time": "2020-04-29T00:37:09+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"classmap": [
"idiorm.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause",
"BSD-3-Clause",
"BSD-4-Clause"
],
"authors": [
{
"name": "Jamie Matthews",
"email": "jamie.matthews@gmail.com",
"homepage": "http://j4mie.org",
"role": "Developer"
},
{
"name": "Simon Holywell",
"email": "treffynnon@php.net",
"homepage": "http://simonholywell.com",
"role": "Maintainer"
},
{
"name": "Durham Hale",
"email": "me@durhamhale.com",
"homepage": "http://durhamhale.com",
"role": "Maintainer"
}
],
"description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5",
"homepage": "http://j4mie.github.com/idiormandparis",
"keywords": [
"idiorm",
"orm",
"query builder"
],
"support": {
"issues": "https://github.com/j4mie/idiorm/issues",
"source": "https://github.com/j4mie/idiorm"
},
"install-path": "../j4mie/idiorm"
},
{
"name": "mervick/material-design-icons",
"version": "2.2.0",

23
vendor/composer/installed.php

@ -6,7 +6,8 @@
'aliases' =>
array (
),
'reference' => 'bada1601fc231ecde54a528a545611429d60af21',
'reference' => 'f96abd2b52b9de5eac3651594ca32c6a4023c3e3',
'dev-requirement' => true,
'name' => '__root__',
),
'versions' =>
@ -18,7 +19,8 @@
'aliases' =>
array (
),
'reference' => 'bada1601fc231ecde54a528a545611429d60af21',
'reference' => 'f96abd2b52b9de5eac3651594ca32c6a4023c3e3',
'dev-requirement' => false,
),
'beberlei/assert' =>
array (
@ -28,6 +30,7 @@
array (
),
'reference' => 'd63a6943fc4fd1a2aedb65994e3548715105abcf',
'dev-requirement' => false,
),
'chillerlan/php-qrcode' =>
array (
@ -37,6 +40,7 @@
array (
),
'reference' => 'd8bf297e6843a53aeaa8f3285ce04fc349d133d6',
'dev-requirement' => false,
),
'chillerlan/php-settings-container' =>
array (
@ -46,6 +50,17 @@
array (
),
'reference' => 'b9b0431dffd74102ee92348a63b4c33fc8ba639b',
'dev-requirement' => false,
),
'j4mie/idiorm' =>
array (
'pretty_version' => 'v1.5.7',
'version' => '1.5.7.0',
'aliases' =>
array (
),
'reference' => 'd23f97053ef5d0b988a02c6a71eb5c6118b2f5b4',
'dev-requirement' => false,
),
'mervick/material-design-icons' =>
array (
@ -55,6 +70,7 @@
array (
),
'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a',
'dev-requirement' => false,
),
'paragonie/constant_time_encoding' =>
array (
@ -64,6 +80,7 @@
array (
),
'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c',
'dev-requirement' => false,
),
'spomky-labs/otphp' =>
array (
@ -73,6 +90,7 @@
array (
),
'reference' => 'f44cce5a9db4b8da410215d992110482c931232f',
'dev-requirement' => false,
),
'thecodingmachine/safe' =>
array (
@ -82,6 +100,7 @@
array (
),
'reference' => 'a8ab0876305a4cdaef31b2350fcb9811b5608dbc',
'dev-requirement' => false,
),
),
);

16
vendor/j4mie/idiorm/CONTRIBUTING.md

@ -0,0 +1,16 @@
---
### Feature complete
Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it will continue to be maintained with bug fixes there will be no further new features added.
**Please do not submit feature requests or pull requests adding new features as they will be closed without ceremony.**
---
When making a pull request please include the following aspects:
- Update the changelog in the README.markdown file to include details of the pull request
- If the documentation in the README or Sphinx docs needs to be amended please do so in the pull request
- Include unit tests for any changes - if it is a bug include at least one regression test

239
vendor/j4mie/idiorm/README.markdown

@ -0,0 +1,239 @@
Idiorm
======
[![Build Status](https://travis-ci.org/j4mie/idiorm.png?branch=master)](https://travis-ci.org/j4mie/idiorm) [![Latest Stable Version](https://poser.pugx.org/j4mie/idiorm/v/stable.png)](https://packagist.org/packages/j4mie/idiorm) [![Total Downloads](https://poser.pugx.org/j4mie/idiorm/downloads.png)](https://packagist.org/packages/j4mie/idiorm) [![Code Climate](https://codeclimate.com/github/j4mie/idiorm/badges/gpa.svg)](https://codeclimate.com/github/j4mie/idiorm)
[http://j4mie.github.com/idiormandparis/](http://j4mie.github.com/idiormandparis/)
---
### Feature/API complete
Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it will continue to be maintained with bug fixes there will be no further new features added from this point on. This means that if a pull request makes breaking changes to the API or requires anything other than a patch version bump of the library then it will not be merged.
**Please do not submit feature requests or API breaking changes as they will be closed without ceremony.**
---
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5 and above.
Tested on PHP 5.2.0+ - may work on earlier versions with PDO and the correct database drivers.
Released under a [BSD license](http://en.wikipedia.org/wiki/BSD_licenses).
**See Also: [Paris](http://github.com/j4mie/paris), an Active Record implementation built on top of Idiorm.**
Features
--------
* Makes simple queries and simple CRUD operations completely painless.
* Gets out of the way when more complex SQL is required.
* Built on top of [PDO](http://php.net/pdo).
* Uses [prepared statements](http://uk.php.net/manual/en/pdo.prepared-statements.php) throughout to protect against [SQL injection](http://en.wikipedia.org/wiki/SQL_injection) attacks.
* Requires no model classes, no XML configuration and no code generation: works out of the box, given only a connection string.
* Consists of one main class called `ORM`. Additional classes are prefixed with `Idiorm`. Minimal global namespace pollution.
* Database agnostic. Currently supports SQLite, MySQL, Firebird and PostgreSQL. May support others, please give it a try!
* Supports collections of models with method chaining to filter or apply actions to multiple results at once.
* Multiple connections supported
* PSR-1 compliant methods (any method can be called in camelCase instead of underscores eg. `find_many()` becomes `findMany()`) - you'll need PHP 5.3+
Documentation
-------------
The documentation is hosted on Read the Docs: [idiorm.rtfd.org](http://idiorm.rtfd.org)
### Building the Docs ###
You will need to install [Sphinx](http://sphinx-doc.org/) and then in the docs folder run:
make html
The documentation will now be in docs/_build/html/index.html
Let's See Some Code
-------------------
```php
$user = ORM::for_table('user')
->where_equal('username', 'j4mie')
->find_one();
$user->first_name = 'Jamie';
$user->save();
$tweets = ORM::for_table('tweet')
->select('tweet.*')
->join('user', array(
'user.id', '=', 'tweet.user_id'
))
->where_equal('user.username', 'j4mie')
->find_many();
foreach ($tweets as $tweet) {
echo $tweet->text;
}
```
Tests
-----
Tests are written with PHPUnit and be run through composer
composer test
To make testing on PHP 5.2 (Idiorm maintains support back to this version of PHP) there
is a Docker setup in `./test/docker_for_php52` - check the readme in there for more.
Changelog
---------
#### 1.5.7 - released 2020-04-29
* Fix argument order in call to join() [[CatalinFrancu](https://github.com/CatalinFrancu)] - [issue #357](https://github.com/j4mie/idiorm/pull/357)
#### 1.5.6 - released 2018-05-31
* Assign `null` to `self::$_db` on `reset_db()` to ensure PDO closes the connections [[bleakgadfly](https://github.com/bleakgadfly)] - [issue #338](https://github.com/j4mie/idiorm/issues/338)
#### 1.5.5 - released 2018-01-05
* Add a docker setup for testing with PHP 5.2 (uses PHPUnit 3.6.12, which is the last version released compatible with PHP 5.2) [[Treffynnon](https://github.com/treffynnon)]
#### 1.5.4 - released 2018-01-04
* Reset Idiorm state when a cached result is returned [[fayland](https://github.com/fayland) (and [Treffynnon](https://github.com/treffynnon))] - [issue #319](https://github.com/j4mie/idiorm/issues/319)
* Fix travis builds for PHP 5.2+ (adding 7.0 and 7.1) and document support for newer PHP versions [[Treffynnon](https://github.com/treffynnon)]
* Correct PHPDoc comments for `selectMany()` [[kawausokun](https://github.com/kawausokun)] - [issue #325](github.com/j4mie/idiorm/issues/325)
* Add pdo_sqlite to the composer require-dev dependencies [[qyanu](https://github.com/qyanu)] - [issue #328](github.com/j4mie/idiorm/issues/328)
#### 1.5.3 - released 2017-03-21
* Document the `raw_execute()` method and add a note for `get_db()` in the querying documentation - [[Treffynnon](https://github.com/treffynnon)]
#### 1.5.2 - released 2016-12-14
* Fix autoincremented compound keys inserts [[lrlopez](https://github.com/lrlopez)] - [issue #233](https://github.com/j4mie/idiorm/issues/233) and [pull #235](https://github.com/j4mie/idiorm/pull/235)
* Add @method tags for magic methods [[stellis](https://github.com/stellis)] - [issue #237](https://github.com/j4mie/idiorm/issues/237)
* Ensure `is_dirty()` returns correctly when fed null or an empty string [[tentwofour](https://github.com/tentwofour)] - [issue #268](https://github.com/j4mie/idiorm/issues/268)
* Adding Code Climate badge to the readme file [[e3betht](https://github.com/e3betht)] - [issue #260](https://github.com/j4mie/idiorm/issues/260)
* Typo in navigation [[leongersen](https://github.com/leongersen)] - [issue #257](https://github.com/j4mie/idiorm/issues/257)
* Support named placeholders logging and test [[m92o](https://github.com/m92o)] - [issue #223](https://github.com/j4mie/idiorm/issues/223)
* `having_id_is()` reference undefined variable `$value` [[Treffynnon](https://github.com/treffynnon)] - [issue #224](https://github.com/j4mie/idiorm/issues/224)
* Documentation fix - ORM query output for `where_any_is()` [[uovidiu](https://github.com/uovidiu)] - [issue #306](https://github.com/j4mie/idiorm/issues/306)
* Code style fix preventing nested loops from using the same variable names [[mkkeck](https://github.com/mkkeck)] - [issue #301](https://github.com/j4mie/idiorm/issues/301)
* Document shortcomings of the built in query logger [[Treffynnon](https://github.com/treffynnon)] - [issue #307](https://github.com/j4mie/idiorm/issues/307)
* Add phpunit to dev dependencies, add `composer test` script shortcut and fix PDO mock in test bootstrap [[Treffynnon](https://github.com/treffynnon)]
* New test for multiple raw where clauses [[Treffynnon](https://github.com/treffynnon)] - [issue #236](https://github.com/j4mie/idiorm/issues/236)
* Remove PHP 5.2 from travis-ci containers to test against (**note** Idiorm still supports PHP 5.2 despite this) [[Treffynnon](https://github.com/treffynnon)]
#### 1.5.1 - released 2014-06-23
* Binding of named parameters was broken [[cainmi](https://github.com/cainmi)] - [issue #221](https://github.com/j4mie/idiorm/pull/221)
#### 1.5.0 - released 2014-06-22
* Multiple OR'ed conditions support [[lrlopez](https://github.com/lrlopez)] - [issue #201](https://github.com/j4mie/idiorm/issues/201)
* `where_id_in()` for selecting multiple records by primary key [[lrlopez](https://github.com/lrlopez)] - [issue #202](https://github.com/j4mie/idiorm/issues/202)
* Add compound primary key support [[lrlopez](https://github.com/lrlopez)] - [issue #171](https://github.com/j4mie/idiorm/issues/171)
* Add a RAW JOIN source to the query [[moiseevigor](https://github.com/moiseevigor)] - [issue #163](https://github.com/j4mie/idiorm/issues/163)
* offsetExists() should return true for null values, resolves [#181](https://github.com/j4mie/idiorm/issues/181) [[cainmi](https://github.com/cainmi)] - [issue #214](https://github.com/j4mie/idiorm/pull/214)
* Custom cache callback functions [[peter-mw](https://github.com/peter-mw)] - [issue #216](https://github.com/j4mie/idiorm/pull/216)
* Restrict null primary keys on update/delete, resolves [#203](https://github.com/j4mie/idiorm/issues/203) [[cainmi](https://github.com/cainmi)] - [issue #205](https://github.com/j4mie/idiorm/issues/205)
* Ensure parameters treated by type correctly [[charsleysa](https://github.com/charsleysa)] & [[SneakyBobito](https://github.com/SneakyBobito)] - [issue #206](https://github.com/j4mie/idiorm/issues/206) & [issue #208](https://github.com/j4mie/idiorm/issues/208)
* Reduce the type casting on aggregate functions to allow characters [[herroffizier](https://github.com/herroffizier)] - [issue #150](https://github.com/j4mie/idiorm/issues/150)
* Prevent invalid method calls from triggering infinite recursion [[michaelward82](https://github.com/michaelward82)] - [issue #152](https://github.com/j4mie/idiorm/issues/152)
* Add time to query logging - adds query time parameter to external logger callback function [[AgelxNash](https://github.com/AgelxNash)] - [issue #180](https://github.com/j4mie/idiorm/issues/180)
* Changed database array access to ensure it's always properly setup [[falmp](https://github.com/falmp)] - [issue #159](https://github.com/j4mie/idiorm/issues/159)
* Allow unsetting the db (`ORM::set_db(null)`) to make the test work again [[borrel](https://github.com/borrel)] - [issue #160](https://github.com/j4mie/idiorm/issues/160)
* Correct [issue #176](https://github.com/j4mie/idiorm/issues/176): Ensure database setup before building select [[kendru](https://github.com/kendru)] - [issue #197](https://github.com/j4mie/idiorm/issues/197)
* Add HHVM to travis-ci build matrix [[ptarjan](https://github.com/ptarjan)] - [issue #168](https://github.com/j4mie/idiorm/issues/168)
* Improve where statement precendence documentation [[thomasahle](https://github.com/thomasahle)] - [issue #190](https://github.com/j4mie/idiorm/issues/190)
* Improve testing checks [[charsleysa](https://github.com/charsleysa)] - [issue #173](https://github.com/j4mie/idiorm/issues/173)
#### 1.4.1 - released 2013-12-12
**Patch update to remove a broken pull request** - may have consequences for users of 1.4.0 that exploited the "`find_many()` now returns an associative array with the databases primary ID as the array keys" change that was merged in 1.4.0.
* Back out pull request/issue [#133](https://github.com/j4mie/idiorm/pull/133) as it breaks backwards compatibility in previously unexpected ways (see [#162](https://github.com/j4mie/idiorm/pull/162), [#156](https://github.com/j4mie/idiorm/issues/156) and [#133](https://github.com/j4mie/idiorm/pull/133#issuecomment-29063108)) - sorry for merging this change into Idiorm - closes [issue 156](https://github.com/j4mie/idiorm/issues/156)
#### 1.4.0 - released 2013-09-05
* `find_many()` now returns an associative array with the databases primary ID as the array keys [[Surt](https://github.com/Surt)] - [issue #133](https://github.com/j4mie/idiorm/issues/133)
* Calls to `set()` and `set_expr()` return `$this` allowing them to be chained [[Surt](https://github.com/Surt)]
* Add PSR-1 compliant camelCase method calls to Idiorm (PHP 5.3+ required) [[crhayes](https://github.com/crhayes)] - [issue #108](https://github.com/j4mie/idiorm/issues/108)
* Add static method `get_config()` to access current configuration [[javierd](https://github.com/mikejestes)] - [issue #141](https://github.com/j4mie/idiorm/issues/141)
* Add logging callback functionality [[lalop](https://github.com/lalop)] - [issue #130](https://github.com/j4mie/idiorm/issues/130)
* Add support for MS SQL ``TOP`` limit style (automatically used for PDO drivers: sqlsrv, dblib and mssql) [[numkem](https://github.com/numkem)] - [issue #116](https://github.com/j4mie/idiorm/issues/116)
* Uses table aliases in `WHERE` clauses [[vicvicvic](https://github.com/vicvicvic)] - [issue #140](https://github.com/j4mie/idiorm/issues/140)
* Ignore result columns when calling an aggregate function [[tassoevan](https://github.com/tassoevan)] - [issue #120](https://github.com/j4mie/idiorm/issues/120)
* Improve documentation [[bruston](https://github.com/bruston)] - [issue #111](https://github.com/j4mie/idiorm/issues/111)
* Improve PHPDoc on `get_db()` [[mailopl](https://github.com/mailopl)] - [issue #106](https://github.com/j4mie/idiorm/issues/106)
* Improve documentation [[sjparsons](https://github.com/sjparsons)] - [issue #103](https://github.com/j4mie/idiorm/issues/103)
* Make tests/bootstrap.php HHVM compatible [[JoelMarcey](https://github.com/JoelMarcey)] - [issue #143](https://github.com/j4mie/idiorm/issues/143)
* Fix docblock [[ulrikjohansson](https://github.com/ulrikjohansson)] - [issue #147](https://github.com/j4mie/idiorm/issues/147)
* Fix incorrect variable name in querying documentation [[fridde](https://github.com/fridde)] - [issue #146](https://github.com/j4mie/idiorm/issues/146)
#### 1.3.0 - released 2013-01-31
* Documentation moved to [idiorm.rtfd.org](http://idiorm.rtfd.org) and now built using [Sphinx](http://sphinx-doc.org/)
* Add support for multiple database connections - closes [issue #15](https://github.com/j4mie/idiorm/issues/15) [[tag](https://github.com/tag)]
* Add in raw_execute - closes [issue #40](https://github.com/j4mie/idiorm/issues/40) [[tag](https://github.com/tag)]
* Add `get_last_statement()` - closes [issue #84](https://github.com/j4mie/idiorm/issues/84) [[tag](https://github.com/tag)]
* Add HAVING clause functionality - closes [issue #50](https://github.com/j4mie/idiorm/issues/50)
* Add `is_new` method - closes [issue #85](https://github.com/j4mie/idiorm/issues/85)
* Add `ArrayAccess` support to the model instances allowing property access via `$model['field']` as well as `$model->field` - [issue #51](https://github.com/j4mie/idiorm/issues/51)
* Add a result set object for collections of models that can support method chains to filter or apply actions to multiple results at once - issue [#51](https://github.com/j4mie/idiorm/issues/51) and [#22](https://github.com/j4mie/idiorm/issues/22)
* Add support for [Firebird](http://www.firebirdsql.org) with `ROWS` and `TO` result set limiting and identifier quoting [[mapner](https://github.com/mapner)] - [issue #98](https://github.com/j4mie/idiorm/issues/98)
* Fix last insert ID for PostgreSQL using RETURNING - closes issues [#62](https://github.com/j4mie/idiorm/issues/62) and [#89](https://github.com/j4mie/idiorm/issues/89) [[laacz](https://github.com/laacz)]
* Reset Idiorm after performing a query to allow for calling `count()` and then `find_many()` [[fayland](https://github.com/fayland)] - [issue #97](https://github.com/j4mie/idiorm/issues/97)
* Change Composer to use a classmap so that autoloading is better supported [[javierd](https://github.com/javiervd)] - [issue #96](https://github.com/j4mie/idiorm/issues/96)
* Add query logging to `delete_many` [[tag](https://github.com/tag)]
* Fix when using `set_expr` alone it doesn't trigger query creation - closes [issue #90](https://github.com/j4mie/idiorm/issues/90)
* Escape quote symbols in "_quote_identifier_part" - close [issue #74](https://github.com/j4mie/idiorm/issues/74)
* Fix issue with aggregate functions always returning `int` when is `float` sometimes required - closes [issue #92](https://github.com/j4mie/idiorm/issues/92)
* Move testing into PHPUnit to unify method testing and query generation testing
#### 1.2.3 - released 2012-11-28
* Fix [issue #78](https://github.com/j4mie/idiorm/issues/78) - remove use of PHP 5.3 static call
#### 1.2.2 - released 2012-11-15
* Fix bug where input parameters were sent as part-indexed, part associative
#### 1.2.1 - released 2012-11-15
* Fix minor bug caused by IdiormStringException not extending Exception
#### 1.2.0 - released 2012-11-14
* Setup composer for installation via packagist (j4mie/idiorm)
* Add `order_by_expr` method [[sandermarechal](http://github.com/sandermarechal)]
* Add support for raw queries without parameters argument [[sandermarechal](http://github.com/sandermarechal)]
* Add support to set multiple properties at once by passing an associative array to `set` method [[sandermarechal](http://github.com/sandermarechal)]
* Allow an associative array to be passed to `configure` method [[jordanlev](http://github.com/jordanlev)]
* Patch to allow empty Paris models to be saved ([[j4mie/paris](http://github.com/j4mie/paris)]) - [issue #58](https://github.com/j4mie/idiorm/issues/58)
* Add `select_many` and `select_many_expr` - closing issues [#49](https://github.com/j4mie/idiorm/issues/49) and [#69](https://github.com/j4mie/idiorm/issues/69)
* Add support for `MIN`, `AVG`, `MAX` and `SUM` - closes [issue #16](https://github.com/j4mie/idiorm/issues/16)
* Add `group_by_expr` - closes [issue #24](https://github.com/j4mie/idiorm/issues/24)
* Add `set_expr` to allow database expressions to be set as ORM properties - closes issues [#59](https://github.com/j4mie/idiorm/issues/59) and [#43](https://github.com/j4mie/idiorm/issues/43) [[brianherbert](https://github.com/brianherbert)]
* Prevent ambiguous column names when joining tables - [issue #66](https://github.com/j4mie/idiorm/issues/66) [[hellogerard](https://github.com/hellogerard)]
* Add `delete_many` method [[CBeerta](https://github.com/CBeerta)]
* Allow unsetting of ORM parameters [[CBeerta](https://github.com/CBeerta)]
* Add `find_array` to get the records as associative arrays [[Surt](https://github.com/Surt)] - closes [issue #17](https://github.com/j4mie/idiorm/issues/17)
* Fix bug in `_log_query` with `?` and `%` supplied in raw where statements etc. - closes [issue #57](https://github.com/j4mie/idiorm/issues/57) [[ridgerunner](https://github.com/ridgerunner)]
#### 1.1.1 - released 2011-01-30
* Fix bug in quoting column wildcard. j4mie/paris#12
* Small documentation improvements
#### 1.1.0 - released 2011-01-24
* Add `is_dirty` method
* Add basic query caching
* Add `distinct` method
* Add `group_by` method
#### 1.0.0 - released 2010-12-01
* Initial release

49
vendor/j4mie/idiorm/composer.json

@ -0,0 +1,49 @@
{
"name": "j4mie/idiorm",
"type": "library",
"description": "A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5",
"keywords": ["idiorm", "orm", "query builder"],
"homepage": "http://j4mie.github.com/idiormandparis",
"support": {
"issues": "https://github.com/j4mie/idiorm/issues",
"source": "https://github.com/j4mie/idiorm"
},
"authors": [
{
"name": "Jamie Matthews",
"email": "jamie.matthews@gmail.com",
"homepage": "http://j4mie.org",
"role": "Developer"
},
{
"name": "Simon Holywell",
"email": "treffynnon@php.net",
"homepage": "http://simonholywell.com",
"role": "Maintainer"
},
{
"name": "Durham Hale",
"email": "me@durhamhale.com",
"homepage": "http://durhamhale.com",
"role": "Maintainer"
}
],
"scripts": {
"test": "phpunit -c ./phpunit.xml"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"ext-pdo_sqlite": "*"
},
"license": [
"BSD-2-Clause",
"BSD-3-Clause",
"BSD-4-Clause"
],
"require": {
"php": ">=5.2.0"
},
"autoload": {
"classmap": ["idiorm.php"]
}
}

81
vendor/j4mie/idiorm/demo.php

@ -0,0 +1,81 @@
<?php
// ------------------- //
// --- Idiorm Demo --- //
// ------------------- //
// Note: This is just about the simplest database-driven webapp it's possible to create
// and is designed only for the purpose of demonstrating how Idiorm works.
// In case it's not obvious: this is not the correct way to build web applications!
// Require the idiorm file
require_once("idiorm.php");
// Connect to the demo database file
ORM::configure('sqlite:./demo.sqlite');
// This grabs the raw database connection from the ORM
// class and creates the table if it doesn't already exist.
// Wouldn't normally be needed if the table is already there.
$db = ORM::get_db();
$db->exec("
CREATE TABLE IF NOT EXISTS contact (
id INTEGER PRIMARY KEY,
name TEXT,
email TEXT
);"
);
// Handle POST submission
if (!empty($_POST)) {
// Create a new contact object
$contact = ORM::for_table('contact')->create();
// SHOULD BE MORE ERROR CHECKING HERE!
// Set the properties of the object
$contact->name = $_POST['name'];
$contact->email = $_POST['email'];
// Save the object to the database
$contact->save();
// Redirect to self.
header('Location: ' . basename(__FILE__));
exit;
}
// Get a list of all contacts from the database
$count = ORM::for_table('contact')->count();
$contact_list = ORM::for_table('contact')->find_many();
?>
<html>
<head>
<title>Idiorm Demo</title>
</head>
<body>
<h1>Idiorm Demo</h1>
<h2>Contact List (<?php echo $count; ?> contacts)</h2>
<ul>
<?php foreach ($contact_list as $contact): ?>
<li>
<strong><?php echo $contact->name ?></strong>
<a href="mailto:<?php echo $contact->email; ?>"><?php echo $contact->email; ?></a>
</li>
<?php endforeach; ?>
</ul>
<form method="post" action="">
<h2>Add Contact</h2>
<p><label for="name">Name:</label> <input type="text" name="name" /></p>
<p><label for="email">Email:</label> <input type="email" name="email" /></p>
<input type="submit" value="Create" />
</form>
</body>
</html>

153
vendor/j4mie/idiorm/docs/Makefile

@ -0,0 +1,153 @@
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Idiorm.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Idiorm.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/Idiorm"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Idiorm"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

242
vendor/j4mie/idiorm/docs/conf.py

@ -0,0 +1,242 @@
# -*- coding: utf-8 -*-
#
# Idiorm documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 28 15:39:16 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Idiorm'
copyright = u'2014, Jamie Matthews and Simon Holywell'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = ''
# The full version, including alpha/beta/rc tags.
release = ''
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'Idiormdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Idiorm.tex', u'Idiorm Documentation',
u'Jamie Matthews and Simon Holywell', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'idiorm', u'Idiorm Documentation',
[u'Jamie Matthews and Simon Holywell'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Idiorm', u'Idiorm Documentation',
u'Jamie Matthews and Simon Holywell', 'Idiorm', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

378
vendor/j4mie/idiorm/docs/configuration.rst

@ -0,0 +1,378 @@
Configuration
=============
The first thing you need to know about Idiorm is that *you don’t need to
define any model classes to use it*. With almost every other ORM, the
first thing to do is set up your models and map them to database tables
(through configuration variables, XML files or similar). With Idiorm,
you can start using the ORM straight away.
Setup
~~~~~
First, ``require`` the Idiorm source file:
.. code-block:: php
<?php
require_once 'idiorm.php';
Then, pass a *Data Source Name* connection string to the ``configure``
method of the ORM class. This is used by PDO to connect to your
database. For more information, see the `PDO documentation`_.
.. code-block:: php
<?php
ORM::configure('sqlite:./example.db');
You may also need to pass a username and password to your database
driver, using the ``username`` and ``password`` configuration options.
For example, if you are using MySQL:
.. code-block:: php
<?php
ORM::configure('mysql:host=localhost;dbname=my_database');
ORM::configure('username', 'database_user');
ORM::configure('password', 'top_secret');
Also see “Configuration” section below.
Configuration
~~~~~~~~~~~~~
Other than setting the DSN string for the database connection (see
above), the ``configure`` method can be used to set some other simple
options on the ORM class. Modifying settings involves passing a
key/value pair to the ``configure`` method, representing the setting you
wish to modify and the value you wish to set it to.
.. code-block:: php
<?php
ORM::configure('setting_name', 'value_for_setting');
A shortcut is provided to allow passing multiple key/value pairs at
once.
.. code-block:: php
<?php
ORM::configure(array(
'setting_name_1' => 'value_for_setting_1',
'setting_name_2' => 'value_for_setting_2',
'etc' => 'etc'
));
Use the ``get_config`` method to read current settings.
.. code-block:: php
<?php
$isLoggingEnabled = ORM::get_config('logging');
ORM::configure('logging', false);
// some crazy loop we don't want to log
ORM::configure('logging', $isLoggingEnabled);
Database authentication details
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Settings: ``username`` and ``password``
Some database adapters (such as MySQL) require a username and password
to be supplied separately to the DSN string. These settings allow you to
provide these values. A typical MySQL connection setup might look like
this:
.. code-block:: php
<?php
ORM::configure('mysql:host=localhost;dbname=my_database');
ORM::configure('username', 'database_user');
ORM::configure('password', 'top_secret');
Or you can combine the connection setup into a single line using the
configuration array shortcut:
.. code-block:: php
<?php
ORM::configure(array(
'connection_string' => 'mysql:host=localhost;dbname=my_database',
'username' => 'database_user',
'password' => 'top_secret'
));
Result sets
^^^^^^^^^^^
Setting: ``return_result_sets``
Collections of results can be returned as an array (default) or as a result set.
See the `find_result_set()` documentation for more information.
.. code-block:: php
<?php
ORM::configure('return_result_sets', true); // returns result sets
.. note::
It is recommended that you setup your projects to use result sets as they
are more flexible.
PDO Driver Options
^^^^^^^^^^^^^^^^^^
Setting: ``driver_options``
Some database adapters require (or allow) an array of driver-specific
configuration options. This setting allows you to pass these options
through to the PDO constructor. For more information, see `the PDO
documentation`_. For example, to force the MySQL driver to use UTF-8 for
the connection:
.. code-block:: php
<?php
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
PDO Error Mode
^^^^^^^^^^^^^^
Setting: ``error_mode``
This can be used to set the ``PDO::ATTR_ERRMODE`` setting on the
database connection class used by Idiorm. It should be passed one of the
class constants defined by PDO. For example:
.. code-block:: php
<?php
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
The default setting is ``PDO::ERRMODE_EXCEPTION``. For full details of
the error modes available, see `the PDO set attribute documentation`_.
PDO object access
^^^^^^^^^^^^^^^^^
Should it ever be necessary, the PDO object used by Idiorm may be
accessed directly through ``ORM::get_db()``, or set directly via
``ORM::set_db()``. This should be an unusual occurance.
After a statement has been executed by any means, such as ``::save()``
or ``::raw_execute()``, the ``PDOStatement`` instance used may be
accessed via ``ORM::get_last_statement()``. This may be useful in order
to access ``PDOStatement::errorCode()``, if PDO exceptions are turned
off, or to access the ``PDOStatement::rowCount()`` method, which returns
differing results based on the underlying database. For more
information, see the `PDOStatement documentation`_.
Identifier quote character
^^^^^^^^^^^^^^^^^^^^^^^^^^
Setting: ``identifier_quote_character``
Set the character used to quote identifiers (eg table name, column
name). If this is not set, it will be autodetected based on the database
driver being used by PDO.
ID Column
^^^^^^^^^
By default, the ORM assumes that all your tables have a primary key
column called ``id``. There are two ways to override this: for all
tables in the database, or on a per-table basis.
Setting: ``id_column``
This setting is used to configure the name of the primary key column for
all tables. If your ID column is called ``primary_key``, use:
.. code-block:: php
<?php
ORM::configure('id_column', 'primary_key');
You can specify a compound primary key using an array:
.. code-block:: php
<?php
ORM::configure('id_column', array('pk_1', 'pk_2'));
Note: If you use a auto-increment column in the compound primary key then it
should be the first one defined into the array.
Setting: ``id_column_overrides``
This setting is used to specify the primary key column name for each
table separately. It takes an associative array mapping table names to
column names. If, for example, your ID column names include the name of
the table, you can use the following configuration:
.. code-block:: php
<?php
ORM::configure('id_column_overrides', array(
'person' => 'person_id',
'role' => 'role_id',
));
As with ``id_column`` setting, you can specify a compound primary key
using an array.
Limit clause style
^^^^^^^^^^^^^^^^^^
Setting: ``limit_clause_style``
You can specify the limit clause style in the configuration. This is to facilitate
a MS SQL style limit clause that uses the ``TOP`` syntax.
Acceptable values are ``ORM::LIMIT_STYLE_TOP_N`` and ``ORM::LIMIT_STYLE_LIMIT``.
.. note::
If the PDO driver you are using is one of sqlsrv, dblib or mssql then Idiorm
will automatically select the ``ORM::LIMIT_STYLE_TOP_N`` for you unless you
override the setting.
Query logging
^^^^^^^^^^^^^