mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 00:04:31 +02:00
[Ivan Diaz] - Updated vendor
This commit is contained in:
parent
4b66684c0e
commit
b3df77988b
63
server/composer.lock
generated
63
server/composer.lock
generated
@ -8,16 +8,16 @@
|
||||
"packages": [
|
||||
{
|
||||
"name": "gabordemooij/redbean",
|
||||
"version": "v4.2.1",
|
||||
"version": "v4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/gabordemooij/redbean.git",
|
||||
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa"
|
||||
"reference": "f375a1678d137ca1ff806813fac306723f97ec6b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/13610146620d7c0a66215dcaf0c8796bb03a04aa",
|
||||
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa",
|
||||
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/f375a1678d137ca1ff806813fac306723f97ec6b",
|
||||
"reference": "f375a1678d137ca1ff806813fac306723f97ec6b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -45,7 +45,7 @@
|
||||
"keywords": [
|
||||
"orm"
|
||||
],
|
||||
"time": "2015-05-09 12:22:47"
|
||||
"time": "2015-09-11 18:55:25"
|
||||
},
|
||||
{
|
||||
"name": "slim/slim",
|
||||
@ -151,16 +151,16 @@
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "d8093b631a31628342d0703764935f8bac2c56b1"
|
||||
"reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/d8093b631a31628342d0703764935f8bac2c56b1",
|
||||
"reference": "d8093b631a31628342d0703764935f8bac2c56b1",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e3abefcd7f106677fd352cd7c187d6c969aa9ddc",
|
||||
"reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -189,7 +189,7 @@
|
||||
"object",
|
||||
"object graph"
|
||||
],
|
||||
"time": "2015-10-05 15:07:09"
|
||||
"time": "2015-11-07 22:20:37"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
@ -302,16 +302,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "c84f05be256cd7c9d2340b26f7995b4afbf8787b"
|
||||
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c84f05be256cd7c9d2340b26f7995b4afbf8787b",
|
||||
"reference": "c84f05be256cd7c9d2340b26f7995b4afbf8787b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
|
||||
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -360,7 +360,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-10-06 15:51:05"
|
||||
"time": "2015-11-12 21:08:20"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
@ -542,16 +542,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "5.0.6",
|
||||
"version": "5.0.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "d2656ec378c88e036b3fc14fb4262ee1a25498c9"
|
||||
"reference": "ed084be6b5b912f11c3559e17110f8d8a1e3a8a1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d2656ec378c88e036b3fc14fb4262ee1a25498c9",
|
||||
"reference": "d2656ec378c88e036b3fc14fb4262ee1a25498c9",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed084be6b5b912f11c3559e17110f8d8a1e3a8a1",
|
||||
"reference": "ed084be6b5b912f11c3559e17110f8d8a1e3a8a1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -612,20 +612,20 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-10-14 13:51:20"
|
||||
"time": "2015-11-10 21:47:43"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "3.0.3",
|
||||
"version": "3.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "382c729a52b7ef682e94c73fd6868f5ee8116ba7"
|
||||
"reference": "b28b029356e65091dfbf8c2bc4ef106ffece509e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/382c729a52b7ef682e94c73fd6868f5ee8116ba7",
|
||||
"reference": "382c729a52b7ef682e94c73fd6868f5ee8116ba7",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b28b029356e65091dfbf8c2bc4ef106ffece509e",
|
||||
"reference": "b28b029356e65091dfbf8c2bc4ef106ffece509e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -668,7 +668,7 @@
|
||||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-10-18 07:55:54"
|
||||
"time": "2015-11-09 15:37:17"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
@ -1085,24 +1085,21 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.7.5",
|
||||
"version": "v2.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770"
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -1130,7 +1127,7 @@
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2015-09-14 14:14:09"
|
||||
"time": "2015-10-11 09:39:48"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
2
server/vendor/autoload.php
vendored
2
server/vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062::getLoader();
|
||||
return ComposerAutoloaderInitc1131bbfb8e9acff5fc8b79d0d7d1f64::getLoader();
|
||||
|
8
server/vendor/composer/autoload_real.php
vendored
8
server/vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062
|
||||
class ComposerAutoloaderInitc1131bbfb8e9acff5fc8b79d0d7d1f64
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -19,9 +19,9 @@ class ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc1131bbfb8e9acff5fc8b79d0d7d1f64', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc1131bbfb8e9acff5fc8b79d0d7d1f64', 'loadClassLoader'));
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@ -44,7 +44,7 @@ class ComposerAutoloaderInita2f433ace6603da0dacbae24a9d70062
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequirea2f433ace6603da0dacbae24a9d70062($file)
|
||||
function composerRequirec1131bbfb8e9acff5fc8b79d0d7d1f64($file)
|
||||
{
|
||||
require $file;
|
||||
}
|
||||
|
153
server/vendor/composer/installed.json
vendored
153
server/vendor/composer/installed.json
vendored
@ -48,18 +48,61 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.4.0",
|
||||
"version_normalized": "1.4.0.0",
|
||||
"name": "gabordemooij/redbean",
|
||||
"version": "v4.3",
|
||||
"version_normalized": "4.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "d8093b631a31628342d0703764935f8bac2c56b1"
|
||||
"url": "https://github.com/gabordemooij/redbean.git",
|
||||
"reference": "f375a1678d137ca1ff806813fac306723f97ec6b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/d8093b631a31628342d0703764935f8bac2c56b1",
|
||||
"reference": "d8093b631a31628342d0703764935f8bac2c56b1",
|
||||
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/f375a1678d137ca1ff806813fac306723f97ec6b",
|
||||
"reference": "f375a1678d137ca1ff806813fac306723f97ec6b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.4"
|
||||
},
|
||||
"time": "2015-09-11 18:55:25",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RedBeanPHP\\": "RedBeanPHP"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"New BSD and GPLv2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gabor de Mooij",
|
||||
"email": "gabor@redbeanphp.com",
|
||||
"homepage": "http://redbeanphp.com"
|
||||
}
|
||||
],
|
||||
"description": "RedBeanPHP ORM",
|
||||
"homepage": "http://redbeanphp.com/",
|
||||
"keywords": [
|
||||
"orm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.5.0",
|
||||
"version_normalized": "1.5.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e3abefcd7f106677fd352cd7c187d6c969aa9ddc",
|
||||
"reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -69,7 +112,7 @@
|
||||
"doctrine/collections": "1.*",
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"time": "2015-10-05 15:07:09",
|
||||
"time": "2015-11-07 22:20:37",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -522,26 +565,23 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.7.5",
|
||||
"version_normalized": "2.7.5.0",
|
||||
"version": "v2.7.6",
|
||||
"version_normalized": "2.7.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770"
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7"
|
||||
},
|
||||
"time": "2015-09-14 14:14:09",
|
||||
"time": "2015-10-11 09:39:48",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -785,17 +825,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "3.0.3",
|
||||
"version_normalized": "3.0.3.0",
|
||||
"version": "3.0.4",
|
||||
"version_normalized": "3.0.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "382c729a52b7ef682e94c73fd6868f5ee8116ba7"
|
||||
"reference": "b28b029356e65091dfbf8c2bc4ef106ffece509e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/382c729a52b7ef682e94c73fd6868f5ee8116ba7",
|
||||
"reference": "382c729a52b7ef682e94c73fd6868f5ee8116ba7",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b28b029356e65091dfbf8c2bc4ef106ffece509e",
|
||||
"reference": "b28b029356e65091dfbf8c2bc4ef106ffece509e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -810,7 +850,7 @@
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"time": "2015-10-18 07:55:54",
|
||||
"time": "2015-11-09 15:37:17",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -986,17 +1026,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "3.0.1",
|
||||
"version_normalized": "3.0.1.0",
|
||||
"version": "3.0.2",
|
||||
"version_normalized": "3.0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "c84f05be256cd7c9d2340b26f7995b4afbf8787b"
|
||||
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c84f05be256cd7c9d2340b26f7995b4afbf8787b",
|
||||
"reference": "c84f05be256cd7c9d2340b26f7995b4afbf8787b",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
|
||||
"reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1016,7 +1056,7 @@
|
||||
"ext-xdebug": ">=2.2.1",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"time": "2015-10-06 15:51:05",
|
||||
"time": "2015-11-12 21:08:20",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -1050,17 +1090,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "5.0.6",
|
||||
"version_normalized": "5.0.6.0",
|
||||
"version": "5.0.9",
|
||||
"version_normalized": "5.0.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "d2656ec378c88e036b3fc14fb4262ee1a25498c9"
|
||||
"reference": "ed084be6b5b912f11c3559e17110f8d8a1e3a8a1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d2656ec378c88e036b3fc14fb4262ee1a25498c9",
|
||||
"reference": "d2656ec378c88e036b3fc14fb4262ee1a25498c9",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed084be6b5b912f11c3559e17110f8d8a1e3a8a1",
|
||||
"reference": "ed084be6b5b912f11c3559e17110f8d8a1e3a8a1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1089,7 +1129,7 @@
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "~1.1"
|
||||
},
|
||||
"time": "2015-10-14 13:51:20",
|
||||
"time": "2015-11-10 21:47:43",
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
@ -1123,48 +1163,5 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gabordemooij/redbean",
|
||||
"version": "v4.2.1",
|
||||
"version_normalized": "4.2.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/gabordemooij/redbean.git",
|
||||
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/13610146620d7c0a66215dcaf0c8796bb03a04aa",
|
||||
"reference": "13610146620d7c0a66215dcaf0c8796bb03a04aa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.4"
|
||||
},
|
||||
"time": "2015-05-09 12:22:47",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RedBeanPHP\\": "RedBeanPHP"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"New BSD and GPLv2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gabor de Mooij",
|
||||
"email": "gabor@redbeanphp.com",
|
||||
"homepage": "http://redbeanphp.com"
|
||||
}
|
||||
],
|
||||
"description": "RedBeanPHP ORM",
|
||||
"homepage": "http://redbeanphp.com/",
|
||||
"keywords": [
|
||||
"orm"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -9,6 +9,22 @@ RedBeanPHP is an easy to use ORM tool for PHP.
|
||||
* No configuration, just fire and forget
|
||||
* No complicated package tools, no autoloaders, just ONE file
|
||||
|
||||
Installation via Composer
|
||||
-------------------------
|
||||
|
||||
Just open your composer.json file and add the package name ```(e.g. "gabordemooij/redbean": "dev-master")``` in your require list.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"gabordemooij/redbean": "dev-master"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you not using composer then [try it.](http://redbeanphp.com/install)
|
||||
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -6,7 +6,7 @@ namespace RedBeanPHP;
|
||||
* Adapter Interface.
|
||||
* Describes the API for a RedBeanPHP Database Adapter.
|
||||
* This interface defines the API contract for
|
||||
* a RedBeanPHP Database Adapter.
|
||||
* a RedBeanPHP Database Adapter.
|
||||
*
|
||||
* @file RedBeanPHP/Adapter.php
|
||||
* @author Gabor de Mooij and the RedBeanPHP Community
|
||||
@ -20,7 +20,7 @@ namespace RedBeanPHP;
|
||||
interface Adapter
|
||||
{
|
||||
/**
|
||||
* Returns the latest SQL statement
|
||||
* Returns the latest SQL statement.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -32,9 +32,11 @@ interface Adapter
|
||||
* observers to notify about the SQL execution; this to prevent
|
||||
* infinite recursion when using observers.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
* @param boolean $noevent no event firing
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function exec( $sql, $bindings = array(), $noevent = FALSE );
|
||||
|
||||
@ -44,8 +46,8 @@ interface Adapter
|
||||
* The values array can be used to bind values to the place holders in the
|
||||
* SQL query.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -57,8 +59,8 @@ interface Adapter
|
||||
* The values array can be used to bind values to the place holders in the
|
||||
* SQL query.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values to bind
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -70,8 +72,8 @@ interface Adapter
|
||||
* The values array can be used to bind values to the place holders in the
|
||||
* SQL query.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values to bind
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -83,8 +85,8 @@ interface Adapter
|
||||
* The values array can be used to bind values to the place holders in the
|
||||
* SQL query.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values to bind
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -98,18 +100,18 @@ interface Adapter
|
||||
* The values array can be used to bind values to the place holders in the
|
||||
* SQL query.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings values to bind
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAssoc( $sql, $bindings = array() );
|
||||
|
||||
|
||||
/**
|
||||
* Executes the SQL query specified in $sql and indexes
|
||||
* the row by the first column.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
*
|
||||
* @param string $sql Sstring containing SQL code for databaseQL
|
||||
* @param array $bindings values to bind
|
||||
*
|
||||
* @return array
|
||||
@ -134,8 +136,8 @@ interface Adapter
|
||||
/**
|
||||
* Returns a database agnostic Cursor object.
|
||||
*
|
||||
* @param string $sql SQL
|
||||
* @param array $bindings bindings
|
||||
* @param string $sql string containing SQL code for database
|
||||
* @param array $bindings array of values to bind to parameters in query string
|
||||
*
|
||||
* @return Cursor
|
||||
*/
|
||||
@ -147,7 +149,7 @@ interface Adapter
|
||||
* adapter. RedBean will only access the adapter and never to talk
|
||||
* directly to the driver though.
|
||||
*
|
||||
* @return object
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDatabase();
|
||||
|
||||
|
@ -140,7 +140,7 @@ class DBAdapter extends Observable implements Adapter
|
||||
|
||||
return $assoc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Adapter::getAssocRow
|
||||
*/
|
||||
|
@ -2,15 +2,10 @@
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\Observable as Observable;
|
||||
use RedBeanPHP\OODB as OODB;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
use RedBeanPHP\ToolBox as ToolBox;
|
||||
|
||||
/**
|
||||
* Association Manager.
|
||||
@ -43,15 +38,13 @@ class AssociationManager extends Observable
|
||||
protected $writer;
|
||||
|
||||
/**
|
||||
* Handles\Exceptions. Suppresses exceptions caused by missing structures.
|
||||
* Handles exceptions. Suppresses exceptions caused by missing structures.
|
||||
*
|
||||
* @param\Exception $exception
|
||||
* @param Exception $exception exception to handle
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws\Exception
|
||||
*/
|
||||
private function handleException(\Exception $exception )
|
||||
private function handleException( \Exception $exception )
|
||||
{
|
||||
if ( $this->oodb->isFrozen() || !$this->writer->sqlStateIn( $exception->getSQLState(),
|
||||
array(
|
||||
@ -74,9 +67,6 @@ class AssociationManager extends Observable
|
||||
* @param array $bindings bindings for query
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Security
|
||||
* @throws SQL
|
||||
*/
|
||||
private function relatedRows( $bean, $type, $sql = '', $bindings = array() )
|
||||
{
|
||||
@ -100,8 +90,6 @@ class AssociationManager extends Observable
|
||||
* @param OODBBean $bean2 second bean
|
||||
* @param OODBBean $bean base bean (association record)
|
||||
*
|
||||
* @throws\Exception|SQL
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function associateBeans( OODBBean $bean1, OODBBean $bean2, OODBBean $bean )
|
||||
@ -174,7 +162,7 @@ class AssociationManager extends Observable
|
||||
* This method will associate two beans and store the connection between the
|
||||
* two in a link table. Instead of two single beans this method also accepts
|
||||
* two sets of beans. Returns the ID or the IDs of the linking beans.
|
||||
*
|
||||
*
|
||||
* @param OODBBean|array $beans1 one or more beans to form the association
|
||||
* @param OODBBean|array $beans2 one or more beans to form the association
|
||||
*
|
||||
@ -209,13 +197,11 @@ class AssociationManager extends Observable
|
||||
* SQL snippet for additional filtering.
|
||||
*
|
||||
* @param OODBBean|array $bean a bean object or an array of beans
|
||||
* @param string $type type of bean you're interested in
|
||||
* @param string $sql SQL snippet (optional)
|
||||
* @param array $bindings bindings for your SQL string
|
||||
* @param string $type type of bean you're interested in
|
||||
* @param string $sql SQL snippet (optional)
|
||||
* @param array $bindings bindings for your SQL string
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function relatedCount( $bean, $type, $sql = NULL, $bindings = array() )
|
||||
{
|
||||
@ -249,9 +235,9 @@ class AssociationManager extends Observable
|
||||
* set to boolean TRUE this method will remove the beans without their consent,
|
||||
* bypassing FUSE. This can be used to improve performance.
|
||||
*
|
||||
* @param OODBBean $bean1 first bean
|
||||
* @param OODBBean $bean2 second bean
|
||||
* @param boolean $fast If TRUE, removes the entries by query without FUSE
|
||||
* @param OODBBean $bean1 first bean in target association
|
||||
* @param OODBBean $bean2 second bean in target association
|
||||
* @param boolean $fast if TRUE, removes the entries by query without FUSE
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -299,7 +285,7 @@ class AssociationManager extends Observable
|
||||
* with unassociate() instead. (that might be slower though)
|
||||
*
|
||||
* @param OODBBean $bean reference bean
|
||||
* @param string $type type of beans that need to be unassociated
|
||||
* @param string $type type of beans that need to be unassociated
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -328,11 +314,10 @@ class AssociationManager extends Observable
|
||||
* Since 3.2, you can now also pass an array of beans instead just one
|
||||
* bean as the first parameter.
|
||||
*
|
||||
* @param OODBBean|array $bean the bean you have
|
||||
* @param string $type the type of beans you want
|
||||
* @param string $sql SQL snippet for extra filtering
|
||||
* @param array $bindings values to be inserted in SQL slots
|
||||
* @param boolean $glue whether the SQL should be prefixed with WHERE
|
||||
* @param OODBBean|array $bean the bean you have
|
||||
* @param string $type the type of beans you want
|
||||
* @param string $sql SQL snippet for extra filtering
|
||||
* @param array $bindings values to be inserted in SQL slots
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -44,10 +44,10 @@ class BeanCollection
|
||||
* @var string
|
||||
*/
|
||||
protected $type = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor, creates a new instance of the BeanCollection.
|
||||
*
|
||||
*
|
||||
* @param string $type type of beans in this collection
|
||||
* @param Repository $repository repository to use to generate bean objects
|
||||
* @param Cursor $cursor cursor object to use
|
||||
|
@ -7,7 +7,7 @@ use RedBeanPHP\OODBBean as OODBBean;
|
||||
|
||||
/**
|
||||
* Bean Helper Interface.
|
||||
*
|
||||
*
|
||||
* Interface for Bean Helper.
|
||||
* A little bolt that glues the whole machinery together.
|
||||
*
|
||||
@ -28,7 +28,7 @@ interface BeanHelper
|
||||
* as such the bean is a proxy for OODB. This allows beans to implement
|
||||
* their magic getters and setters and return lists.
|
||||
*
|
||||
* @return ToolBox $toolbox toolbox
|
||||
* @return ToolBox
|
||||
*/
|
||||
public function getToolbox();
|
||||
|
||||
@ -46,9 +46,9 @@ interface BeanHelper
|
||||
* Given a certain bean this method will
|
||||
* return the corresponding model.
|
||||
*
|
||||
* @param OODBBean $bean
|
||||
* @param OODBBean $bean bean to obtain the corresponding model of
|
||||
*
|
||||
* @return object
|
||||
* @return SimpleModel|CustomModel
|
||||
*/
|
||||
public function getModelForBean( OODBBean $bean );
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ class SimpleFacadeBeanHelper implements BeanHelper
|
||||
* Sets the factory function to create the model when using FUSE
|
||||
* to connect a bean to a model.
|
||||
*
|
||||
* @param closure $factory
|
||||
* @param closure $factory factory function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setFactoryFunction( $factory )
|
||||
public static function setFactoryFunction( $factory )
|
||||
{
|
||||
self::$factory = $factory;
|
||||
}
|
||||
@ -86,7 +86,7 @@ class SimpleFacadeBeanHelper implements BeanHelper
|
||||
if ( !class_exists( $modelName ) ) {
|
||||
//second try
|
||||
$modelName = $prefix . ucfirst( $model );
|
||||
|
||||
|
||||
if ( !class_exists( $modelName ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -21,7 +21,7 @@ interface Driver
|
||||
/**
|
||||
* Runs a query and fetches results as a multi dimensional array.
|
||||
*
|
||||
* @param string $sql SQL to be executed
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return array
|
||||
@ -31,7 +31,7 @@ interface Driver
|
||||
/**
|
||||
* Runs a query and fetches results as a column.
|
||||
*
|
||||
* @param string $sql SQL Code to execute
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return array
|
||||
@ -41,31 +41,31 @@ interface Driver
|
||||
/**
|
||||
* Runs a query and returns results as a single cell.
|
||||
*
|
||||
* @param string $sql SQL to execute
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetOne( $sql, $bindings = array() );
|
||||
|
||||
|
||||
/**
|
||||
* Runs a query and returns results as an associative array
|
||||
* indexed by the first column.
|
||||
*
|
||||
* @param string $sql SQL to execute
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetAssocRow( $sql, $bindings = array() );
|
||||
|
||||
|
||||
/**
|
||||
* Runs a query and returns a flat array containing the values of
|
||||
* one row.
|
||||
*
|
||||
* @param string $sql SQL to execute
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetRow( $sql, $bindings = array() );
|
||||
@ -80,7 +80,7 @@ interface Driver
|
||||
* array(":key"=>123) will bind the integer 123 to the key :key in the
|
||||
* SQL. This method has no return value.
|
||||
*
|
||||
* @param string $sql SQL Code to execute
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return array Affected Rows
|
||||
@ -106,8 +106,8 @@ interface Driver
|
||||
/**
|
||||
* Returns a cursor-like object from the database.
|
||||
*
|
||||
* @param string $sql SQL code to execute
|
||||
* @param array $bindings Bindings
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings list of values to bind to SQL snippet
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -120,11 +120,12 @@ interface Driver
|
||||
* passes on to the screen for inspection.
|
||||
* This method has no return value.
|
||||
*
|
||||
* @param boolean $trueFalse turn on/off
|
||||
* @param boolean $tf TRUE = debug mode ON
|
||||
* @param Logger $customLogger
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDebugMode( $tf );
|
||||
public function setDebugMode( $tf, $customLogger );
|
||||
|
||||
/**
|
||||
* Starts a transaction.
|
||||
|
@ -130,9 +130,9 @@ class RPDO implements Driver
|
||||
*
|
||||
* @param string $sql the SQL string to be send to database server
|
||||
* @param array $bindings the values that need to get bound to the query slots
|
||||
* @param array $options
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @return mixed
|
||||
* @throws SQL
|
||||
*/
|
||||
protected function runQuery( $sql, $bindings, $options = array() )
|
||||
@ -168,7 +168,7 @@ class RPDO implements Driver
|
||||
} else {
|
||||
$this->resultArray = array();
|
||||
}
|
||||
} catch (\PDOException $e ) {
|
||||
} catch ( \PDOException $e ) {
|
||||
//Unfortunately the code field is supposed to be int by default (php)
|
||||
//So we need a property to convey the SQL State code.
|
||||
$err = $e->getMessage();
|
||||
@ -184,11 +184,13 @@ class RPDO implements Driver
|
||||
* MySQL < 5.5 does not support proper 4 byte unicode but they
|
||||
* seem to have added it with version 5.5 under a different label: utf8mb4.
|
||||
* We try to select the best possible charset based on your version data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setEncoding()
|
||||
{
|
||||
$driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME );
|
||||
$version = floatval( $this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION ) );
|
||||
$driver = $this->pdo->getAttribute( \PDO::ATTR_DRIVER_NAME );
|
||||
$version = floatval( $this->pdo->getAttribute( \PDO::ATTR_SERVER_VERSION ) );
|
||||
if ($driver === 'mysql') {
|
||||
$encoding = ($version >= 5.5) ? 'utf8mb4' : 'utf8';
|
||||
$this->pdo->setAttribute(\PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES '.$encoding ); //on every re-connect
|
||||
@ -205,10 +207,11 @@ class RPDO implements Driver
|
||||
* $driver = new RPDO($dsn, $user, $password);
|
||||
* $driver = new RPDO($existingConnection);
|
||||
*
|
||||
* @param string|object $dsn database connection string
|
||||
* @param string $user optional, usename to sign in
|
||||
* @param string $pass optional, password for connection login
|
||||
* @param string|object $dsn database connection string
|
||||
* @param string $user optional, usename to sign in
|
||||
* @param string $pass optional, password for connection login
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $dsn, $user = NULL, $pass = NULL )
|
||||
{
|
||||
@ -216,8 +219,8 @@ class RPDO implements Driver
|
||||
$this->pdo = $dsn;
|
||||
$this->isConnected = TRUE;
|
||||
$this->setEncoding();
|
||||
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION );
|
||||
$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE,\PDO::FETCH_ASSOC );
|
||||
$this->pdo->setAttribute( \PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION );
|
||||
$this->pdo->setAttribute( \PDO::ATTR_DEFAULT_FETCH_MODE,\PDO::FETCH_ASSOC );
|
||||
// make sure that the dsn at least contains the type
|
||||
$this->dsn = $this->getDatabaseType();
|
||||
} else {
|
||||
@ -286,8 +289,6 @@ class RPDO implements Driver
|
||||
* UTF8 for the database and PDO-ERRMODE-EXCEPTION as well as
|
||||
* PDO-FETCH-ASSOC.
|
||||
*
|
||||
* @throws\PDOException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
@ -531,7 +532,7 @@ class RPDO implements Driver
|
||||
/**
|
||||
* Returns the version number of the database.
|
||||
*
|
||||
* @return mixed $version version number of the database
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDatabaseVersion()
|
||||
{
|
||||
@ -551,7 +552,7 @@ class RPDO implements Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes database connection by destructing\PDO.
|
||||
* Closes database connection by destructing PDO.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -562,7 +563,7 @@ class RPDO implements Driver
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the current\PDO instance is connected.
|
||||
* Returns TRUE if the current PDO instance is connected.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -278,11 +278,15 @@ class DuplicationManager
|
||||
*
|
||||
* This method allows two array formats:
|
||||
*
|
||||
* <code>
|
||||
* array( TABLE1, TABLE2 ... )
|
||||
* </code>
|
||||
*
|
||||
* or
|
||||
*
|
||||
* <code>
|
||||
* array( TABLE1 => array( COLUMN1, COLUMN2 ... ) ... )
|
||||
* </code>
|
||||
*
|
||||
* @param array $tables a table cache array
|
||||
*
|
||||
@ -335,6 +339,8 @@ class DuplicationManager
|
||||
* the default behavior.
|
||||
*
|
||||
* @param array $filters list of tables to be filtered
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFilters( $filters )
|
||||
{
|
||||
|
@ -2,35 +2,29 @@
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\ToolBox as ToolBox;
|
||||
use RedBeanPHP\OODB as OODB;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\AssociationManager as AssociationManager;
|
||||
use RedBeanPHP\TagManager as TagManager;
|
||||
use RedBeanPHP\DuplicationManager as DuplicationManager;
|
||||
use RedBeanPHP\LabelMaker as LabelMaker;
|
||||
use RedBeanPHP\Finder as Finder;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\Logger as Logger;
|
||||
use RedBeanPHP\Logger\RDefault as RDefault;
|
||||
use RedBeanPHP\Logger\RDefault\Debug as Debug;
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\SimpleModel as SimpleModel;
|
||||
use RedBeanPHP\SimpleModelHelper as SimpleModelHelper;
|
||||
use RedBeanPHP\Adapter as Adapter;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper as SimpleFacadeBeanHelper;
|
||||
use RedBeanPHP\Driver\RPDO as RPDO;
|
||||
use RedBeanPHP\Util\MultiLoader as MultiLoader;
|
||||
use RedBeanPHP\Util\Transaction as Transaction;
|
||||
use RedBeanPHP\Util\Dump as Dump;
|
||||
use RedBeanPHP\Util\DispenseHelper as DispenseHelper;
|
||||
use RedBeanPHP\Util\ArrayTool as ArrayTool;
|
||||
|
||||
/**
|
||||
* RedBean Facade
|
||||
*
|
||||
* Version Information
|
||||
* RedBean Version @version 4.2
|
||||
*
|
||||
* RedBean Version @version 4.3
|
||||
*
|
||||
* This class hides the object landscape of
|
||||
* RedBeanPHP behind a single letter class providing
|
||||
* almost all functionality with simple static calls.
|
||||
@ -49,7 +43,7 @@ class Facade
|
||||
/**
|
||||
* RedBeanPHP version constant.
|
||||
*/
|
||||
const C_REDBEANPHP_VERSION = '4.2';
|
||||
const C_REDBEANPHP_VERSION = '4.3';
|
||||
|
||||
/**
|
||||
* @var ToolBox
|
||||
@ -110,7 +104,7 @@ class Facade
|
||||
* @var string
|
||||
*/
|
||||
private static $exportCaseStyle = 'default';
|
||||
|
||||
|
||||
/**
|
||||
* Not in use (backward compatibility SQLHelper)
|
||||
*/
|
||||
@ -130,8 +124,6 @@ class Facade
|
||||
* Internal Query function, executes the desired query. Used by
|
||||
* all facade query functions. This keeps things DRY.
|
||||
*
|
||||
* @throws SQL
|
||||
*
|
||||
* @param string $method desired query method (i.e. 'cell', 'col', 'exec' etc..)
|
||||
* @param string $sql the sql you want to execute
|
||||
* @param array $bindings array of values to be bound to query statement
|
||||
@ -231,62 +223,38 @@ class Facade
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a transaction within a closure (or other valid callback).
|
||||
* If an\Exception is thrown inside, the operation is automatically rolled back.
|
||||
* If no\Exception happens, it commits automatically.
|
||||
* Wraps a transaction around a closure or string callback.
|
||||
* If an Exception is thrown inside, the operation is automatically rolled back.
|
||||
* If no Exception happens, it commits automatically.
|
||||
* It also supports (simulated) nested transactions (that is useful when
|
||||
* you have many methods that needs transactions but are unaware of
|
||||
* each other).
|
||||
* ex:
|
||||
* $from = 1;
|
||||
* $to = 2;
|
||||
* $amount = 300;
|
||||
*
|
||||
* R::transaction(function() use($from, $to, $amount)
|
||||
* {
|
||||
* $accountFrom = R::load('account', $from);
|
||||
* $accountTo = R::load('account', $to);
|
||||
* Example:
|
||||
*
|
||||
* $accountFrom->money -= $amount;
|
||||
* $accountTo->money += $amount;
|
||||
* <code>
|
||||
* $from = 1;
|
||||
* $to = 2;
|
||||
* $amount = 300;
|
||||
*
|
||||
* R::store($accountFrom);
|
||||
* R::store($accountTo);
|
||||
* });
|
||||
* R::transaction(function() use($from, $to, $amount)
|
||||
* {
|
||||
* $accountFrom = R::load('account', $from);
|
||||
* $accountTo = R::load('account', $to);
|
||||
* $accountFrom->money -= $amount;
|
||||
* $accountTo->money += $amount;
|
||||
* R::store($accountFrom);
|
||||
* R::store($accountTo);
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* @param callable $callback Closure (or other callable) with the transaction logic
|
||||
*
|
||||
* @throws Security
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
*/
|
||||
public static function transaction( $callback )
|
||||
{
|
||||
if ( !is_callable( $callback ) ) {
|
||||
throw new RedException( 'R::transaction needs a valid callback.' );
|
||||
}
|
||||
|
||||
static $depth = 0;
|
||||
$result = null;
|
||||
try {
|
||||
if ( $depth == 0 ) {
|
||||
self::begin();
|
||||
}
|
||||
$depth++;
|
||||
$result = call_user_func( $callback ); //maintain 5.2 compatibility
|
||||
$depth--;
|
||||
if ( $depth == 0 ) {
|
||||
self::commit();
|
||||
}
|
||||
} catch (\Exception $exception ) {
|
||||
$depth--;
|
||||
if ( $depth == 0 ) {
|
||||
self::rollback();
|
||||
}
|
||||
throw $exception;
|
||||
}
|
||||
return $result;
|
||||
return Transaction::transaction( self::$adapter, $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,8 +263,10 @@ class Facade
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* R::addDatabase( 'database-1', 'sqlite:/tmp/db1.txt' );
|
||||
* R::selectDatabase( 'database-1' ); //to select database again
|
||||
* </code>
|
||||
*
|
||||
* This method allows you to dynamically add (and select) new databases
|
||||
* to the facade. Adding a database with the same key will cause an exception.
|
||||
@ -325,16 +295,19 @@ class Facade
|
||||
|
||||
$adapter = new DBAdapter( $db );
|
||||
|
||||
$writers = array(
|
||||
'pgsql' => 'PostgreSQL',
|
||||
'sqlite' => 'SQLiteT',
|
||||
'cubrid' => 'CUBRID',
|
||||
'mysql' => 'MySQL',
|
||||
'sqlsrv' => 'SQLServer',
|
||||
);
|
||||
$writers = array(
|
||||
'pgsql' => 'PostgreSQL',
|
||||
'sqlite' => 'SQLiteT',
|
||||
'cubrid' => 'CUBRID',
|
||||
'mysql' => 'MySQL',
|
||||
'sqlsrv' => 'SQLServer',
|
||||
);
|
||||
|
||||
$wkey = trim( strtolower( $dbType ) );
|
||||
if ( !isset( $writers[$wkey] ) ) trigger_error( 'Unsupported DSN: '.$wkey );
|
||||
if ( !isset( $writers[$wkey] ) ) {
|
||||
$wkey = preg_replace( '/\W/', '' , $wkey );
|
||||
throw new RedException( 'Unsupported database ('.$wkey.').' );
|
||||
}
|
||||
$writerClass = '\\RedBeanPHP\\QueryWriter\\'.$writers[$wkey];
|
||||
$writer = new $writerClass( $adapter );
|
||||
$redbean = new OODB( $writer, $frozen );
|
||||
@ -362,6 +335,10 @@ class Facade
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !isset( self::$toolboxes[$key] ) ) {
|
||||
throw new RedException( 'Database not found in registry. Add database using R::addDatabase().' );
|
||||
}
|
||||
|
||||
self::configureFacadeWithToolbox( self::$toolboxes[$key] );
|
||||
self::$currentDB = $key;
|
||||
|
||||
@ -379,9 +356,8 @@ class Facade
|
||||
* @param boolean $tf debug mode (true or false)
|
||||
* @param integer $mode (0 = to STDOUT, 1 = to ARRAY)
|
||||
*
|
||||
* @throws Security
|
||||
*
|
||||
* @return RDefault
|
||||
* @throws RedException
|
||||
*/
|
||||
public static function debug( $tf = TRUE, $mode = 0 )
|
||||
{
|
||||
@ -450,8 +426,6 @@ class Facade
|
||||
* @param OODBBean|SimpleModel $bean bean to store
|
||||
*
|
||||
* @return integer|string
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public static function store( $bean )
|
||||
{
|
||||
@ -480,28 +454,16 @@ class Facade
|
||||
* for loading a one-to-one relation.
|
||||
*
|
||||
* Usage:
|
||||
* list($author, $bio) = R::load('author, bio', $id);
|
||||
* list( $author, $bio ) = R::loadMulti( 'author, bio', $id );
|
||||
*
|
||||
* @param string|array $types
|
||||
* @param mixed $id
|
||||
* @param string|array $types the set of types to load at once
|
||||
* @param mixed $id the common ID
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
public static function loadMulti( $types, $id )
|
||||
{
|
||||
if ( is_string( $types ) ) {
|
||||
$types = explode( ',', $types );
|
||||
}
|
||||
|
||||
if ( !is_array( $types ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach ( $types as $k => $typeItem ) {
|
||||
$types[$k] = self::$redbean->load( $typeItem, $id );
|
||||
}
|
||||
|
||||
return $types;
|
||||
return MultiLoader::load( self::$redbean, $types, $id );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,8 +486,6 @@ class Facade
|
||||
* @param string $type type of bean you want to load
|
||||
* @param integer $id ID of the bean you want to load
|
||||
*
|
||||
* @throws SQL
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
public static function load( $type, $id )
|
||||
@ -543,7 +503,7 @@ class Facade
|
||||
* and THEN trash it.
|
||||
*
|
||||
* @param string|OODBBean|SimpleModel $bean bean you want to remove from database
|
||||
* @param integer $id (optional)
|
||||
* @param integer $id ID if the bean to trash (optional, type-id variant only)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -559,41 +519,13 @@ class Facade
|
||||
*
|
||||
* @param string|array $typeOrBeanArray type or bean array to import
|
||||
* @param integer $number number of beans to dispense
|
||||
* @param boolean $alwaysReturnArray if TRUE always returns the result as an array
|
||||
* @param boolean $alwaysReturnArray if TRUE always returns the result as an array
|
||||
*
|
||||
* @return array|OODBBean
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public static function dispense( $typeOrBeanArray, $num = 1, $alwaysReturnArray = FALSE )
|
||||
{
|
||||
if ( is_array($typeOrBeanArray) ) {
|
||||
|
||||
if ( !isset( $typeOrBeanArray['_type'] ) ) {
|
||||
$list = array();
|
||||
foreach( $typeOrBeanArray as $beanArray ) if ( !( is_array( $beanArray ) && isset( $beanArray['_type'] ) ) ) throw new RedException( 'Invalid Array Bean' );
|
||||
foreach( $typeOrBeanArray as $beanArray ) $list[] = self::dispense( $beanArray );
|
||||
return $list;
|
||||
}
|
||||
|
||||
$import = $typeOrBeanArray;
|
||||
$type = $import['_type'];
|
||||
unset( $import['_type'] );
|
||||
} else {
|
||||
$type = $typeOrBeanArray;
|
||||
}
|
||||
|
||||
if ( !preg_match( '/^[a-z0-9]+$/', $type ) ) {
|
||||
throw new RedException( 'Invalid type: ' . $type );
|
||||
}
|
||||
|
||||
$beanOrBeans = self::$redbean->dispense( $type, $num, $alwaysReturnArray );
|
||||
|
||||
if ( isset( $import ) ) {
|
||||
$beanOrBeans->import( $import );
|
||||
}
|
||||
|
||||
return $beanOrBeans;
|
||||
return DispenseHelper::dispense( self::$redbean, $typeOrBeanArray, $num, $alwaysReturnArray );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -603,14 +535,18 @@ class Facade
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* list($book, $page, $text) = R::dispenseAll('book,page,text');
|
||||
* <code>
|
||||
* list( $book, $page, $text ) = R::dispenseAll( 'book,page,text' );
|
||||
* </code>
|
||||
*
|
||||
* This will dispense a book, a page and a text. This way you can
|
||||
* quickly dispense beans of various types in just one line of code.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* list($book, $pages) = R::dispenseAll('book,page*100');
|
||||
* </code>
|
||||
*
|
||||
* This returns an array with a book bean and then another array
|
||||
* containing 100 page beans.
|
||||
@ -622,21 +558,7 @@ class Facade
|
||||
*/
|
||||
public static function dispenseAll( $order, $onlyArrays = FALSE )
|
||||
{
|
||||
|
||||
$list = array();
|
||||
|
||||
foreach( explode( ',', $order ) as $order ) {
|
||||
if ( strpos( $order, '*' ) !== false ) {
|
||||
list( $type, $amount ) = explode( '*', $order );
|
||||
} else {
|
||||
$type = $order;
|
||||
$amount = 1;
|
||||
}
|
||||
|
||||
$list[] = self::dispense( $type, $amount, $onlyArrays );
|
||||
}
|
||||
|
||||
return $list;
|
||||
return DispenseHelper::dispenseAll( self::$redbean, $order, $onlyArrays );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -661,9 +583,9 @@ class Facade
|
||||
* array parameter; you can either use the question mark notation
|
||||
* or the slot-notation (:keyname).
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -681,9 +603,9 @@ class Facade
|
||||
*
|
||||
* Your SQL does not have to start with a valid WHERE-clause condition.
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -696,9 +618,9 @@ class Facade
|
||||
* @see Facade::find
|
||||
* The variation also exports the beans (i.e. it returns arrays).
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -711,9 +633,9 @@ class Facade
|
||||
* @see Facade::find
|
||||
* This variation returns the first bean only.
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -726,9 +648,9 @@ class Facade
|
||||
* @see Facade::find
|
||||
* This variation returns the last bean only.
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -741,9 +663,9 @@ class Facade
|
||||
* Finds a bean collection.
|
||||
* Use this for large datasets.
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
* @param string $type the type of bean you are looking for
|
||||
* @param string $sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
* @param array $bindings array of values to be bound to parameters in query
|
||||
*
|
||||
* @return BeanCollection
|
||||
*/
|
||||
@ -762,7 +684,7 @@ class Facade
|
||||
* @param array|string $types a list of bean types to find
|
||||
* @param string|array $sqlOrArr SQL query string or result set array
|
||||
* @param array $bindings SQL bindings
|
||||
* @param array $remappings An array of remapping arrays containing closures
|
||||
* @param array $remappings an array of remapping arrays containing closures
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -812,8 +734,8 @@ class Facade
|
||||
* Convenience function to execute Queries directly.
|
||||
* Executes SQL.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
@ -826,8 +748,8 @@ class Facade
|
||||
* Convenience function to execute Queries directly.
|
||||
* Executes SQL.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -840,8 +762,8 @@ class Facade
|
||||
* Convenience function to execute Queries directly.
|
||||
* Executes SQL.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -854,8 +776,8 @@ class Facade
|
||||
* Convenience function to execute Queries directly.
|
||||
* Executes SQL.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -868,8 +790,8 @@ class Facade
|
||||
* Convenience function to execute Queries directly.
|
||||
* Executes SQL.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -887,8 +809,8 @@ class Facade
|
||||
* selected in the query, both key and value of the array will have the
|
||||
* value of this field for each row.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -903,8 +825,8 @@ class Facade
|
||||
* Results will be returned as an associative array indexed by the first
|
||||
* column in the select.
|
||||
*
|
||||
* @param string $sql sql SQL query to execute
|
||||
* @param array $bindings values a list of values to be bound to query parameters
|
||||
* @param string $sql SQL query to execute
|
||||
* @param array $bindings a list of values to be bound to query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -946,7 +868,7 @@ class Facade
|
||||
* @param OODBBean $bean bean to be copied
|
||||
* @param array $trail for internal usage, pass array()
|
||||
* @param boolean $pid for internal usage
|
||||
* @param array $white white list filter with bean types to duplicate
|
||||
* @param array $white white list filter with bean types to duplicate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -960,9 +882,9 @@ class Facade
|
||||
* Makes a deep copy of a bean. This method makes a deep copy
|
||||
* of the bean.The copy will have the following:
|
||||
*
|
||||
* - All beans in own-lists will be duplicated as well
|
||||
* - All references to shared beans will be copied but not the shared beans themselves
|
||||
* - All references to parent objects (_id fields) will be copied but not the parents themselves
|
||||
* * All beans in own-lists will be duplicated as well
|
||||
* * All references to shared beans will be copied but not the shared beans themselves
|
||||
* * All references to parent objects (_id fields) will be copied but not the parents themselves
|
||||
*
|
||||
* In most cases this is the desired scenario for copying beans.
|
||||
* This function uses a trail-array to prevent infinite recursion, if a recursive bean is found
|
||||
@ -976,7 +898,7 @@ class Facade
|
||||
* This is a simplified version of the deprecated R::dup() function.
|
||||
*
|
||||
* @param OODBBean $bean bean to be copied
|
||||
* @param array $white white list filter with bean types to duplicate
|
||||
* @param array $white white list filter with bean types to duplicate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -989,15 +911,16 @@ class Facade
|
||||
* Exports a collection of beans. Handy for XML/JSON exports with a
|
||||
* Javascript framework like Dojo or ExtJS.
|
||||
* What will be exported:
|
||||
* - contents of the bean
|
||||
* - all own bean lists (recursively)
|
||||
* - all shared beans (not THEIR own lists)
|
||||
*
|
||||
* * contents of the bean
|
||||
* * all own bean lists (recursively)
|
||||
* * all shared beans (not THEIR own lists)
|
||||
*
|
||||
* @param array|OODBBean $beans beans to be exported
|
||||
* @param boolean $parents whether you want parent beans to be exported
|
||||
* @param array $filters whitelist of types
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public static function exportAll( $beans, $parents = FALSE, $filters = array())
|
||||
{
|
||||
@ -1009,9 +932,9 @@ class Facade
|
||||
* This will determine the case style for the keys of exported beans (see exportAll).
|
||||
* The following options are accepted:
|
||||
*
|
||||
* 'default' RedBeanPHP by default enforces Snake Case (i.e. book_id is_valid )
|
||||
* 'camel' Camel Case (i.e. bookId isValid )
|
||||
* 'dolphin' Dolphin Case (i.e. bookID isValid ) Like CamelCase but ID is written all uppercase
|
||||
* * 'default' RedBeanPHP by default enforces Snake Case (i.e. book_id is_valid )
|
||||
* * 'camel' Camel Case (i.e. bookId isValid )
|
||||
* * 'dolphin' Dolphin Case (i.e. bookID isValid ) Like CamelCase but ID is written all uppercase
|
||||
*
|
||||
* @warning RedBeanPHP transforms camelCase to snake_case using a slightly different
|
||||
* algorithm, it also converts isACL to is_acl (not is_a_c_l) and bookID to book_id.
|
||||
@ -1090,8 +1013,8 @@ class Facade
|
||||
* be associated with the bean.
|
||||
* You may also pass an array instead of a string.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param mixed $tagList tags
|
||||
* @param OODBBean $bean bean to tag
|
||||
* @param mixed $tagList tags to attach to the specified bean
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -1107,7 +1030,7 @@ class Facade
|
||||
* be associated with the bean.
|
||||
* You may also pass an array instead of a string.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param OODBBean $bean bean to tag
|
||||
* @param array $tagList list of tags to add to bean
|
||||
*
|
||||
* @return void
|
||||
@ -1123,8 +1046,8 @@ class Facade
|
||||
*
|
||||
* @param string $beanType type of bean you are looking for
|
||||
* @param array $tagList list of tags to match
|
||||
* @param string $sql additional SQL
|
||||
* @param array $bindings bindings
|
||||
* @param string $sql additional SQL query snippet
|
||||
* @param array $bindings a list of values to bind to the query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -1139,8 +1062,8 @@ class Facade
|
||||
*
|
||||
* @param string $beanType type of bean you are looking for
|
||||
* @param array $tagList list of tags to match
|
||||
* @param string $sql additional SQL
|
||||
* @param array $bindings bindings
|
||||
* @param string $sql additional SQL query snippet
|
||||
* @param array $bindings a list of values to bind to the query parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -1171,8 +1094,6 @@ class Facade
|
||||
* @param array $bindings parameters to bind to SQL
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws SQL
|
||||
*/
|
||||
public static function count( $type, $addSQL = '', $bindings = array() )
|
||||
{
|
||||
@ -1184,36 +1105,26 @@ class Facade
|
||||
* Adapter and you want it on-the-fly? Use this method to hot-swap your facade with a new
|
||||
* toolbox.
|
||||
*
|
||||
* @param ToolBox $tb toolbox
|
||||
* @param ToolBox $tb toolbox to configure facade with
|
||||
*
|
||||
* @return ToolBox
|
||||
*/
|
||||
public static function configureFacadeWithToolbox( ToolBox $tb )
|
||||
{
|
||||
$oldTools = self::$toolbox;
|
||||
|
||||
self::$toolbox = $tb;
|
||||
|
||||
self::$writer = self::$toolbox->getWriter();
|
||||
self::$adapter = self::$toolbox->getDatabaseAdapter();
|
||||
self::$redbean = self::$toolbox->getRedBean();
|
||||
self::$finder = new Finder( self::$toolbox );
|
||||
|
||||
self::$associationManager = new AssociationManager( self::$toolbox );
|
||||
|
||||
self::$redbean->setAssociationManager( self::$associationManager );
|
||||
|
||||
self::$labelMaker = new LabelMaker( self::$toolbox );
|
||||
|
||||
$helper = new SimpleModelHelper();
|
||||
|
||||
$helper->attachEventListeners( self::$redbean );
|
||||
|
||||
self::$redbean->setBeanHelper( new SimpleFacadeBeanHelper );
|
||||
|
||||
self::$duplicationManager = new DuplicationManager( self::$toolbox );
|
||||
self::$tagManager = new TagManager( self::$toolbox );
|
||||
|
||||
return $oldTools;
|
||||
}
|
||||
|
||||
@ -1226,9 +1137,7 @@ class Facade
|
||||
public static function begin()
|
||||
{
|
||||
if ( !self::$redbean->isFrozen() ) return FALSE;
|
||||
|
||||
self::$adapter->startTransaction();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1241,9 +1150,7 @@ class Facade
|
||||
public static function commit()
|
||||
{
|
||||
if ( !self::$redbean->isFrozen() ) return FALSE;
|
||||
|
||||
self::$adapter->commit();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1256,9 +1163,7 @@ class Facade
|
||||
public static function rollback()
|
||||
{
|
||||
if ( !self::$redbean->isFrozen() ) return FALSE;
|
||||
|
||||
self::$adapter->rollback();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1286,8 +1191,7 @@ class Facade
|
||||
*/
|
||||
public static function genSlots( $array, $template = NULL )
|
||||
{
|
||||
$str = count( $array ) ? implode( ',', array_fill( 0, count( $array ), '?' ) ) : '';
|
||||
return ( is_null( $template ) || $str === '' ) ? $str : sprintf( $template, $str );
|
||||
return ArrayTool::genSlots( $array, $template );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1299,11 +1203,7 @@ class Facade
|
||||
*/
|
||||
public static function flat( $array, $result = array() )
|
||||
{
|
||||
foreach( $array as $value ) {
|
||||
if ( is_array( $value ) ) $result = self::flat( $value, $result );
|
||||
else $result[] = $value;
|
||||
}
|
||||
return $result;
|
||||
return ArrayTool::flat( $array, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1338,7 +1238,6 @@ class Facade
|
||||
foreach ( $beans as $bean ) {
|
||||
$ids[] = self::store( $bean );
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
@ -1378,7 +1277,6 @@ class Facade
|
||||
self::getWriter()->setUseCache( $yesNo );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A label is a bean with only an id, type and name property.
|
||||
* This function will dispense beans for all entries in the array. The
|
||||
@ -1402,7 +1300,9 @@ class Facade
|
||||
*
|
||||
* To obtain (and add if necessary) an ENUM value:
|
||||
*
|
||||
* <code>
|
||||
* $tea->flavour = R::enum( 'flavour:apple' );
|
||||
* </code>
|
||||
*
|
||||
* Returns a bean of type 'flavour' with name = apple.
|
||||
* This will add a bean with property name (set to APPLE) to the database
|
||||
@ -1410,11 +1310,15 @@ class Facade
|
||||
*
|
||||
* To obtain all flavours:
|
||||
*
|
||||
* <code>
|
||||
* R::enum('flavour');
|
||||
* </code>
|
||||
*
|
||||
* To get a list of all flavour names:
|
||||
*
|
||||
* <code>
|
||||
* R::gatherLabels( R::enum( 'flavour' ) );
|
||||
* </code>
|
||||
*
|
||||
* @param string $enum either type or type-value
|
||||
*
|
||||
@ -1481,7 +1385,6 @@ class Facade
|
||||
public static function isoDateTime( $time = NULL )
|
||||
{
|
||||
if ( !$time ) $time = time();
|
||||
|
||||
return @date( 'Y-m-d H:i:s', $time );
|
||||
}
|
||||
|
||||
@ -1489,7 +1392,7 @@ class Facade
|
||||
* Optional accessor for neat code.
|
||||
* Sets the database adapter you want to use.
|
||||
*
|
||||
* @param Adapter $adapter
|
||||
* @param Adapter $adapter Database Adapter for facade to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -1502,7 +1405,7 @@ class Facade
|
||||
* Optional accessor for neat code.
|
||||
* Sets the database adapter you want to use.
|
||||
*
|
||||
* @param QueryWriter $writer
|
||||
* @param QueryWriter $writer Query Writer instance for facade to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -1515,7 +1418,7 @@ class Facade
|
||||
* Optional accessor for neat code.
|
||||
* Sets the database adapter you want to use.
|
||||
*
|
||||
* @param OODB $redbean
|
||||
* @param OODB $redbean Object Database for facade to use
|
||||
*/
|
||||
public static function setRedBean( OODB $redbean )
|
||||
{
|
||||
@ -1586,21 +1489,16 @@ class Facade
|
||||
*
|
||||
* Returns the components in the following order:
|
||||
*
|
||||
* 0 - OODB instance (getRedBean())
|
||||
* 1 - Database Adapter
|
||||
* 2 - Query Writer
|
||||
* 3 - Toolbox itself
|
||||
* # OODB instance (getRedBean())
|
||||
* # Database Adapter
|
||||
* # Query Writer
|
||||
* # Toolbox itself
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExtractedToolbox()
|
||||
{
|
||||
return array(
|
||||
self::$redbean,
|
||||
self::$adapter,
|
||||
self::$writer,
|
||||
self::$toolbox
|
||||
);
|
||||
return array( self::$redbean, self::$adapter, self::$writer, self::$toolbox );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1630,36 +1528,36 @@ class Facade
|
||||
public static function beansToArray( $beans )
|
||||
{
|
||||
$list = array();
|
||||
foreach( $beans as $bean ) {
|
||||
$list[] = $bean->export();
|
||||
}
|
||||
foreach( $beans as $bean ) $list[] = $bean->export();
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the error mode for FUSE.
|
||||
* What to do if a FUSE model method does not exist?
|
||||
* You can set the following options:
|
||||
*
|
||||
* OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL
|
||||
* OODBBean::C_ERR_LOG, logs the incident using error_log
|
||||
* OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE
|
||||
* OODBBean::C_ERR_WARN, triggers a E_USER_WARNING
|
||||
* OODBBean::C_ERR_EXCEPTION, throws an exception
|
||||
* OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function)
|
||||
* OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR
|
||||
*
|
||||
* * OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL
|
||||
* * OODBBean::C_ERR_LOG, logs the incident using error_log
|
||||
* * OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE
|
||||
* * OODBBean::C_ERR_WARN, triggers a E_USER_WARNING
|
||||
* * OODBBean::C_ERR_EXCEPTION, throws an exception
|
||||
* * OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function)
|
||||
* * OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR
|
||||
*
|
||||
* <code>
|
||||
* Custom handler method signature: handler( array (
|
||||
* 'message' => string
|
||||
* 'bean' => OODBBean
|
||||
* 'method' => string
|
||||
* ) )
|
||||
* </code>
|
||||
*
|
||||
* This method returns the old mode and handler as an array.
|
||||
*
|
||||
* @param integer $mode mode
|
||||
* @param callable|NULL $func custom handler
|
||||
*
|
||||
* @param integer $mode mode, determines how to handle errors
|
||||
* @param callable|NULL $func custom handler (if applicable)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setErrorHandlingFUSE( $mode, $func = NULL )
|
||||
@ -1676,29 +1574,10 @@ class Facade
|
||||
* @param OODBBean|array $data either a bean or an array of beans
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public static function dump( $data )
|
||||
{
|
||||
$array = array();
|
||||
|
||||
if ( $data instanceof OODBBean ) {
|
||||
$str = strval( $data );
|
||||
if (strlen($str) > 35) {
|
||||
$beanStr = substr( $str, 0, 35 ).'... ';
|
||||
} else {
|
||||
$beanStr = $str;
|
||||
}
|
||||
return $beanStr;
|
||||
}
|
||||
|
||||
if ( is_array( $data ) ) {
|
||||
foreach( $data as $key => $item ) {
|
||||
$array[$key] = self::dump( $item );
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
return Dump::dump( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1710,16 +1589,19 @@ class Facade
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* R::bindFunc( 'read', 'location.point', 'asText' );
|
||||
* R::bindFunc( 'write', 'location.point', 'GeomFromText' );
|
||||
* </code>
|
||||
*
|
||||
* Passing NULL as the function will reset (clear) the function
|
||||
* for this column/mode.
|
||||
*
|
||||
* @param string $mode (read or write)
|
||||
* @param string $field
|
||||
* @param string $function
|
||||
* @param string $mode mode for function: i.e. read or write
|
||||
* @param string $field field (table.column) to bind function to
|
||||
* @param string $function SQL function to bind to specified column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function bindFunc( $mode, $field, $function )
|
||||
{
|
||||
@ -1729,7 +1611,7 @@ class Facade
|
||||
/**
|
||||
* Sets global aliases.
|
||||
*
|
||||
* @param array $list
|
||||
* @param array $list list of global aliases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -1865,14 +1747,20 @@ class Facade
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* R::ext( 'makeTea', function() { ... } );
|
||||
* </code>
|
||||
*
|
||||
* Now you can use your makeTea plugin like this:
|
||||
*
|
||||
* <code>
|
||||
* R::makeTea();
|
||||
* </code>
|
||||
*
|
||||
* @param string $pluginName name of the method to call the plugin
|
||||
* @param callable $callable a PHP callable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function ext( $pluginName, $callable )
|
||||
{
|
||||
|
@ -2,10 +2,6 @@
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\ToolBox as ToolBox;
|
||||
use RedBeanPHP\OODB as OODB;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
|
||||
/**
|
||||
* RedBeanPHP Finder.
|
||||
@ -59,8 +55,6 @@ class Finder
|
||||
* @param array $bindings values array of values to be bound to parameters in query
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function find( $type, $sql = NULL, $bindings = array() )
|
||||
{
|
||||
@ -75,8 +69,12 @@ class Finder
|
||||
|
||||
/**
|
||||
* Like find() but also exports the beans as an array.
|
||||
* This method will perform a find-operation. For every bean
|
||||
* in the result collection this method will call the export() method.
|
||||
* This method returns an array containing the array representations
|
||||
* of every bean in the result set.
|
||||
*
|
||||
* @see Finder::findAndExport
|
||||
* @see Finder::find
|
||||
*
|
||||
* @param string $type type the type of bean you are looking for
|
||||
* @param string $sql sql SQL query to find the desired bean, starting right after WHERE clause
|
||||
@ -97,6 +95,7 @@ class Finder
|
||||
/**
|
||||
* Like find() but returns just one bean instead of an array of beans.
|
||||
* This method will return only the first bean of the array.
|
||||
* If no beans are found, this method will return NULL.
|
||||
*
|
||||
* @see Finder::find
|
||||
*
|
||||
@ -109,7 +108,7 @@ class Finder
|
||||
public function findOne( $type, $sql = NULL, $bindings = array() )
|
||||
{
|
||||
$sql = $this->toolbox->getWriter()->glueLimitOne( $sql );
|
||||
|
||||
|
||||
$items = $this->find( $type, $sql, $bindings );
|
||||
|
||||
if ( empty($items) ) {
|
||||
@ -122,6 +121,7 @@ class Finder
|
||||
/**
|
||||
* Like find() but returns the last bean of the result array.
|
||||
* Opposite of Finder::findLast().
|
||||
* If no beans are found, this method will return NULL.
|
||||
*
|
||||
* @see Finder::find
|
||||
*
|
||||
@ -252,9 +252,11 @@ class Finder
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* $stuff = $finder->findMulti('movie,review', '
|
||||
* SELECT movie.*, review.* FROM movie
|
||||
* LEFT JOIN review ON review.movie_id = movie.id');
|
||||
* </code>
|
||||
*
|
||||
* After this operation, $stuff will contain an entry 'movie' containing all
|
||||
* movies and an entry named 'review' containing all reviews (all beans).
|
||||
@ -267,18 +269,21 @@ class Finder
|
||||
* The remapping argument (optional) should contain an array of arrays.
|
||||
* Each array in the remapping array should contain the following entries:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'a' => TYPE A
|
||||
* 'b' => TYPE B
|
||||
* 'matcher' => MATCHING FUNCTION ACCEPTING A, B and ALL BEANS
|
||||
* 'do' => OPERATION FUNCTION ACCEPTING A, B, ALL BEANS, ALL REMAPPINGS
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* Using this mechanism you can build your own 'preloader' with tiny function
|
||||
* snippets (and those can be re-used and shared online of course).
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'a' => 'movie' //define A as movie
|
||||
* 'b' => 'review' //define B as review
|
||||
@ -290,6 +295,7 @@ class Finder
|
||||
* $a->clearHistory(); //optional, act 'as if these beans have been loaded through ownReviewList'.
|
||||
* }
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* The Query Template parameter is optional as well but can be used to
|
||||
* set a different SQL template (sprintf-style) for processing the original query.
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @file RedBeanPHP/Functions.php
|
||||
* @author Gabor de Mooij and the RedBeanPHP community
|
||||
* @license BSD/GPLv2
|
||||
*
|
||||
*
|
||||
* @copyright
|
||||
* copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
|
||||
* This source file is subject to the BSD/GPLv2 License that is bundled
|
||||
@ -19,7 +19,9 @@
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* R::find( 'paint', ' color_id = ? ', [ EID('color:yellow') ] );
|
||||
* </code>
|
||||
*
|
||||
* If a function called EID() already exists you'll have to write this
|
||||
* wrapper yourself ;)
|
||||
|
@ -45,7 +45,9 @@ class LabelMaker
|
||||
* values of the array will be assigned to the name property of each
|
||||
* individual bean.
|
||||
*
|
||||
* <code>
|
||||
* $people = R::dispenseLabels( 'person', [ 'Santa', 'Claus' ] );
|
||||
* </code>
|
||||
*
|
||||
* @param string $type type of beans you would like to have
|
||||
* @param array $labels list of labels, names for each bean
|
||||
@ -72,9 +74,11 @@ class LabelMaker
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* $o1->name = 'hamburger';
|
||||
* $o2->name = 'pizza';
|
||||
* implode( ',', R::gatherLabels( [ $o1, $o2 ] ) ); //hamburger,pizza
|
||||
* </code>
|
||||
*
|
||||
* Note that the return value is an array of strings, not beans.
|
||||
*
|
||||
@ -94,39 +98,47 @@ class LabelMaker
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches an ENUM from the database and creates it if necessary.
|
||||
* An ENUM has the following format:
|
||||
*
|
||||
* <code>
|
||||
* ENUM:VALUE
|
||||
* </code>
|
||||
*
|
||||
* If you pass 'ENUM' only, this method will return an array of its
|
||||
* values:
|
||||
*
|
||||
* <code>
|
||||
* implode( ',', R::gatherLabels( R::enum( 'flavour' ) ) ) //'BANANA,MOCCA'
|
||||
* </code>
|
||||
*
|
||||
* If you pass 'ENUM:VALUE' this method will return the specified enum bean
|
||||
* and create it in the database if it does not exist yet:
|
||||
*
|
||||
* <code>
|
||||
* $bananaFlavour = R::enum( 'flavour:banana' );
|
||||
* $bananaFlavour->name;
|
||||
* </code>
|
||||
*
|
||||
* So you can use this method to set an ENUM value in a bean:
|
||||
*
|
||||
* <code>
|
||||
* $shake->flavour = R::enum( 'flavour:banana' );
|
||||
* </code>
|
||||
*
|
||||
* the property flavour now contains the enum bean, a parent bean.
|
||||
* In the database, flavour_id will point to the flavour record with name 'banana'.
|
||||
*
|
||||
* @param string $enum ENUM specification for label
|
||||
*
|
||||
*
|
||||
* @return array|OODBBean
|
||||
*/
|
||||
public function enum( $enum )
|
||||
{
|
||||
$oodb = $this->toolbox->getRedBean();
|
||||
|
||||
|
||||
if ( strpos( $enum, ':' ) === FALSE ) {
|
||||
$type = $enum;
|
||||
$value = FALSE;
|
||||
@ -134,22 +146,37 @@ class LabelMaker
|
||||
list( $type, $value ) = explode( ':', $enum );
|
||||
$value = preg_replace( '/\W+/', '_', strtoupper( trim( $value ) ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* We use simply find here, we could use inspect() in fluid mode etc,
|
||||
* but this would be useless. At first sight it looks clean, you could even
|
||||
* bake this into find(), however, find not only has to deal with the primary
|
||||
* search type, people can also include references in the SQL part, so avoiding
|
||||
* find failures does not matter, this is still the quickest way making use
|
||||
* of existing functionality.
|
||||
*
|
||||
* @note There seems to be a bug in XDebug v2.3.2 causing suppressed
|
||||
* exceptions like these to surface anyway, to prevent this use:
|
||||
*
|
||||
* "xdebug.default_enable = 0"
|
||||
*
|
||||
* Also see Github Issue #464
|
||||
*/
|
||||
$values = $oodb->find( $type );
|
||||
|
||||
|
||||
if ( $value === FALSE ) {
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
foreach( $values as $enumItem ) {
|
||||
if ( $enumItem->name === $value ) return $enumItem;
|
||||
if ( $enumItem->name === $value ) return $enumItem;
|
||||
}
|
||||
|
||||
|
||||
$newEnumItems = $this->dispenseLabels( $type, array( $value ) );
|
||||
$newEnumItem = reset( $newEnumItems );
|
||||
|
||||
|
||||
$oodb->store( $newEnumItem );
|
||||
|
||||
|
||||
return $newEnumItem;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -18,16 +18,16 @@ namespace RedBeanPHP;
|
||||
*/
|
||||
interface Logger
|
||||
{
|
||||
|
||||
/**
|
||||
* A logger (for\PDO or OCI driver) needs to implement the log method.
|
||||
* A logger (for PDO or OCI driver) needs to implement the log method.
|
||||
* The log method will receive logging data. Note that the number of parameters is 0, this means
|
||||
* all parameters are optional and the number may vary. This way the logger can be used in a very
|
||||
* flexible way. Sometimes the logger is used to log a simple error message and in other
|
||||
* situations sql and bindings are passed.
|
||||
* The log method should be able to accept all kinds of parameters and data by using
|
||||
* functions like func_num_args/func_get_args.
|
||||
*
|
||||
*
|
||||
* @param string $message, ...
|
||||
* @return void
|
||||
*/
|
||||
public function log();
|
||||
|
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP\Logger;
|
||||
|
||||
use RedBeanPHP\Logger as Logger;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
|
||||
/**
|
||||
* Logger. Provides a basic logging function for RedBeanPHP.
|
||||
@ -66,25 +65,25 @@ class RDefault implements Logger
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->mode === self::C_LOGGER_ECHO ) echo "<br>\n";
|
||||
if ( $this->mode === self::C_LOGGER_ECHO ) echo "<br>" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the internal log array.
|
||||
* The internal log array is where all log messages are stored.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs()
|
||||
{
|
||||
return $this->logs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the internal log array, removing all
|
||||
* previously stored entries.
|
||||
*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function clear()
|
||||
@ -92,16 +91,16 @@ class RDefault implements Logger
|
||||
$this->logs = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a logging mode.
|
||||
* There are several options available.
|
||||
*
|
||||
* C_LOGGER_ARRAY - log silently, stores entries in internal log array only
|
||||
* C_LOGGER_ECHO - also forward log messages directly to STDOUT
|
||||
*
|
||||
*
|
||||
* * C_LOGGER_ARRAY - log silently, stores entries in internal log array only
|
||||
* * C_LOGGER_ECHO - also forward log messages directly to STDOUT
|
||||
*
|
||||
* @param integer $mode mode of operation for logging object
|
||||
*
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMode( $mode )
|
||||
@ -112,7 +111,7 @@ class RDefault implements Logger
|
||||
$this->mode = $mode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches for all log entries in internal log array
|
||||
* for $needle and returns those entries.
|
||||
|
@ -5,7 +5,6 @@ namespace RedBeanPHP\Logger\RDefault;
|
||||
use RedBeanPHP\Logger as Logger;
|
||||
use RedBeanPHP\Logger\RDefault as RDefault;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
|
||||
/**
|
||||
* Debug logger.
|
||||
@ -57,7 +56,7 @@ class Debug extends RDefault implements Logger
|
||||
* Fills in a value of a binding and truncates the
|
||||
* resulting string if necessary.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $value bound value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -89,7 +88,7 @@ class Debug extends RDefault implements Logger
|
||||
protected function output( $str )
|
||||
{
|
||||
$this->logs[] = $str;
|
||||
if ( !$this->mode ) echo $str .'<br />';
|
||||
if ( !$this->mode ) echo $str ,'<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,16 +2,9 @@
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\Observable as Observable;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\BeanHelper\FacadeBeanHelper as FacadeBeanHelper;
|
||||
use RedBeanPHP\AssociationManager as AssociationManager;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\SimpleModel as SimpleModel;
|
||||
use RedBeanPHP\BeanHelper as BeanHelper;
|
||||
use RedBeanPHP\RedException\SQL as SQL;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\Repository as Repository;
|
||||
use RedBeanPHP\Repository\Fluid as FluidRepo;
|
||||
@ -19,7 +12,7 @@ use RedBeanPHP\Repository\Frozen as FrozenRepo;
|
||||
|
||||
/**
|
||||
* RedBean Object Oriented DataBase.
|
||||
*
|
||||
*
|
||||
* The RedBean OODB Class is the main class of RedBeanPHP.
|
||||
* It takes OODBBean objects and stores them to and loads them from the
|
||||
* database as well as providing other CRUD functions. This class acts as a
|
||||
@ -46,7 +39,6 @@ class OODB extends Observable
|
||||
*/
|
||||
protected $chillList = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -92,6 +84,24 @@ class OODB extends Observable
|
||||
*/
|
||||
protected $fluidRepository = NULL;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected static $autoClearHistoryAfterStore = FALSE;
|
||||
|
||||
/**
|
||||
* If set to TRUE, this method will call clearHistory every time
|
||||
* the bean gets stored.
|
||||
*
|
||||
* @param boolean $autoClear auto clear option
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function autoClearHistoryAfterStore( $autoClear = TRUE )
|
||||
{
|
||||
self::$autoClearHistoryAfterStore = (boolean) $autoClear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unboxes a bean from a FUSE model if needed and checks whether the bean is
|
||||
* an instance of OODBBean.
|
||||
@ -99,8 +109,6 @@ class OODB extends Observable
|
||||
* @param OODBBean $bean bean you wish to unbox
|
||||
*
|
||||
* @return OODBBean
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
protected function unboxIfNeeded( $bean )
|
||||
{
|
||||
@ -259,8 +267,6 @@ class OODB extends Observable
|
||||
* @param OODBBean $bean the bean that needs to be checked
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security $exception
|
||||
*/
|
||||
public function check( OODBBean $bean )
|
||||
{
|
||||
@ -273,10 +279,12 @@ class OODB extends Observable
|
||||
*
|
||||
* Conditions need to take form:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'PROPERTY' => array( POSSIBLE VALUES... 'John', 'Steve' )
|
||||
* 'PROPERTY' => array( POSSIBLE VALUES... )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* All conditions are glued together using the AND-operator, while all value lists
|
||||
* are glued using IN-operators thus acting as OR-conditions.
|
||||
@ -287,11 +295,9 @@ class OODB extends Observable
|
||||
* @param string $type type of beans you are looking for
|
||||
* @param array $conditions list of conditions
|
||||
* @param string $addSQL SQL to be used in query
|
||||
* @param array $bindings whether you prefer to use a WHERE clause or not (TRUE = not)
|
||||
* @param array $bindings a list of values to bind to query parameters
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws SQL
|
||||
*/
|
||||
public function find( $type, $conditions = array(), $sql = NULL, $bindings = array() )
|
||||
{
|
||||
@ -301,13 +307,11 @@ class OODB extends Observable
|
||||
/**
|
||||
* Same as find() but returns a BeanCollection.
|
||||
*
|
||||
* @param string $type type of beans you are looking for
|
||||
* @param string $addSQL SQL to be used in query
|
||||
* @param array $bindings whether you prefer to use a WHERE clause or not (TRUE = not)
|
||||
* @param string $type type of beans you are looking for
|
||||
* @param string $addSQL SQL to be used in query
|
||||
* @param array $bindings a list of values to bind to query parameters
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws SQL
|
||||
*/
|
||||
public function findCollection( $type, $sql = NULL, $bindings = array() )
|
||||
{
|
||||
@ -348,13 +352,15 @@ class OODB extends Observable
|
||||
* @param OODBBean|SimpleModel $bean bean to store
|
||||
*
|
||||
* @return integer|string
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function store( $bean )
|
||||
{
|
||||
$bean = $this->unboxIfNeeded( $bean );
|
||||
return $this->repository->store( $bean );
|
||||
$id = $this->repository->store( $bean );
|
||||
if ( self::$autoClearHistoryAfterStore ) {
|
||||
$bean->clearHistory();
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -377,10 +383,7 @@ class OODB extends Observable
|
||||
* @param string $type type of bean you want to load
|
||||
* @param integer $id ID of the bean you want to load
|
||||
*
|
||||
* @throws SQL
|
||||
*
|
||||
* @return OODBBean
|
||||
*
|
||||
*/
|
||||
public function load( $type, $id )
|
||||
{
|
||||
@ -395,8 +398,6 @@ class OODB extends Observable
|
||||
* @param OODBBean|SimpleModel $bean bean you want to remove from database
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function trash( $bean )
|
||||
{
|
||||
@ -449,8 +450,6 @@ class OODB extends Observable
|
||||
* @param array $bindings parameters to bind to SQL
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws SQL
|
||||
*/
|
||||
public function count( $type, $addSQL = '', $bindings = array() )
|
||||
{
|
||||
@ -463,8 +462,6 @@ class OODB extends Observable
|
||||
* @param string $type type of bean you wish to delete all instances of
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @throws SQL
|
||||
*/
|
||||
public function wipe( $type )
|
||||
{
|
||||
@ -477,8 +474,6 @@ class OODB extends Observable
|
||||
* storage and more.
|
||||
*
|
||||
* @return AssociationManager
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function getAssociationManager()
|
||||
{
|
||||
@ -521,9 +516,11 @@ class OODB extends Observable
|
||||
* MySQL spatial columns, because they need to be processed first using
|
||||
* the asText/GeomFromText functions.
|
||||
*
|
||||
* @param string $mode (read or write)
|
||||
* @param string $field
|
||||
* @param string $function
|
||||
* @param string $mode mode to set function for, i.e. read or write
|
||||
* @param string $field field (table.column) to bind SQL function to
|
||||
* @param string $function SQL function to bind to field
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function bindFunc( $mode, $field, $function )
|
||||
{
|
||||
|
@ -4,13 +4,11 @@ namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\BeanHelper as BeanHelper;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
|
||||
/**
|
||||
* OODBBean (Object Oriented DataBase Bean).
|
||||
*
|
||||
*
|
||||
* to exchange information with the database. A bean represents
|
||||
* a single table row and offers generic services for interaction
|
||||
* with databases systems as well as some meta-data.
|
||||
@ -19,7 +17,7 @@ use RedBeanPHP\OODBBean as OODBBean;
|
||||
* @author Gabor de Mooij and the RedBeanPHP community
|
||||
* @license BSD/GPLv2
|
||||
* @desc OODBBean represents a bean. RedBeanPHP uses beans
|
||||
*
|
||||
*
|
||||
* @copyright
|
||||
* copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
|
||||
* This source file is subject to the BSD/GPLv2 License that is bundled
|
||||
@ -58,84 +56,6 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*/
|
||||
protected static $autoResolve = FALSE;
|
||||
|
||||
/**
|
||||
* Sets the error mode for FUSE.
|
||||
* What to do if a FUSE model method does not exist?
|
||||
* You can set the following options:
|
||||
*
|
||||
* OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL
|
||||
* OODBBean::C_ERR_LOG, logs the incident using error_log
|
||||
* OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE
|
||||
* OODBBean::C_ERR_WARN, triggers a E_USER_WARNING
|
||||
* OODBBean::C_ERR_EXCEPTION, throws an exception
|
||||
* OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function)
|
||||
* OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR
|
||||
*
|
||||
* Custom handler method signature: handler( array (
|
||||
* 'message' => string
|
||||
* 'bean' => OODBBean
|
||||
* 'method' => string
|
||||
* ) )
|
||||
*
|
||||
* This method returns the old mode and handler as an array.
|
||||
*
|
||||
* @param integer $mode mode
|
||||
* @param callable|NULL $func custom handler
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setErrorHandlingFUSE($mode, $func = NULL) {
|
||||
if (
|
||||
$mode !== self::C_ERR_IGNORE
|
||||
&& $mode !== self::C_ERR_LOG
|
||||
&& $mode !== self::C_ERR_NOTICE
|
||||
&& $mode !== self::C_ERR_WARN
|
||||
&& $mode !== self::C_ERR_EXCEPTION
|
||||
&& $mode !== self::C_ERR_FUNC
|
||||
&& $mode !== self::C_ERR_FATAL
|
||||
) throw new \Exception( 'Invalid error mode selected' );
|
||||
|
||||
if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) {
|
||||
throw new \Exception( 'Invalid error handler' );
|
||||
}
|
||||
|
||||
$old = array( self::$errorHandlingFUSE, self::$errorHandler );
|
||||
self::$errorHandlingFUSE = $mode;
|
||||
if ( is_callable( $func ) ) {
|
||||
self::$errorHandler = $func;
|
||||
} else {
|
||||
self::$errorHandler = NULL;
|
||||
}
|
||||
return $old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets aliases.
|
||||
*
|
||||
* @param array $list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function aliases( $list )
|
||||
{
|
||||
self::$aliases = $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables auto-resolving fetch types.
|
||||
* Auto-resolving aliased parent beans is convenient but can
|
||||
* be slower and can create infinite recursion if you
|
||||
* used aliases to break cyclic relations in your domain.
|
||||
*
|
||||
* @param boolean $automatic TRUE to enable automatic resolving aliased parents
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setAutoResolve( $automatic = TRUE )
|
||||
{
|
||||
self::$autoResolve = (boolean) $automatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where the real properties of the bean live. They are stored and retrieved
|
||||
* by the magic getter and setter (__get and __set).
|
||||
@ -195,6 +115,86 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*/
|
||||
protected $all = FALSE;
|
||||
|
||||
/**
|
||||
* Sets the error mode for FUSE.
|
||||
* What to do if a FUSE model method does not exist?
|
||||
* You can set the following options:
|
||||
*
|
||||
* * OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL
|
||||
* * OODBBean::C_ERR_LOG, logs the incident using error_log
|
||||
* * OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE
|
||||
* * OODBBean::C_ERR_WARN, triggers a E_USER_WARNING
|
||||
* * OODBBean::C_ERR_EXCEPTION, throws an exception
|
||||
* * OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function)
|
||||
* * OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR
|
||||
*
|
||||
* <code>
|
||||
* Custom handler method signature: handler( array (
|
||||
* 'message' => string
|
||||
* 'bean' => OODBBean
|
||||
* 'method' => string
|
||||
* ) )
|
||||
* </code>
|
||||
*
|
||||
* This method returns the old mode and handler as an array.
|
||||
*
|
||||
* @param integer $mode error handling mode
|
||||
* @param callable|NULL $func custom handler
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setErrorHandlingFUSE($mode, $func = NULL) {
|
||||
if (
|
||||
$mode !== self::C_ERR_IGNORE
|
||||
&& $mode !== self::C_ERR_LOG
|
||||
&& $mode !== self::C_ERR_NOTICE
|
||||
&& $mode !== self::C_ERR_WARN
|
||||
&& $mode !== self::C_ERR_EXCEPTION
|
||||
&& $mode !== self::C_ERR_FUNC
|
||||
&& $mode !== self::C_ERR_FATAL
|
||||
) throw new \Exception( 'Invalid error mode selected' );
|
||||
|
||||
if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) {
|
||||
throw new \Exception( 'Invalid error handler' );
|
||||
}
|
||||
|
||||
$old = array( self::$errorHandlingFUSE, self::$errorHandler );
|
||||
self::$errorHandlingFUSE = $mode;
|
||||
if ( is_callable( $func ) ) {
|
||||
self::$errorHandler = $func;
|
||||
} else {
|
||||
self::$errorHandler = NULL;
|
||||
}
|
||||
return $old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets global aliases.
|
||||
*
|
||||
* @param array $list list of global aliases to use
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function aliases( $list )
|
||||
{
|
||||
self::$aliases = $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables auto-resolving fetch types.
|
||||
* Auto-resolving aliased parent beans is convenient but can
|
||||
* be slower and can create infinite recursion if you
|
||||
* used aliases to break cyclic relations in your domain.
|
||||
*
|
||||
* @param boolean $automatic TRUE to enable automatic resolving aliased parents
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setAutoResolve( $automatic = TRUE )
|
||||
{
|
||||
self::$autoResolve = (boolean) $automatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a meta property for all beans. This is a quicker way to set
|
||||
* the meta properties for a collection of beans because this method
|
||||
@ -232,7 +232,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* @param string $type the source type for the join
|
||||
*
|
||||
* @return string $joinSql
|
||||
* @return string
|
||||
*/
|
||||
private function parseJoin( $type )
|
||||
{
|
||||
@ -357,7 +357,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* use the OODB object to dispense new beans. You can use this method
|
||||
* if you build your own bean dispensing mechanism.
|
||||
*
|
||||
* @param string $type type of the new bean
|
||||
* @param string $type type of the new bean
|
||||
* @param BeanHelper $beanhelper bean helper to obtain a toolbox and a model
|
||||
*
|
||||
* @return void
|
||||
@ -380,7 +380,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* nested beans (bean lists: ownBean, sharedBean) without the need to
|
||||
* rely on static calls to the facade (or make this class dep. on OODB).
|
||||
*
|
||||
* @param BeanHelper $helper
|
||||
* @param BeanHelper $helper helper to use for this bean
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -390,7 +390,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an\ArrayIterator so you can treat the bean like
|
||||
* Returns an ArrayIterator so you can treat the bean like
|
||||
* an array with the properties container as its contents.
|
||||
* This method is meant for PHP and allows you to access beans as if
|
||||
* they were arrays, i.e. using array notation:
|
||||
@ -399,11 +399,11 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Note that not all PHP functions work with the array interface.
|
||||
*
|
||||
* @return \ArrayIterator
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new\ArrayIterator( $this->properties );
|
||||
return new \ArrayIterator( $this->properties );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -600,7 +600,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* Unsets a property of a bean.
|
||||
* Magic method, gets called implicitly when performing the unset() operation
|
||||
* on a bean property.
|
||||
*
|
||||
*
|
||||
* @param string $property property to unset
|
||||
*
|
||||
* @return void
|
||||
@ -636,13 +636,15 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* issue the following command: $book->ownPage
|
||||
* However, to order these pages by number use:
|
||||
*
|
||||
* <code>
|
||||
* $book->with(' ORDER BY `number` ASC ')->ownPage
|
||||
* </code>
|
||||
*
|
||||
* the additional SQL snippet will be merged into the final
|
||||
* query.
|
||||
*
|
||||
* @param string $sql SQL to be added to retrieval query.
|
||||
* @param array $bindings array with parameters to bind to SQL snippet
|
||||
* @param string $sql SQL to be added to retrieval query.
|
||||
* @param array $bindings array with parameters to bind to SQL snippet
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -682,8 +684,10 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* $bean->with( ' LIMIT 3 ' )->ownPage; //Just 3
|
||||
* $bean->all()->ownPage; //Reload all pages
|
||||
* </code>
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@ -713,16 +717,22 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* case, so to the project has a teacher_id pointing to a person, and a student_id
|
||||
* also pointing to a person. Given a project, we obtain the teacher like this:
|
||||
*
|
||||
* <code>
|
||||
* $project->fetchAs('person')->teacher;
|
||||
* </code>
|
||||
*
|
||||
* Now, if we want all projects of a teacher we cant say:
|
||||
*
|
||||
* <code>
|
||||
* $teacher->ownProject
|
||||
* </code>
|
||||
*
|
||||
* because the $teacher is a bean of type 'person' and no project has been
|
||||
* assigned to a person. Instead we use the alias() method like this:
|
||||
*
|
||||
* <code>
|
||||
* $teacher->alias('teacher')->ownProject
|
||||
* </code>
|
||||
*
|
||||
* now we get the projects associated with the person bean aliased as
|
||||
* a teacher.
|
||||
@ -770,12 +780,13 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* Turns a camelcase property name into an underscored property name.
|
||||
*
|
||||
* Examples:
|
||||
* oneACLRoute -> one_acl_route
|
||||
* camelCase -> camel_case
|
||||
*
|
||||
* * oneACLRoute -> one_acl_route
|
||||
* * camelCase -> camel_case
|
||||
*
|
||||
* Also caches the result to improve performance.
|
||||
*
|
||||
* @param string $property
|
||||
* @param string $property property to un-beautify
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -911,7 +922,6 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
return $this->properties[$property];
|
||||
}
|
||||
|
||||
|
||||
list( $redbean, , , $toolbox ) = $this->beanHelper->getExtractedToolbox();
|
||||
|
||||
if ( isset( $this->$fieldLink ) ) {
|
||||
@ -989,8 +999,6 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* @param mixed $value the value you want to assign
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
public function __set( $property, $value )
|
||||
{
|
||||
@ -1101,12 +1109,14 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* $bean->setMeta( 'flush-cache', TRUE );
|
||||
* </code>
|
||||
*
|
||||
* RedBeanPHP also stores meta data in beans, this meta data uses
|
||||
* keys prefixed with 'sys.' (system).
|
||||
*
|
||||
* @param string $path path
|
||||
* @param string $path path to property in meta data
|
||||
* @param mixed $default default value
|
||||
*
|
||||
* @return mixed
|
||||
@ -1122,7 +1132,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* This is a short-cut method that can be used instead
|
||||
* of combining a get/unset.
|
||||
*
|
||||
* @param string $path path
|
||||
* @param string $path path to property in meta data
|
||||
* @param mixed $default default value
|
||||
*
|
||||
* @return mixed
|
||||
@ -1161,7 +1171,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* This is a convenience method to enable you to
|
||||
* exchange meta information easily.
|
||||
*
|
||||
* @param OODBBean $bean
|
||||
* @param OODBBean $bean bean to copy meta data of
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -1338,7 +1348,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* For polymorphic bean relations.
|
||||
* Same as fetchAs but uses a column instead of a direct value.
|
||||
*
|
||||
* @param string $column
|
||||
* @param string $field field name to use for mapping
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -1354,10 +1364,12 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Can be used together with with, withCondition, alias and fetchAs.
|
||||
*
|
||||
* @param string $property property
|
||||
* @param closure $function function
|
||||
* @param string $property property
|
||||
* @param callable $function function
|
||||
* @param integer $maxDepth maximum depth for traversal
|
||||
*
|
||||
* @return OODBBean
|
||||
* @throws RedException
|
||||
*/
|
||||
public function traverse( $property, $function, $maxDepth = NULL )
|
||||
{
|
||||
@ -1382,7 +1394,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
if ( !is_array( $beans ) ) $beans = array( $beans );
|
||||
|
||||
foreach( $beans as $bean ) {
|
||||
|
||||
/** @var OODBBean $bean */
|
||||
$function( $bean );
|
||||
|
||||
$bean->fetchType = $oldFetchType;
|
||||
@ -1397,7 +1409,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of\Countable interface. Makes it possible to use
|
||||
* Implementation of Countable interface. Makes it possible to use
|
||||
* count() function on a bean.
|
||||
*
|
||||
* @return integer
|
||||
@ -1508,7 +1520,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* it has been stored or not. Storing a bean does not undo it's history,
|
||||
* to clean the history of a bean use: clearHistory().
|
||||
*
|
||||
* @param string $property name of the property you want the change-status of
|
||||
* @param string $property name of the property you want the change-status of
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -1564,11 +1576,15 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <code>
|
||||
* $album->link('track', array('number'=>1))->song = $song;
|
||||
* </code>
|
||||
*
|
||||
* or:
|
||||
*
|
||||
* <code>
|
||||
* $album->link($trackBean)->song = $song;
|
||||
* </code>
|
||||
*
|
||||
* What this method does is adding the link bean to the own-list, in this case
|
||||
* ownTrack. If the first argument is a string and the second is an array or
|
||||
@ -1577,7 +1593,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
* allowing the chained setter: ->song = $song.
|
||||
*
|
||||
* @param string|OODBBean $type type of bean to dispense or the full bean
|
||||
* @param string|array $qualification JSON string or array (optional)
|
||||
* @param string|array $qualification JSON string or array (optional)
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -1609,6 +1625,19 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
return $bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bean of the given type with the same ID of as
|
||||
* the current one. This only happens in a one-to-one relation.
|
||||
* This is as far as support for 1-1 goes in RedBeanPHP. This
|
||||
* method will only return a reference to the bean, changing it
|
||||
* and storing the bean will not update the related one-bean.
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
public function one( $type ) {
|
||||
return $this->beanHelper->getToolBox()->getRedBean()->load( $type, $this->id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the same bean freshly loaded from the database.
|
||||
*
|
||||
@ -1708,7 +1737,7 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
$count = 0;
|
||||
|
||||
if ( $this->getID() ) {
|
||||
$count = $redbean->getAssociationManager()->relatedCount( $this, $type, $this->withSql, $this->withParams, TRUE );
|
||||
$count = $redbean->getAssociationManager()->relatedCount( $this, $type, $this->withSql, $this->withParams );
|
||||
}
|
||||
|
||||
$this->clearModifiers();
|
||||
@ -1727,7 +1756,9 @@ class OODBBean implements\IteratorAggregate,\ArrayAccess,\Countable
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* $quest->aggr( 'xownQuestTarget', 'target', 'quest' );
|
||||
* </code>
|
||||
*
|
||||
* Loads (in batch) and returns references to all
|
||||
* quest beans residing in the $questTarget->target properties
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -31,7 +31,7 @@ abstract class Observable { //bracket must be here - otherwise coverage software
|
||||
* Second argument should be the object that wants to be notified in case
|
||||
* the event occurs.
|
||||
*
|
||||
* @param string $eventname event identifier
|
||||
* @param string $eventname event identifier
|
||||
* @param Observer $observer observer instance
|
||||
*
|
||||
* @return void
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -25,7 +25,7 @@ interface Observer
|
||||
* notifications. Therefore the observer needs to implement the
|
||||
* onEvent method with two parameters: the event identifier specifying the
|
||||
* current event and a message object (in RedBeanPHP this can also be a bean).
|
||||
*
|
||||
*
|
||||
* @param string $eventname event identifier
|
||||
* @param mixed $bean a message sent along with the notification
|
||||
*
|
||||
|
@ -1 +0,0 @@
|
||||
This folder will get mounted in the phar.
|
@ -32,7 +32,7 @@ interface QueryWriter
|
||||
/**
|
||||
* SQL filter constants
|
||||
*/
|
||||
const C_SQLFILTER_READ = 'r';
|
||||
const C_SQLFILTER_READ = 'r';
|
||||
const C_SQLFILTER_WRITE = 'w';
|
||||
|
||||
/**
|
||||
@ -90,9 +90,9 @@ interface QueryWriter
|
||||
*
|
||||
* The GLUE type determines the prefix:
|
||||
*
|
||||
* - NONE prefixes with WHERE
|
||||
* - WHERE prefixes with WHERE and replaces AND if snippets starts with AND
|
||||
* - AND prefixes with AND
|
||||
* * NONE prefixes with WHERE
|
||||
* * WHERE prefixes with WHERE and replaces AND if snippets starts with AND
|
||||
* * AND prefixes with AND
|
||||
*
|
||||
* This method will never replace WHERE with AND since a snippet should never
|
||||
* begin with WHERE in the first place. OR is not supported.
|
||||
@ -104,8 +104,8 @@ interface QueryWriter
|
||||
* @note A default implementation is available in AQueryWriter
|
||||
* unless a database uses very different SQL this should suffice.
|
||||
*
|
||||
* @param string $sql SQL Snippet
|
||||
* @param integer $glue the GLUE type - how to glue (C_GLUE_WHERE or C_GLUE_AND)
|
||||
* @param string $sql SQL Snippet
|
||||
* @param integer $glue the GLUE type - how to glue (C_GLUE_WHERE or C_GLUE_AND)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -196,9 +196,9 @@ interface QueryWriter
|
||||
* This method will widen the column to the specified data type.
|
||||
* This methods accepts a type and infers the corresponding table name.
|
||||
*
|
||||
* @param string $type type / table that needs to be adjusted
|
||||
* @param string $column column that needs to be altered
|
||||
* @param integer $datatype target data type
|
||||
* @param string $type type / table that needs to be adjusted
|
||||
* @param string $column column that needs to be altered
|
||||
* @param integer $datatype target data type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -309,9 +309,9 @@ interface QueryWriter
|
||||
* Returns the new ID.
|
||||
* This methods accepts a type and infers the corresponding table name.
|
||||
*
|
||||
* @param string $type name of the table to update
|
||||
* @param array $updatevalues list of update values
|
||||
* @param integer $id optional primary key ID value
|
||||
* @param string $type name of the table to update
|
||||
* @param array $updatevalues list of update values
|
||||
* @param integer $id optional primary key ID value
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
@ -350,7 +350,7 @@ interface QueryWriter
|
||||
* This method will add a UNIQUE constraint index to a table on columns $columns.
|
||||
* This methods accepts a type and infers the corresponding table name.
|
||||
*
|
||||
* @param string $type type
|
||||
* @param string $type target bean type
|
||||
* @param array $columnsPartOfIndex columns to include in index
|
||||
*
|
||||
* @return void
|
||||
@ -364,8 +364,8 @@ interface QueryWriter
|
||||
* a one of the constants defined in this class and then check whether it is in the list
|
||||
* of standard states provided.
|
||||
*
|
||||
* @param string $state sql state
|
||||
* @param array $list list
|
||||
* @param string $state SQL state to consider
|
||||
* @param array $list list of standardized SQL state constants to check against
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -439,11 +439,15 @@ interface QueryWriter
|
||||
* Renames an association. For instance if you would like to refer to
|
||||
* album_song as: track you can specify this by calling this method like:
|
||||
*
|
||||
* <code>
|
||||
* renameAssociation('album_song','track')
|
||||
* </code>
|
||||
*
|
||||
* This allows:
|
||||
*
|
||||
* <code>
|
||||
* $album->sharedSong
|
||||
* </code>
|
||||
*
|
||||
* to add/retrieve beans from track instead of album_song.
|
||||
* Also works for exportAll().
|
||||
@ -451,8 +455,8 @@ interface QueryWriter
|
||||
* This method also accepts a single associative array as
|
||||
* its first argument.
|
||||
*
|
||||
* @param string|array $fromType
|
||||
* @param string $toType (optional)
|
||||
* @param string|array $fromType original type name, or array
|
||||
* @param string $toType new type name (only if 1st argument is string)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -474,7 +478,7 @@ interface QueryWriter
|
||||
/**
|
||||
* Given a bean type and a property, this method
|
||||
* tries to infer the fetch type using the foreign key
|
||||
* definitions in the database.
|
||||
* definitions in the database.
|
||||
* For instance: project, student -> person.
|
||||
* If no fetchType can be inferred, this method will return NULL.
|
||||
*
|
||||
|
@ -123,7 +123,7 @@ abstract class AQueryWriter
|
||||
* Globally available service method for RedBeanPHP.
|
||||
* Converts a camel cased string to a snake cased string.
|
||||
*
|
||||
* @param string $camel a camelCased string
|
||||
* @param string $camel camelCased string to converty to snake case
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -172,6 +172,7 @@ abstract class AQueryWriter
|
||||
* This is a lowlevel method to set the SQL filter array.
|
||||
* The format of this array is:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* '<MODE, i.e. 'r' for read, 'w' for write>' => array(
|
||||
* '<TABLE NAME>' => array(
|
||||
@ -179,22 +180,27 @@ abstract class AQueryWriter
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* QueryWriter::C_SQLFILTER_READ => array(
|
||||
* QueryWriter::C_SQLFILTER_READ => array(
|
||||
* 'book' => array(
|
||||
* 'title' => ' LOWER(book.title) '
|
||||
* )
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* Note that you can use constants instead of magical chars
|
||||
* as keys for the uppermost array.
|
||||
* This is a lowlevel method. For a more friendly method
|
||||
* please take a look at the facade: R::bindFunc().
|
||||
*
|
||||
* @param array
|
||||
* @param array list of filters to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setSQLFilters( $sqlFilters, $safeMode = false )
|
||||
{
|
||||
@ -284,7 +290,7 @@ abstract class AQueryWriter
|
||||
* improve caching efficiency (issue #400).
|
||||
*
|
||||
* @param string $cacheTag cache tag (secondary key)
|
||||
* @param string $key key
|
||||
* @param string $key key to store values under
|
||||
* @param array $values content to be stored
|
||||
*
|
||||
* @return void
|
||||
@ -303,15 +309,17 @@ abstract class AQueryWriter
|
||||
/**
|
||||
* Creates an SQL snippet from a list of conditions of format:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* key => array(
|
||||
* value1, value2, value3 ....
|
||||
* )
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param array $conditions list of conditions
|
||||
* @param array $bindings parameter bindings for SQL snippet
|
||||
* @param string $addSql SQL snippet
|
||||
* @param string $addSql additional SQL snippet to append to result
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -434,6 +442,7 @@ abstract class AQueryWriter
|
||||
* A foreign key map describes the foreign keys in a table.
|
||||
* A FKM always has the same structure:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'name' => <name of the foreign key>
|
||||
* 'from' => <name of the column on the source table>
|
||||
@ -442,6 +451,7 @@ abstract class AQueryWriter
|
||||
* 'on_update' => <update rule: 'SET NULL','CASCADE' or 'RESTRICT'>
|
||||
* 'on_delete' => <delete rule: 'SET NULL','CASCADE' or 'RESTRICT'>
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @note the keys in the result array are FKDLs, i.e. descriptive unique
|
||||
* keys per source table. Also see: AQueryWriter::makeFKLabel for details.
|
||||
@ -510,9 +520,9 @@ abstract class AQueryWriter
|
||||
* If you pass an offset the bindings will be re-added to the value list.
|
||||
* Some databases cant handle duplicate parameter names in queries.
|
||||
*
|
||||
* @param array &$valueList list of values to generate slots for (gets modified if needed)
|
||||
* @param array $otherBindings list of additional bindings
|
||||
* @param integer $offset start counter at...
|
||||
* @param array &$valueList list of values to generate slots for (gets modified if needed)
|
||||
* @param array $otherBindings list of additional bindings
|
||||
* @param integer $offset start counter at...
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -648,8 +658,6 @@ abstract class AQueryWriter
|
||||
* @param string $table table string
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
protected function check( $struct )
|
||||
{
|
||||
@ -712,7 +720,7 @@ abstract class AQueryWriter
|
||||
*/
|
||||
public function glueLimitOne( $sql = '')
|
||||
{
|
||||
return ( strpos( $sql, 'LIMIT' ) === FALSE ) ? ( $sql . ' LIMIT 1 ' ) : $sql;
|
||||
return ( strpos( strtoupper( $sql ), 'LIMIT' ) === FALSE ) ? ( $sql . ' LIMIT 1 ' ) : $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -832,7 +840,6 @@ abstract class AQueryWriter
|
||||
|
||||
$rows = $this->adapter->get( $sql, $bindings );
|
||||
|
||||
|
||||
if ( $this->flagUseCache && $key ) {
|
||||
$this->putResultInCache( $type, $key, $rows );
|
||||
}
|
||||
@ -1107,6 +1114,8 @@ abstract class AQueryWriter
|
||||
* use a result row cache.
|
||||
*
|
||||
* @param boolean
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseCache( $yesNo )
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP\QueryWriter;
|
||||
namespace RedBeanPHP\QueryWriter;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\Adapter as Adapter;
|
||||
use RedBeanPHP\Adapter as Adapter;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
|
||||
/**
|
||||
@ -52,13 +52,13 @@ class CUBRID extends AQueryWriter implements QueryWriter
|
||||
* later on.
|
||||
* This methods accepts a type and infers the corresponding table name.
|
||||
*
|
||||
* @param string $type type that will have a foreign key field
|
||||
* @param string $targetType points to this type
|
||||
* @param string $property field that contains the foreign key value
|
||||
* @param string $targetProperty field where the fk points to
|
||||
* @param bool $isDep
|
||||
*
|
||||
* @param string $type type that will have a foreign key field
|
||||
* @param string $targetType points to this type
|
||||
* @param string $field field that contains the foreign key value
|
||||
* @param string $targetField field where the fk points to
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
protected function buildFK( $type, $targetType, $property, $targetProperty, $isDep = FALSE )
|
||||
{
|
||||
@ -137,7 +137,7 @@ class CUBRID extends AQueryWriter implements QueryWriter
|
||||
* This method returns the datatype to be used for primary key IDS and
|
||||
* foreign keys. Returns one if the data type constants.
|
||||
*
|
||||
* @return integer $const data type to be used for IDS.
|
||||
* @return integer
|
||||
*/
|
||||
public function getTypeForID()
|
||||
{
|
||||
@ -340,9 +340,9 @@ class CUBRID extends AQueryWriter implements QueryWriter
|
||||
$table = $this->esc( $type, TRUE );
|
||||
$field = $this->esc( $property, TRUE ) . '_id';
|
||||
$keys = $this->getKeyMapForType( $table );
|
||||
|
||||
|
||||
foreach( $keys as $key ) {
|
||||
if (
|
||||
if (
|
||||
$key['from'] === $field
|
||||
) return $key['table'];
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
const C_DATATYPE_SPECIAL_POINT = 90;
|
||||
const C_DATATYPE_SPECIAL_LINESTRING = 91;
|
||||
const C_DATATYPE_SPECIAL_POLYGON = 92;
|
||||
const C_DATATYPE_SPECIAL_MONEY = 93;
|
||||
|
||||
const C_DATATYPE_SPECIFIED = 99;
|
||||
|
||||
@ -57,6 +58,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
*/
|
||||
protected function getKeyMapForType( $type )
|
||||
{
|
||||
$databaseName = $this->adapter->getCell('SELECT DATABASE()');
|
||||
$table = $this->esc( $type, TRUE );
|
||||
$keys = $this->adapter->get('
|
||||
SELECT
|
||||
@ -68,17 +70,15 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
information_schema.referential_constraints.delete_rule AS `on_delete`
|
||||
FROM information_schema.key_column_usage
|
||||
INNER JOIN information_schema.referential_constraints
|
||||
ON (
|
||||
information_schema.referential_constraints.constraint_name = information_schema.key_column_usage.constraint_name
|
||||
AND information_schema.referential_constraints.constraint_schema = information_schema.key_column_usage.constraint_schema
|
||||
AND information_schema.referential_constraints.constraint_catalog = information_schema.key_column_usage.constraint_catalog
|
||||
)
|
||||
ON information_schema.referential_constraints.constraint_name = information_schema.key_column_usage.constraint_name
|
||||
WHERE
|
||||
information_schema.key_column_usage.table_schema IN ( SELECT DATABASE() )
|
||||
AND information_schema.key_column_usage.table_name = ?
|
||||
information_schema.key_column_usage.table_schema = :database
|
||||
AND information_schema.referential_constraints.constraint_schema = :database
|
||||
AND information_schema.key_column_usage.constraint_schema = :database
|
||||
AND information_schema.key_column_usage.table_name = :table
|
||||
AND information_schema.key_column_usage.constraint_name != \'PRIMARY\'
|
||||
AND information_schema.key_column_usage.referenced_table_name IS NOT NULL
|
||||
', array($table));
|
||||
', array( ':database' => $databaseName, ':table' => $table ) );
|
||||
$keyInfoList = array();
|
||||
foreach ( $keys as $k ) {
|
||||
$label = $this->makeFKLabel( $k['from'], $k['table'], $k['to'] );
|
||||
@ -114,6 +114,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
MySQL::C_DATATYPE_SPECIAL_POINT => ' POINT ',
|
||||
MySQL::C_DATATYPE_SPECIAL_LINESTRING => ' LINESTRING ',
|
||||
MySQL::C_DATATYPE_SPECIAL_POLYGON => ' POLYGON ',
|
||||
MySQL::C_DATATYPE_SPECIAL_MONEY => ' DECIMAL(10,2) '
|
||||
);
|
||||
|
||||
$this->sqltype_typeno = array();
|
||||
@ -131,7 +132,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
* This method returns the datatype to be used for primary key IDS and
|
||||
* foreign keys. Returns one if the data type constants.
|
||||
*
|
||||
* @return integer $const data type to be used for IDS.
|
||||
* @return integer
|
||||
*/
|
||||
public function getTypeForID()
|
||||
{
|
||||
@ -185,6 +186,9 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
if ( $value === INF ) return MySQL::C_DATATYPE_TEXT7;
|
||||
|
||||
if ( $flagSpecial ) {
|
||||
if ( preg_match( '/^-?\d+\.\d{2}$/', $value ) ) {
|
||||
return MySQL::C_DATATYPE_SPECIAL_MONEY;
|
||||
}
|
||||
if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) {
|
||||
return MySQL::C_DATATYPE_SPECIAL_DATE;
|
||||
}
|
||||
@ -297,6 +301,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
|
||||
/**
|
||||
* @see QueryWriter::addFK
|
||||
* @return bool
|
||||
*/
|
||||
public function addFK( $type, $targetType, $property, $targetProperty, $isDependent = FALSE )
|
||||
{
|
||||
@ -329,6 +334,7 @@ class MySQL extends AQueryWriter implements QueryWriter
|
||||
} catch ( SQLException $e ) {
|
||||
// Failure of fk-constraints is not a problem
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ class PostgreSQL extends AQueryWriter implements QueryWriter
|
||||
const C_DATATYPE_SPECIAL_CIRCLE = 92;
|
||||
const C_DATATYPE_SPECIAL_MONEY = 93;
|
||||
const C_DATATYPE_SPECIAL_POLYGON = 94;
|
||||
const C_DATATYPE_SPECIAL_MONEY2 = 95; //Numbers only money, i.e. fixed point numeric
|
||||
const C_DATATYPE_SPECIFIED = 99;
|
||||
|
||||
/**
|
||||
@ -136,6 +137,7 @@ class PostgreSQL extends AQueryWriter implements QueryWriter
|
||||
self::C_DATATYPE_SPECIAL_LSEG => ' lseg ',
|
||||
self::C_DATATYPE_SPECIAL_CIRCLE => ' circle ',
|
||||
self::C_DATATYPE_SPECIAL_MONEY => ' money ',
|
||||
self::C_DATATYPE_SPECIAL_MONEY2 => ' numeric(10,2) ',
|
||||
self::C_DATATYPE_SPECIAL_POLYGON => ' polygon ',
|
||||
);
|
||||
|
||||
@ -152,7 +154,7 @@ class PostgreSQL extends AQueryWriter implements QueryWriter
|
||||
* This method returns the datatype to be used for primary key IDS and
|
||||
* foreign keys. Returns one if the data type constants.
|
||||
*
|
||||
* @return integer $const data type to be used for IDS.
|
||||
* @return integer
|
||||
*/
|
||||
public function getTypeForID()
|
||||
{
|
||||
@ -184,7 +186,7 @@ class PostgreSQL extends AQueryWriter implements QueryWriter
|
||||
{
|
||||
$table = $this->esc( $table, TRUE );
|
||||
|
||||
$columnsRaw = $this->adapter->get( "SELECT column_name, data_type FROM information_schema.columns WHERE table_name='$table'" );
|
||||
$columnsRaw = $this->adapter->get( "SELECT column_name, data_type FROM information_schema.columns WHERE table_name='$table' AND table_schema = ANY( current_schemas( FALSE ) )" );
|
||||
|
||||
$columns = array();
|
||||
foreach ( $columnsRaw as $r ) {
|
||||
@ -231,12 +233,16 @@ class PostgreSQL extends AQueryWriter implements QueryWriter
|
||||
if ( preg_match( '/^\-?(\$|€|¥|£)[\d,\.]+$/', $value ) ) {
|
||||
return PostgreSQL::C_DATATYPE_SPECIAL_MONEY;
|
||||
}
|
||||
|
||||
if ( preg_match( '/^-?\d+\.\d{2}$/', $value ) ) {
|
||||
return PostgreSQL::C_DATATYPE_SPECIAL_MONEY2;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE;
|
||||
|
||||
if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
|
||||
|
||||
|
||||
if ( $value === FALSE || $value === TRUE || $value === NULL || ( is_numeric( $value )
|
||||
&& AQueryWriter::canBeTreatedAsInt( $value )
|
||||
&& $value < 2147483648
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP\QueryWriter;
|
||||
|
||||
@ -55,7 +55,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
*
|
||||
* @param string $type type you want to get info of
|
||||
*
|
||||
* @return array $info
|
||||
* @return array
|
||||
*/
|
||||
protected function getTable( $type )
|
||||
{
|
||||
@ -83,6 +83,8 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
* then store it with putTable()...
|
||||
*
|
||||
* @param array $tableMap information array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function putTable( $tableMap )
|
||||
{
|
||||
@ -131,11 +133,11 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the indexes for type $type.
|
||||
* Returns the an array describing the indexes for type $type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $type type to describe indexes of
|
||||
*
|
||||
* @return array $indexInfo index information
|
||||
* @return array
|
||||
*/
|
||||
protected function getIndexes( $type )
|
||||
{
|
||||
@ -153,7 +155,9 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a foreign key to a type
|
||||
* Adds a foreign key to a type.
|
||||
* Note: cant put this in try-catch because that can hide the fact
|
||||
* that database has been damaged.
|
||||
*
|
||||
* @param string $type type you want to modify table of
|
||||
* @param string $targetType target type
|
||||
@ -161,10 +165,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
* @param string $targetField field where the fk needs to point to
|
||||
* @param integer $buildopt 0 = NO ACTION, 1 = ON DELETE CASCADE
|
||||
*
|
||||
* @return boolean $didIt
|
||||
*
|
||||
* @note: cant put this in try-catch because that can hide the fact
|
||||
* that database has been damaged.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function buildFK( $type, $targetType, $property, $targetProperty, $constraint = FALSE )
|
||||
{
|
||||
@ -259,7 +260,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT;
|
||||
|
||||
if ( $value === TRUE || $value === FALSE ) return self::C_DATATYPE_INTEGER;
|
||||
|
||||
|
||||
if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) return self::C_DATATYPE_INTEGER;
|
||||
|
||||
if ( ( is_numeric( $value ) && $value < 2147483648 && $value > -2147483648)
|
||||
@ -290,7 +291,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
public function code( $typedescription, $includeSpecials = FALSE )
|
||||
{
|
||||
$r = ( ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : 99 );
|
||||
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
@ -400,7 +401,7 @@ class SQLiteT extends AQueryWriter implements QueryWriter
|
||||
public function wipe( $type )
|
||||
{
|
||||
$table = $this->esc( $type );
|
||||
|
||||
|
||||
$this->adapter->exec( "DELETE FROM $table " );
|
||||
}
|
||||
|
||||
|
@ -16,4 +16,6 @@ namespace RedBeanPHP;
|
||||
* @license BSD/GPLv2
|
||||
*
|
||||
*/
|
||||
class R extends Facade {}
|
||||
class R extends Facade
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class SQL extends RedException
|
||||
/**
|
||||
* Returns an ANSI-92 compliant SQL state.
|
||||
*
|
||||
* @return string $state ANSI state code
|
||||
* @return string
|
||||
*/
|
||||
public function getSQLState()
|
||||
{
|
||||
@ -50,7 +50,7 @@ class SQL extends RedException
|
||||
/**
|
||||
* To String prints both code and SQL state.
|
||||
*
|
||||
* @return string $message prints this exception instance as a string
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
|
@ -2,17 +2,11 @@
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\Observable as Observable;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\BeanHelper\FacadeBeanHelper as FacadeBeanHelper;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\SimpleModel as SimpleModel;
|
||||
use RedBeanPHP\BeanHelper as BeanHelper;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\OODB as OODB;
|
||||
use RedBeanPHP\Cursor as Cursor;
|
||||
use RedBeanPHP\Cursor\NullCursor as NullCursor;
|
||||
|
||||
@ -29,7 +23,7 @@ use RedBeanPHP\Cursor\NullCursor as NullCursor;
|
||||
* @file RedBeanPHP/Repository.php
|
||||
* @author Gabor de Mooij and the RedBeanPHP community
|
||||
* @license BSD/GPLv2
|
||||
*
|
||||
*
|
||||
* @copyright
|
||||
* copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
|
||||
* This source file is subject to the BSD/GPLv2 License that is bundled
|
||||
@ -55,7 +49,7 @@ abstract class Repository
|
||||
/**
|
||||
* Stores a bean and its lists in one run.
|
||||
*
|
||||
* @param OODBBean $bean
|
||||
* @param OODBBean $bean bean to process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -140,8 +134,6 @@ abstract class Repository
|
||||
* @param array $sharedAdditions list with shared additions
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
protected function processSharedAdditions( $bean, $sharedAdditions )
|
||||
{
|
||||
@ -161,8 +153,8 @@ abstract class Repository
|
||||
* checks if there have been any modification to this bean, in that case
|
||||
* the bean is stored once again, otherwise the bean will be left untouched.
|
||||
*
|
||||
* @param OODBBean $bean the bean
|
||||
* @param array $ownresidue list
|
||||
* @param OODBBean $bean bean tor process
|
||||
* @param array $ownresidue list to process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -184,14 +176,13 @@ abstract class Repository
|
||||
* If not, the connection between the bean and the owner bean will be broken by
|
||||
* setting the ID to NULL.
|
||||
*
|
||||
* @param OODBBean $bean the bean
|
||||
* @param array $ownTrashcan list
|
||||
* @param OODBBean $bean bean to process
|
||||
* @param array $ownTrashcan list to process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processTrashcan( $bean, $ownTrashcan )
|
||||
{
|
||||
|
||||
foreach ( $ownTrashcan as $trash ) {
|
||||
|
||||
$myFieldLink = $bean->getMeta( 'type' ) . '_id';
|
||||
@ -210,8 +201,8 @@ abstract class Repository
|
||||
/**
|
||||
* Unassociates the list items in the trashcan.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param array $sharedTrashcan list
|
||||
* @param OODBBean $bean bean to process
|
||||
* @param array $sharedTrashcan list to process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -225,8 +216,8 @@ abstract class Repository
|
||||
/**
|
||||
* Stores all the beans in the residue group.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param array $sharedresidue list
|
||||
* @param OODBBean $bean bean to process
|
||||
* @param array $sharedresidue list to process
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -259,19 +250,20 @@ abstract class Repository
|
||||
return $processLists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts an embedded bean to an ID, removed the bean property and
|
||||
* stores the bean in the embedded beans array.
|
||||
*
|
||||
* @param array $embeddedBeans destination array for embedded bean
|
||||
* @param OODBBean $bean target bean
|
||||
* @param string $property property that contains the embedded bean
|
||||
* @param array $embeddedBeans destination array for embedded bean
|
||||
* @param OODBBean $bean target bean to process
|
||||
* @param string $property property that contains the embedded bean
|
||||
* @param OODBBean $value embedded bean itself
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processEmbeddedBean( &$embeddedBeans, $bean, $property, OODBBean $value )
|
||||
{
|
||||
$linkField = $property . '_id';
|
||||
$linkField = $property . '_id';
|
||||
$id = $this->prepareEmbeddedBean( $value );
|
||||
if ($bean->$linkField != $id) $bean->$linkField = $id;
|
||||
$bean->setMeta( 'cast.' . $linkField, 'id' );
|
||||
@ -279,11 +271,13 @@ abstract class Repository
|
||||
unset( $bean->$property );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor, requires a query writer.
|
||||
* Creates a new instance of the bean respository class.
|
||||
*
|
||||
* @param QueryWriter $writer writer
|
||||
* @param QueryWriter $writer the Query Writer to use for this repository
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( OODB $oodb, QueryWriter $writer )
|
||||
{
|
||||
@ -299,8 +293,6 @@ abstract class Repository
|
||||
* @param OODBBean $bean the bean that needs to be checked
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security $exception
|
||||
*/
|
||||
public function check( OODBBean $bean )
|
||||
{
|
||||
@ -339,10 +331,12 @@ abstract class Repository
|
||||
*
|
||||
* Conditions need to take form:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'PROPERTY' => array( POSSIBLE VALUES... 'John', 'Steve' )
|
||||
* 'PROPERTY' => array( POSSIBLE VALUES... )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* All conditions are glued together using the AND-operator, while all value lists
|
||||
* are glued using IN-operators thus acting as OR-conditions.
|
||||
@ -356,7 +350,6 @@ abstract class Repository
|
||||
* @param array $bindings whether you prefer to use a WHERE clause or not (TRUE = not)
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function find( $type, $conditions = array(), $sql = NULL, $bindings = array() )
|
||||
{
|
||||
@ -512,8 +505,6 @@ abstract class Repository
|
||||
* @param array $bindings parameters to bind to SQL
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function count( $type, $addSQL = '', $bindings = array() )
|
||||
{
|
||||
@ -543,8 +534,6 @@ abstract class Repository
|
||||
* @param OODBBean|SimpleModel $bean bean you want to remove from database
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function trash( $bean )
|
||||
{
|
||||
@ -591,8 +580,6 @@ abstract class Repository
|
||||
* @param string $type type of bean you wish to delete all instances of
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function wipe( $type )
|
||||
{
|
||||
|
@ -3,16 +3,10 @@
|
||||
namespace RedBeanPHP\Repository;
|
||||
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\Observable as Observable;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\BeanHelper\FacadeBeanHelper as FacadeBeanHelper;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\SimpleModel as SimpleModel;
|
||||
use RedBeanPHP\BeanHelper as BeanHelper;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\Repository as Repository;
|
||||
|
||||
/**
|
||||
@ -41,8 +35,6 @@ class Fluid extends Repository
|
||||
* @param string $cast cast identifier
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
private function getTypeFromCast( $cast )
|
||||
{
|
||||
@ -63,8 +55,8 @@ class Fluid extends Repository
|
||||
* Orders the Query Writer to create a table if it does not exist already and
|
||||
* adds a note in the build report about the creation.
|
||||
*
|
||||
* @param OODBBean $bean bean to update report of
|
||||
* @param string $table table to check and create if not exists
|
||||
* @param OODBBean $bean bean to update report of
|
||||
* @param string $table table to check and create if not exists
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -149,12 +141,15 @@ class Fluid extends Repository
|
||||
* adds a foreign key. Also adds a constraint in case the type is
|
||||
* in the dependent list.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param array $ownAdditions list of addition beans in own-list
|
||||
* Note that this method raises a custom exception if the bean
|
||||
* is not an instance of OODBBean. Therefore it does not use
|
||||
* a type hint. This allows the user to take action in case
|
||||
* invalid objects are passed in the list.
|
||||
*
|
||||
* @param OODBBean $bean bean to process
|
||||
* @param array $ownAdditions list of addition beans in own-list
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security
|
||||
*/
|
||||
protected function processAdditions( $bean, $ownAdditions )
|
||||
{
|
||||
@ -217,13 +212,11 @@ class Fluid extends Repository
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles\Exceptions. Suppresses exceptions caused by missing structures.
|
||||
* Handles exceptions. Suppresses exceptions caused by missing structures.
|
||||
*
|
||||
* @param\Exception $exception exception
|
||||
* @param Exception $exception exception
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws\Exception
|
||||
*/
|
||||
protected function handleException( \Exception $exception )
|
||||
{
|
||||
@ -286,10 +279,7 @@ class Fluid extends Repository
|
||||
* @param string $type type of bean you want to load
|
||||
* @param integer $id ID of the bean you want to load
|
||||
*
|
||||
* @throws SQL
|
||||
*
|
||||
* @return OODBBean
|
||||
*
|
||||
*/
|
||||
public function load( $type, $id )
|
||||
{
|
||||
|
@ -3,16 +3,10 @@
|
||||
namespace RedBeanPHP\Repository;
|
||||
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\Observable as Observable;
|
||||
use RedBeanPHP\Adapter\DBAdapter as DBAdapter;
|
||||
use RedBeanPHP\BeanHelper\FacadeBeanHelper as FacadeBeanHelper;
|
||||
use RedBeanPHP\QueryWriter as QueryWriter;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException\Security as Security;
|
||||
use RedBeanPHP\SimpleModel as SimpleModel;
|
||||
use RedBeanPHP\BeanHelper as BeanHelper;
|
||||
use RedBeanPHP\RedException\SQL as SQLException;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
use RedBeanPHP\Repository as Repository;
|
||||
|
||||
/**
|
||||
@ -36,12 +30,11 @@ use RedBeanPHP\Repository as Repository;
|
||||
class Frozen extends Repository
|
||||
{
|
||||
/**
|
||||
* Handles\Exceptions. Suppresses exceptions caused by missing structures.
|
||||
* Handles exceptions. Suppresses exceptions caused by missing structures.
|
||||
*
|
||||
* @param \Exception $exception exception
|
||||
* @param \Exception $exception exception to handle
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function handleException( \Exception $exception )
|
||||
@ -85,12 +78,16 @@ class Frozen extends Repository
|
||||
* adds a foreign key. Also adds a constraint in case the type is
|
||||
* in the dependent list.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param array $ownAdditions list of addition beans in own-list
|
||||
* Note that this method raises a custom exception if the bean
|
||||
* is not an instance of OODBBean. Therefore it does not use
|
||||
* a type hint. This allows the user to take action in case
|
||||
* invalid objects are passed in the list.
|
||||
*
|
||||
* @param OODBBean $bean bean to process
|
||||
* @param array $ownAdditions list of addition beans in own-list
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Security
|
||||
* @throws RedException
|
||||
*/
|
||||
protected function processAdditions( $bean, $ownAdditions )
|
||||
{
|
||||
@ -124,7 +121,7 @@ class Frozen extends Repository
|
||||
* configuration for you.
|
||||
*
|
||||
* @param string $type type of bean you want to dispense
|
||||
* @param string $number number of beans you would like to get
|
||||
* @param int $number number of beans you would like to get
|
||||
* @param boolean $alwaysReturnArray if TRUE always returns the result as an array
|
||||
*
|
||||
* @return OODBBean
|
||||
@ -134,6 +131,7 @@ class Frozen extends Repository
|
||||
$OODBBEAN = defined( 'REDBEAN_OODBBEAN_CLASS' ) ? REDBEAN_OODBBEAN_CLASS : '\RedBeanPHP\OODBBean';
|
||||
$beans = array();
|
||||
for ( $i = 0; $i < $number; $i++ ) {
|
||||
/** @var \RedBeanPHP\OODBBean $bean */
|
||||
$bean = new $OODBBEAN;
|
||||
$bean->initializeForDispense( $type, $this->oodb->getBeanHelper() );
|
||||
$this->oodb->signal( 'dispense', $bean );
|
||||
@ -163,10 +161,8 @@ class Frozen extends Repository
|
||||
* @param string $type type of bean you want to load
|
||||
* @param integer $id ID of the bean you want to load
|
||||
*
|
||||
* @throws SQL
|
||||
*
|
||||
* @return OODBBean
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function load( $type, $id )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -32,7 +32,7 @@ class SimpleModel
|
||||
* Used by FUSE: the ModelHelper class to connect a bean to a model.
|
||||
* This method loads a bean in the model.
|
||||
*
|
||||
* @param OODBBean $bean bean
|
||||
* @param OODBBean $bean bean to load
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -48,7 +48,7 @@ class SimpleModel
|
||||
* @note this method returns a value, not a reference!
|
||||
* To obtain a reference unbox the bean first!
|
||||
*
|
||||
* @param string $prop property
|
||||
* @param string $prop property to get
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -61,8 +61,8 @@ class SimpleModel
|
||||
* Magic Setter.
|
||||
* Sets the value directly as a bean property.
|
||||
*
|
||||
* @param string $prop property
|
||||
* @param mixed $value value
|
||||
* @param string $prop property to set value of
|
||||
* @param mixed $value value to set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -38,7 +38,7 @@ class SimpleModelHelper implements Observer
|
||||
* that belongs to the CRUD bean and this model will take over control from
|
||||
* there.
|
||||
*
|
||||
* @param Observable $observable
|
||||
* @param Observable $observable object to observe
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -65,7 +65,7 @@ class TagManager
|
||||
* Finds a tag bean by it's title.
|
||||
* Internal method.
|
||||
*
|
||||
* @param string $title title
|
||||
* @param string $title title to search for
|
||||
*
|
||||
* @return OODBBean
|
||||
*/
|
||||
@ -87,7 +87,7 @@ class TagManager
|
||||
* The tag manager offers an easy way to quickly implement basic tagging
|
||||
* functionality.
|
||||
*
|
||||
* @param ToolBox $toolbox
|
||||
* @param ToolBox $toolbox toolbox object
|
||||
*/
|
||||
public function __construct( ToolBox $toolbox )
|
||||
{
|
||||
@ -105,13 +105,13 @@ class TagManager
|
||||
* If the third parameter is FALSE this
|
||||
* method will return TRUE if one of the tags matches, FALSE if none
|
||||
* match.
|
||||
*
|
||||
*
|
||||
* Tag list can be either an array with tag names or a comma separated list
|
||||
* of tag names.
|
||||
*
|
||||
* @param OODBBean $bean bean to check for tags
|
||||
* @param array|string $tags list of tags
|
||||
* @param boolean $all whether they must all match or just some
|
||||
* @param OODBBean $bean bean to check for tags
|
||||
* @param array|string $tags list of tags
|
||||
* @param boolean $all whether they must all match or just some
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -132,12 +132,12 @@ class TagManager
|
||||
/**
|
||||
* Removes all sepcified tags from the bean. The tags specified in
|
||||
* the second parameter will no longer be associated with the bean.
|
||||
*
|
||||
*
|
||||
* Tag list can be either an array with tag names or a comma separated list
|
||||
* of tag names.
|
||||
*
|
||||
* @param OODBBean $bean tagged bean
|
||||
* @param array|string $tagList list of tags (names)
|
||||
* @param OODBBean $bean tagged bean
|
||||
* @param array|string $tagList list of tags (names)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -159,19 +159,19 @@ class TagManager
|
||||
* If $tagList is a comma separated list (string) of tags all tags will
|
||||
* be associated with the bean.
|
||||
* You may also pass an array instead of a string.
|
||||
*
|
||||
*
|
||||
* Tag list can be either an array with tag names or a comma separated list
|
||||
* of tag names.
|
||||
*
|
||||
* @param OODBBean $bean bean to be tagged
|
||||
* @param array|string $tagList a list of tags
|
||||
* @param OODBBean $bean bean to be tagged
|
||||
* @param array|string $tagList a list of tags
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tag( OODBBean $bean, $tagList = NULL )
|
||||
{
|
||||
if ( is_null( $tagList ) ) {
|
||||
|
||||
|
||||
$tags = $bean->sharedTag;
|
||||
$foundTags = array();
|
||||
|
||||
@ -193,12 +193,12 @@ class TagManager
|
||||
* If $tagList is a comma separated list of tags all tags will
|
||||
* be associated with the bean.
|
||||
* You may also pass an array instead of a string.
|
||||
*
|
||||
*
|
||||
* Tag list can be either an array with tag names or a comma separated list
|
||||
* of tag names.
|
||||
*
|
||||
* @param OODBBean $bean bean to add tags to
|
||||
* @param array|string $tagList list of tags to add to bean
|
||||
* @param OODBBean $bean bean to add tags to
|
||||
* @param array|string $tagList list of tags to add to bean
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -250,8 +250,8 @@ class TagManager
|
||||
* Tag list can be either an array with tag names or a comma separated list
|
||||
* of tag names.
|
||||
*
|
||||
* @param string $beanType type of bean you are looking for
|
||||
* @param array|string $tagList list of tags to match
|
||||
* @param string $beanType type of bean you are looking for
|
||||
* @param array|string $tagList list of tags to match
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedBeanPHP;
|
||||
|
||||
@ -19,7 +19,7 @@ use RedBeanPHP\Adapter as Adapter;
|
||||
* @file RedBeanPHP/ToolBox.php
|
||||
* @author Gabor de Mooij and the RedBeanPHP community
|
||||
* @license BSD/GPLv2
|
||||
*
|
||||
*
|
||||
* @copyright
|
||||
* copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
|
||||
* This source file is subject to the BSD/GPLv2 License that is bundled
|
||||
@ -51,11 +51,9 @@ class ToolBox
|
||||
* the adapter, the query writer and the core functionality of RedBeanPHP in
|
||||
* OODB.
|
||||
*
|
||||
* @param OODB $oodb Object Database
|
||||
* @param DBAdapter $adapter Adapter
|
||||
* @param QueryWriter $writer Writer
|
||||
*
|
||||
* @return ToolBox
|
||||
* @param OODB $oodb Object Database, OODB
|
||||
* @param DBAdapter $adapter Database Adapter
|
||||
* @param QueryWriter $writer Query Writer
|
||||
*/
|
||||
public function __construct( OODB $oodb, Adapter $adapter, QueryWriter $writer )
|
||||
{
|
||||
@ -80,7 +78,7 @@ class ToolBox
|
||||
|
||||
/**
|
||||
* Returns the OODB instance in this toolbox.
|
||||
* OODB is responsible for creating, storing, retrieving and deleting
|
||||
* OODB is responsible for creating, storing, retrieving and deleting
|
||||
* single beans. Other components rely
|
||||
* on OODB for their basic functionality.
|
||||
*
|
||||
@ -95,7 +93,7 @@ class ToolBox
|
||||
* Returns the database adapter in this toolbox.
|
||||
* The adapter is responsible for executing the query and binding the values.
|
||||
* The adapter also takes care of transaction handling.
|
||||
*
|
||||
*
|
||||
* @return DBAdapter
|
||||
*/
|
||||
public function getDatabaseAdapter()
|
||||
|
@ -59,6 +59,13 @@ require( REDBEANPHP_MAIN_DIR . 'DuplicationManager.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Plugin.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Functions.php' );
|
||||
|
||||
/* Facade Utilities */
|
||||
require( REDBEANPHP_MAIN_DIR . 'Util/ArrayTool.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Util/DispenseHelper.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Util/Dump.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Util/MultiLoader.php' );
|
||||
require( REDBEANPHP_MAIN_DIR . 'Util/Transaction.php' );
|
||||
|
||||
//Allow users to mount the plugin folder.
|
||||
if ( defined( 'REDBEANPHP_PLUGINS' ) ) {
|
||||
Phar::mount( 'RedBeanPHP/Plugin', REDBEANPHP_PLUGINS );
|
||||
|
15
server/vendor/gabordemooij/redbean/replica2.php
vendored
15
server/vendor/gabordemooij/redbean/replica2.php
vendored
@ -40,7 +40,7 @@ if ($mode !== 'onlyphar') {
|
||||
|
||||
function addFile($file) {
|
||||
global $code;
|
||||
echo 'Added '. $file . ' to package... '.PHP_EOL;
|
||||
echo 'Added ', $file , ' to package... ',PHP_EOL;
|
||||
$raw = file_get_contents($file);
|
||||
$raw = preg_replace('/namespace\s+([a-zA-Z0-9\\\;]+);/m', 'namespace $1 {', $raw);
|
||||
$raw .= '}';
|
||||
@ -85,6 +85,11 @@ if ($mode !== 'onlyphar') {
|
||||
addFile( DIR . 'LabelMaker.php' );
|
||||
addFile( DIR . 'Facade.php' );
|
||||
addFile( DIR . 'DuplicationManager.php' );
|
||||
addFile( DIR . 'Util/ArrayTool.php' );
|
||||
addFile( DIR . 'Util/DispenseHelper.php' );
|
||||
addFile( DIR . 'Util/Dump.php' );
|
||||
addFile( DIR . 'Util/MultiLoader.php' );
|
||||
addFile( DIR . 'Util/Transaction.php' );
|
||||
addFile( DIR . 'Plugin.php' );
|
||||
|
||||
$func = file_get_contents(DIR . 'Functions.php');
|
||||
@ -106,16 +111,16 @@ if ($mode !== 'onlyphar') {
|
||||
|
||||
$code = '<?php'.str_replace('<?php', '', $code);
|
||||
|
||||
echo 'Okay, seems we have all the code.. now writing file: rb.php' .PHP_EOL;
|
||||
echo 'Okay, seems we have all the code.. now writing file: rb.php' ,PHP_EOL;
|
||||
|
||||
$b = file_put_contents('rb.php', $code);
|
||||
|
||||
echo 'Written: '.$b.' bytes.'.PHP_EOL;
|
||||
echo 'Written: ',$b,' bytes.',PHP_EOL;
|
||||
|
||||
if ($b > 0) {
|
||||
echo 'Done!' .PHP_EOL;
|
||||
echo 'Done!' ,PHP_EOL;
|
||||
} else {
|
||||
echo 'Hm, something seems to have gone wrong... '.PHP_EOL;
|
||||
echo 'Hm, something seems to have gone wrong... ',PHP_EOL;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,11 @@ use RedBeanPHP\Facade as R;
|
||||
*/
|
||||
abstract class RedUNIT
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
protected $round;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -35,7 +40,7 @@ abstract class RedUNIT
|
||||
public function prepare()
|
||||
{
|
||||
R::freeze( FALSE );
|
||||
|
||||
|
||||
R::debug( FALSE );
|
||||
|
||||
R::nuke();
|
||||
@ -86,4 +91,34 @@ abstract class RedUNIT
|
||||
{
|
||||
$this->currentlyActiveDriverID = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the round number.
|
||||
*
|
||||
* @param integer $roundNumber round
|
||||
*/
|
||||
public function setRound( $roundNumber )
|
||||
{
|
||||
$this->round = (int) $roundNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current round number
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRound()
|
||||
{
|
||||
return $this->round;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the current round is the first round.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isFirstRound()
|
||||
{
|
||||
return ( $this->round === 0 );
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,8 @@ class Aliasing extends Base
|
||||
list( $teacher, $student ) = R::dispense( 'person', 2 ) ;
|
||||
$teacher->name = 'jimmy' ;
|
||||
$student->name = 'jacko' ;
|
||||
R::store( $teacher, $student ) ;
|
||||
R::store( $teacher ) ;
|
||||
R::store( $student ) ;
|
||||
|
||||
$client = R::dispense( 'client' ) ;
|
||||
$client->firm = 'bean AG' ;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedUNIT\Base;
|
||||
|
||||
@ -21,11 +21,11 @@ class Arrays extends Base
|
||||
{
|
||||
/**
|
||||
* Tests basic array access.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArrayAccess() {
|
||||
|
||||
|
||||
$bean = R::dispense('bean');
|
||||
$bean->name = 'bean';
|
||||
$bean->taste = 'salty';
|
||||
@ -38,7 +38,7 @@ class Arrays extends Base
|
||||
asrt( isset( $properties['id'] ), TRUE );
|
||||
asrt( isset( $properties['name'] ), TRUE );
|
||||
asrt( isset( $properties['taste'] ), TRUE );
|
||||
|
||||
|
||||
$bean = R::dispense('bean');
|
||||
$bean['name'] = 'bean';
|
||||
$bean['taste'] = 'salty';
|
||||
@ -52,30 +52,30 @@ class Arrays extends Base
|
||||
asrt( isset( $properties['name'] ), TRUE );
|
||||
asrt( isset( $properties['taste'] ), TRUE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests array access with lists.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArrayAccessAndLists()
|
||||
{
|
||||
$book = R::dispense('book');
|
||||
$book['title'] = 'My Book';
|
||||
|
||||
|
||||
//Can we add a bean in list with array access?
|
||||
$book['ownPage'][] = R::dispense('page');
|
||||
$book['ownPage'][] = R::dispense('page');
|
||||
|
||||
|
||||
asrt( count( $book ), 3 );
|
||||
|
||||
|
||||
$properties = array();
|
||||
foreach($book as $key => $value) {
|
||||
$properties[ $key ] = $value;
|
||||
}
|
||||
|
||||
|
||||
asrt( count( $properties ), 3 );
|
||||
|
||||
|
||||
//Dont reveal aliased x-own and -List in foreach-loop
|
||||
asrt( isset( $properties['id'] ), TRUE );
|
||||
asrt( isset( $properties['title'] ), TRUE );
|
||||
@ -83,13 +83,13 @@ class Arrays extends Base
|
||||
asrt( isset( $properties['ownPageList'] ), FALSE );
|
||||
asrt( isset( $properties['xownPage'] ), FALSE );
|
||||
asrt( isset( $properties['xownPageList'] ), FALSE );
|
||||
|
||||
|
||||
//But keep them countable
|
||||
asrt( count( $book['ownPage'] ), 2 );
|
||||
asrt( count( $book['ownPageList'] ), 2 );
|
||||
asrt( count( $book['xownPage'] ), 2 );
|
||||
asrt( count( $book['xownPageList'] ), 2 );
|
||||
|
||||
|
||||
//And reveal them with isset()
|
||||
asrt( isset( $book['id'] ), TRUE );
|
||||
asrt( isset( $book['title'] ), TRUE );
|
||||
@ -97,21 +97,21 @@ class Arrays extends Base
|
||||
asrt( isset( $book['ownPageList'] ), TRUE );
|
||||
asrt( isset( $book['xownPage'] ), TRUE );
|
||||
asrt( isset( $book['xownPageList'] ), TRUE );
|
||||
|
||||
|
||||
//Can we add using the List alias?
|
||||
$book['ownPageList'][] = R::dispense('page');
|
||||
asrt( count( $book['ownPage'] ), 3 );
|
||||
asrt( count( $book['ownPageList'] ), 3 );
|
||||
asrt( count( $book['xownPage'] ), 3 );
|
||||
asrt( count( $book['xownPageList'] ), 3 );
|
||||
|
||||
|
||||
//Can we add using the x-mode alias?
|
||||
$book['ownPageList'][] = R::dispense('page');
|
||||
asrt( count( $book['ownPage'] ), 4 );
|
||||
asrt( count( $book['ownPageList'] ), 4 );
|
||||
asrt( count( $book['xownPage'] ), 4 );
|
||||
asrt( count( $book['xownPageList'] ), 4 );
|
||||
|
||||
|
||||
//Can we unset using array access?
|
||||
unset( $book['ownPage'] );
|
||||
asrt( isset( $book['ownPage'] ), FALSE );
|
||||
@ -136,39 +136,39 @@ class Arrays extends Base
|
||||
asrt( isset( $book['ownPageList'] ), FALSE );
|
||||
asrt( isset( $book['xownPage'] ), FALSE );
|
||||
asrt( isset( $book['xownPageList'] ), FALSE );
|
||||
|
||||
|
||||
//does it work with shared lists as well?
|
||||
$book['sharedCategory'] = array( R::dispense('category') );
|
||||
asrt( count( $book ), 3 );
|
||||
|
||||
|
||||
$properties = array();
|
||||
foreach($book as $key => $value) {
|
||||
$properties[ $key ] = $value;
|
||||
}
|
||||
|
||||
|
||||
asrt( isset( $properties['sharedCategory'] ), TRUE );
|
||||
asrt( isset( $properties['sharedCategoryList'] ), FALSE );
|
||||
|
||||
|
||||
asrt( isset( $book['sharedCategory'] ), TRUE );
|
||||
asrt( isset( $book['sharedCategoryList'] ), TRUE );
|
||||
|
||||
|
||||
asrt( count( $book['sharedCategory'] ), 1 );
|
||||
asrt( count( $book['sharedCategoryList'] ), 1 );
|
||||
|
||||
|
||||
$book['sharedCategory'][] = R::dispense( 'category' );
|
||||
|
||||
|
||||
asrt( count( $book['sharedCategory'] ), 2 );
|
||||
asrt( count( $book['sharedCategoryList'] ), 2 );
|
||||
|
||||
|
||||
$book['sharedCategoryList'][] = R::dispense( 'category' );
|
||||
|
||||
|
||||
asrt( count( $book['sharedCategory'] ), 3 );
|
||||
asrt( count( $book['sharedCategoryList'] ), 3 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests array access with parent beans.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArrayAccessWithBeans()
|
||||
@ -194,10 +194,10 @@ class Arrays extends Base
|
||||
asrt( isset( $book['author'] ), FALSE );
|
||||
asrt( count( $book ), 1 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests array access with CRUD operations.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testArrayAccessWithCRUD()
|
||||
@ -206,7 +206,7 @@ class Arrays extends Base
|
||||
$book = R::dispense( 'book' );
|
||||
$book['ownPageList'] = R::dispense( 'page', 3 );
|
||||
R::store( $book );
|
||||
|
||||
|
||||
$book = $book->fresh();
|
||||
//note that isset first returns false, so you can check if a list is loaded
|
||||
asrt( isset( $book['ownPage'] ), FALSE );
|
||||
@ -225,10 +225,10 @@ class Arrays extends Base
|
||||
asrt( count( $book['ownPageList'] ), 3 );
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['xownPageList'] ), 3 );
|
||||
|
||||
|
||||
$book['ownPage'][] = R::dispense( 'page' );
|
||||
R::store( $book );
|
||||
|
||||
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['ownPage'] ), 4 );
|
||||
$book = $book->fresh();
|
||||
@ -237,7 +237,7 @@ class Arrays extends Base
|
||||
asrt( count( $book['ownPageList'] ), 4 );
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['xownPageList'] ), 4 );
|
||||
|
||||
|
||||
//does dependency still work?
|
||||
$book['xownPageList'] = array();
|
||||
R::store( $book );
|
||||
@ -249,11 +249,11 @@ class Arrays extends Base
|
||||
asrt( count( $book['ownPageList'] ), 0 );
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['xownPageList'] ), 0 );
|
||||
|
||||
|
||||
//does shared list work as well?
|
||||
$book['sharedTag'] = R::dispense( 'tag', 2 );
|
||||
R::store( $book );
|
||||
|
||||
|
||||
$book = $book->fresh();
|
||||
//note that isset first returns false, so you can check if a list is loaded
|
||||
asrt( isset( $book['sharedTagList'] ), FALSE );
|
||||
@ -263,18 +263,17 @@ class Arrays extends Base
|
||||
asrt( count( $book['sharedTag'] ), 2 );
|
||||
asrt( isset( $book['sharedTagList'] ), TRUE );
|
||||
asrt( isset( $book['sharedTag'] ), TRUE );
|
||||
|
||||
|
||||
|
||||
$book['sharedTag'][] = R::dispense( 'tag' );
|
||||
R::store( $book );
|
||||
|
||||
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['sharedTagList'] ), 3 );
|
||||
asrt( count( $book['sharedTag'] ), 3 );
|
||||
|
||||
|
||||
$book['sharedTagList'][] = R::dispense( 'tag' );
|
||||
R::store( $book );
|
||||
|
||||
|
||||
$book = $book->fresh();
|
||||
asrt( count( $book['sharedTagList'] ), 4 );
|
||||
asrt( count( $book['sharedTag'] ), 4 );
|
||||
@ -288,16 +287,16 @@ class Arrays extends Base
|
||||
$first = reset( $book['sharedBookList'] );
|
||||
$id = $first['id'];
|
||||
asrt( count( $book['sharedBookList'][$id]['sharedBookList'] ), 1 );
|
||||
|
||||
|
||||
$properties = array();
|
||||
foreach($book as $key => $value) {
|
||||
$properties[ $key ] = $value;
|
||||
}
|
||||
|
||||
|
||||
asrt( count( $properties ), 2 );
|
||||
$keys = array_keys( $properties );
|
||||
sort( $keys );
|
||||
asrt( implode( ',', $keys ), 'id,sharedBook' );
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -170,6 +170,14 @@ class Association extends Base
|
||||
|
||||
R::storeAll( array( $author, $bio ) );
|
||||
|
||||
$x = $author->one( 'bio' );
|
||||
$y = $bio->one('author');
|
||||
|
||||
asrt( $x->name, $bio->name );
|
||||
asrt( $y->name, $author->name );
|
||||
asrt( $x->id, $bio->id );
|
||||
asrt( $y->id, $author->id );
|
||||
|
||||
$id2 = $author->id;
|
||||
|
||||
list( $a, $b ) = R::loadMulti( 'author,bio', $id1 );
|
||||
@ -310,7 +318,6 @@ class Association extends Base
|
||||
asrt( count( $wines[2]->sharedOlive ), 0 );
|
||||
}
|
||||
|
||||
|
||||
public function testErrorHandling()
|
||||
{
|
||||
R::nuke();
|
||||
@ -345,7 +352,6 @@ class Association extends Base
|
||||
fail();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Bean extends Base
|
||||
asrt( isset( $columns['xownerCritic'] ), FALSE );
|
||||
asrt( isset( $columns['sharedbyReader'] ), FALSE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Other tests...
|
||||
*/
|
||||
|
@ -72,4 +72,3 @@ class Boxing extends Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,7 +99,6 @@ class Chill extends Base
|
||||
}
|
||||
asrt(R::count('person_role'), 2);
|
||||
|
||||
|
||||
R::nuke();
|
||||
$link = R::getRedBean()->dispense('person_role');
|
||||
$person = R::dispense( 'person' );
|
||||
|
@ -38,4 +38,3 @@ class Close extends Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,6 @@ class Count extends Base
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test count and wipe.
|
||||
*
|
||||
|
@ -461,7 +461,7 @@ class Cross extends Base
|
||||
$text->content = 'CHANGED';
|
||||
}
|
||||
foreach( $texts as $text ) {
|
||||
asrt( $text->content, 'CHANGED', TRUE );
|
||||
asrt( $text->content, 'CHANGED' );
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ class Cross extends Base
|
||||
$text->content = 'CHANGED';
|
||||
}
|
||||
foreach( $texts as $text ) {
|
||||
asrt( $text->content, 'CHANGED', TRUE );
|
||||
asrt( $text->content, 'CHANGED' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class Cursors extends Base
|
||||
if ( $i > 5 ) break;
|
||||
}
|
||||
$key = array_rand( $list );
|
||||
$content = $list[ $key ];
|
||||
$content = $list[ $key ];
|
||||
$collection = R::findCollection( 'page', ' content = ? ', array( $content ) );
|
||||
$bean = $collection->next();
|
||||
asrt( $bean->content, $content );
|
||||
|
@ -161,7 +161,7 @@ class Database extends Base
|
||||
|
||||
$expect = '{"1":"a","2":"c"}';
|
||||
asrt( json_encode( R::getAssoc( 'SELECT id, a FROM page' ) ), $expect );
|
||||
|
||||
|
||||
$expect = '{"1":{"a":"a","b":"b"},"2":{"a":"c","b":"d"}}';
|
||||
asrt( json_encode( R::getAssoc( 'SELECT id, a, b FROM page' ) ), $expect );
|
||||
|
||||
@ -391,4 +391,3 @@ class TroubleDapter extends DBAdapter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,6 @@ class Dispense extends Base
|
||||
asrt( isset( $bean["abc"] ), TRUE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the facade-only dispenseAll method.
|
||||
*
|
||||
|
@ -424,7 +424,7 @@ class Dup extends Base
|
||||
* }}'
|
||||
*/
|
||||
|
||||
$d->setTables( $cache, 1 );
|
||||
$d->setTables( $cache );
|
||||
|
||||
ob_start();
|
||||
|
||||
|
@ -663,6 +663,10 @@ class Finding extends Base {
|
||||
$logger->clear();
|
||||
$found = R::findOne( 'book', ' title = ? LIMIT 1', array( 'b' ) );
|
||||
asrt( count( $logger->grep('LIMIT 1') ), 1 );
|
||||
$logger->clear();
|
||||
$found = R::findOne( 'book', ' title = ? limit 1', array( 'b' ) );
|
||||
asrt( count( $logger->grep('LIMIT 1') ), 0 );
|
||||
asrt( count( $logger->grep('limit 1') ), 1 );
|
||||
asrt( ( $found instanceof \RedBeanPHP\OODBBean ), TRUE );
|
||||
$found = R::findOne( 'book', ' title = ? LIMIT 2', array( 'b' ) );
|
||||
asrt( count( $logger->grep('LIMIT 2') ), 1 );
|
||||
|
@ -9,7 +9,6 @@ use RedBeanPHP\OODBBean as OODBBean;
|
||||
use RedBeanPHP\Adapter as Adapter;
|
||||
use RedBeanPHP\QueryWriter\AQueryWriter as AQueryWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Foreignkeys
|
||||
*
|
||||
@ -229,7 +228,7 @@ class Foreignkeys extends Base implements Observer
|
||||
* @return void
|
||||
*/
|
||||
public function testDependency2()
|
||||
{
|
||||
{
|
||||
$can = $this->createBeanInCan( TRUE );
|
||||
|
||||
asrt( R::count( 'bean' ), 1 );
|
||||
|
@ -158,7 +158,7 @@ class Fuse extends Base
|
||||
asrt( $probe->getLogActionCount( 'after_delete' ), 0 );
|
||||
asrt( ( $probe->getDataFromLog( 2, 'bean' ) === $probe ), TRUE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the SimpleFacadeBeanHelper factory setter.
|
||||
*
|
||||
@ -336,7 +336,7 @@ class Fuse extends Base
|
||||
asrt( $old[1], NULL);
|
||||
$test->nonExistantMethod(); //we cant really test this... :(
|
||||
pass();
|
||||
|
||||
|
||||
$old = R::setErrorHandlingFUSE( OODBBean::C_ERR_NOTICE );
|
||||
asrt( is_array( $old ), TRUE );
|
||||
asrt( count( $old ), 2 );
|
||||
@ -347,7 +347,7 @@ class Fuse extends Base
|
||||
}, E_USER_NOTICE);
|
||||
$test->nonExistantMethod();
|
||||
restore_error_handler();
|
||||
|
||||
|
||||
$old = OODBBean::setErrorHandlingFUSE( OODBBean::C_ERR_WARN );
|
||||
asrt( is_array( $old ), TRUE );
|
||||
asrt( count( $old ), 2 );
|
||||
@ -358,7 +358,7 @@ class Fuse extends Base
|
||||
}, E_USER_WARNING);
|
||||
$test->nonExistantMethod();
|
||||
restore_error_handler();
|
||||
|
||||
|
||||
$old = OODBBean::setErrorHandlingFUSE( OODBBean::C_ERR_FATAL );
|
||||
asrt( is_array( $old ), TRUE );
|
||||
asrt( count( $old ), 2 );
|
||||
|
@ -6,7 +6,6 @@ use RedUNIT\Base as Base;
|
||||
use RedBeanPHP\Facade as R;
|
||||
use RedBeanPHP\OODBBean as OODBBean;
|
||||
|
||||
|
||||
/**
|
||||
* Joins
|
||||
*
|
||||
@ -106,10 +105,10 @@ class Joins extends Base
|
||||
|
||||
/**
|
||||
* Helper for the next test.
|
||||
*
|
||||
*
|
||||
* @param array $books the books we are going to check
|
||||
* @param string $numberList the numbers that are expected
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function checkBookNumbers( $books, $numberList )
|
||||
@ -190,7 +189,7 @@ class Joins extends Base
|
||||
$books = $author->with(' ORDER BY @joined.category.title DESC, @joined.info.title ASC' )->ownBookList;
|
||||
$this->checkBookNumbers( $books, '3,2,0,1' );
|
||||
$books = $author->with(' ORDER BY @joined.category.title DESC, @joined.info.title ASC LIMIT 2' )->ownBookList;
|
||||
$this->checkBookNumbers( $books, '3,2' );
|
||||
$this->checkBookNumbers( $books, '3,2' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,6 @@ class Keywords extends Base
|
||||
'distinct', 'like'
|
||||
);
|
||||
|
||||
|
||||
foreach ( $keywords as $k ) {
|
||||
R::nuke();
|
||||
|
||||
@ -76,6 +75,5 @@ class Keywords extends Base
|
||||
pass();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Largenum extends Base
|
||||
/**
|
||||
* Test for issue #386.
|
||||
* Can we use large numbers in LIMIT ?
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLargeNum()
|
||||
|
@ -5,7 +5,7 @@ namespace RedUNIT\Base;
|
||||
use RedUNIT\Base as Base;
|
||||
use RedBeanPHP\Facade as R;
|
||||
use RedBeanPHP\Logger as Logger;
|
||||
use RedBeanPHP\Logger\RDefault as RDefault;
|
||||
use RedBeanPHP\Logger\RDefault as RDefault;
|
||||
|
||||
/**
|
||||
* Logging
|
||||
|
@ -28,6 +28,37 @@ use RedBeanPHP\Driver\RPDO as RPDO;
|
||||
*/
|
||||
class Misc extends Base
|
||||
{
|
||||
/**
|
||||
* Test whether we can set the 'auto clear'
|
||||
* option in OODB.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAutoClearHistory()
|
||||
{
|
||||
testpack( 'Auto clear history' );
|
||||
$book = R::dispense( 'book' );
|
||||
$book->pages = 100;
|
||||
$book->title = 'book';
|
||||
R::store( $book );
|
||||
$book = R::findOne( 'book' );
|
||||
asrt( $book->hasChanged( 'title' ), FALSE );
|
||||
$book->title = 'yes';
|
||||
R::store( $book );
|
||||
asrt( $book->hasChanged( 'title' ), TRUE );
|
||||
OODB::autoClearHistoryAfterStore( TRUE );
|
||||
$book = R::findOne( 'book' );
|
||||
asrt( $book->hasChanged( 'title' ), FALSE );
|
||||
$book->title = 'yes2';
|
||||
R::store( $book );
|
||||
asrt( $book->hasChanged( 'title' ), FALSE );
|
||||
OODB::autoClearHistoryAfterStore( FALSE );
|
||||
$book = R::findOne( 'book' );
|
||||
asrt( $book->hasChanged( 'title' ), FALSE );
|
||||
$book->title = 'yes';
|
||||
R::store( $book );
|
||||
asrt( $book->hasChanged( 'title' ), TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the R::inspect() method on the Facade.
|
||||
@ -584,7 +615,6 @@ class Misc extends Base
|
||||
asrt( R::count( 'flavour' ), 4 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test trashAll().
|
||||
*/
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace RedUNIT\Base;
|
||||
|
||||
use RedUNIT\Base as Base;
|
||||
use RedBeanPHP\Facade as R;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
|
||||
/**
|
||||
* Performance
|
||||
*
|
||||
* This performance test is used with runperf and xdebug profiler.
|
||||
*
|
||||
*
|
||||
* @file RedUNIT/Base/Performance.php
|
||||
* @desc Performance testing.
|
||||
* @author Gabor de Mooij and the RedBeanPHP Community
|
||||
@ -24,13 +24,13 @@ class Performance extends Base
|
||||
{
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
R::nuke();
|
||||
|
||||
|
||||
//Prepare structure
|
||||
$book = R::dispense( 'book' );
|
||||
$book->title = 'book';
|
||||
@ -55,16 +55,16 @@ class Performance extends Base
|
||||
$book->sharedTagList = $tags;
|
||||
R::store( $book );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CRUD performance.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crud()
|
||||
{
|
||||
R::freeze( TRUE );
|
||||
|
||||
|
||||
$book = R::dispense( 'book' );
|
||||
$book->title = 'Book';
|
||||
$page = R::dispense('page');
|
||||
@ -87,18 +87,18 @@ class Performance extends Base
|
||||
$book->ownPage;
|
||||
$book->sharedTag;
|
||||
R::trash( $book );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CRUD performance Array Access.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crudaa()
|
||||
{
|
||||
R::freeze( TRUE );
|
||||
|
||||
|
||||
$book = R::dispense( 'book' );
|
||||
$book['title'] = 'Book';
|
||||
$page = R::dispense('page');
|
||||
@ -121,6 +121,6 @@ class Performance extends Base
|
||||
$book->ownPage;
|
||||
$book->sharedTag;
|
||||
R::trash( $book );
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ class Prefixes extends Base
|
||||
* Test prerequisites.
|
||||
*/
|
||||
public function testPrerequisites()
|
||||
{
|
||||
{
|
||||
R::nuke();
|
||||
$bean = R::xdispense( 'type_with_underscore' );
|
||||
asrt( ( $bean instanceof OODBBean ), TRUE );
|
||||
|
@ -981,12 +981,10 @@ class Relations extends Base
|
||||
// Get books for topic
|
||||
asrt( $topic3->countShared('book'), 2 );
|
||||
|
||||
|
||||
$t3 = R::load( 'topic', $topic3->id );
|
||||
|
||||
asrt( count( $t3->sharedBook ), 2 );
|
||||
|
||||
|
||||
// Nuke an own-array, replace entire array at once without getting first
|
||||
$page2->id = 0;
|
||||
$page2->title = 'yet another page 2';
|
||||
@ -1420,7 +1418,6 @@ class Relations extends Base
|
||||
$v2->name = 'Ville 2';
|
||||
$v3->name = 'Ville 3';
|
||||
|
||||
|
||||
$v1->link( 'armyVillage' )->army = $a3;
|
||||
$v2->link( 'army_village' )->army = $a2;
|
||||
$v3->link( 'armyVillage' )->army = $a1;
|
||||
|
@ -149,7 +149,6 @@ class Traverse extends Base
|
||||
|
||||
asrt( implode( ',', $path ), 'e,f,h' );
|
||||
|
||||
|
||||
$path = array();
|
||||
$pageA->traverse( 'ownPageList', function( $page ) use ( &$path ) {
|
||||
$path[] = $page->title;
|
||||
@ -226,7 +225,6 @@ class Traverse extends Base
|
||||
} );
|
||||
asrt( implode( ',', $cats ), 'SF,Fantasy' );
|
||||
|
||||
|
||||
$catList = array();
|
||||
$fantasy->alias( 'genre' )
|
||||
->with( ' ORDER BY gname ASC ' )
|
||||
|
@ -176,7 +176,6 @@ class Update extends Base
|
||||
$account = R::load( 'user', $id );
|
||||
asrt( count( $account->alias( 'seller' )->ownTransaction ), 10 );
|
||||
|
||||
|
||||
$account->alias( 'seller' )->ownTransaction = array();
|
||||
|
||||
$id = R::store( $account );
|
||||
@ -507,7 +506,7 @@ class Update extends Base
|
||||
|
||||
asrt( (int) $pdo->GetCell( "SELECT count(*) FROM page" ), 0 );
|
||||
}
|
||||
|
||||
|
||||
public function testEmptyStringShouldNotBeStoredAsInteger()
|
||||
{
|
||||
R::nuke();
|
||||
|
@ -91,7 +91,6 @@ class Via extends Base
|
||||
$book->via('garbage')->item = 'test';
|
||||
asrt( count( $book->sharedPageList ), 1 );
|
||||
|
||||
|
||||
//yet another
|
||||
$book = R::dispense('leaflet');
|
||||
$book->title = 'leaflet';
|
||||
@ -189,7 +188,6 @@ class Via extends Base
|
||||
|
||||
R::storeAll(array( $p1, $p2 ));
|
||||
|
||||
|
||||
$project = R::load('project', $x1->id);
|
||||
|
||||
$designers = $project
|
||||
@ -201,7 +199,6 @@ class Via extends Base
|
||||
asrt(count($designers), 1);
|
||||
asrt($anna->name, 'Anna');
|
||||
|
||||
|
||||
$coders = $project
|
||||
->withCondition(' participant.arole = ? ', array( 'coder' ) )
|
||||
->via( 'participant' )
|
||||
|
@ -107,7 +107,6 @@ class With extends Base
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test all().
|
||||
*
|
||||
@ -466,7 +465,6 @@ class With extends Base
|
||||
$book->ownPage[] = R::dispense( 'page' );
|
||||
asrt( count( $book->ownPageList ), 4 );
|
||||
|
||||
|
||||
//Do not reload an own list if told to not reload using noLoad()
|
||||
$book->noLoad()->with(' LIMIT 1 ')->ownPage; //dont reload!
|
||||
asrt( count( $book->xownPage ), 0); //dont reload!
|
||||
@ -529,7 +527,6 @@ class With extends Base
|
||||
$book->sharedTag = R::dispense( 'tag', 16 );
|
||||
asrt( count( $book->sharedTag ), 16 );
|
||||
|
||||
|
||||
//Do not reload a sharedTag list if told to not reload using noLoad()
|
||||
$book->noLoad()->with(' LIMIT 1 ')->sharedTag; //dont reload!
|
||||
asrt( count( $book->sharedTag ), 0); //dont reload!
|
||||
|
@ -118,7 +118,6 @@ class Debug extends Blackhole
|
||||
$this->testDebug(':a,?', array(':a'=>20, 30), '20,30');
|
||||
$this->testDebug(':a,?', array(30, ':a'=>20), '20,30');
|
||||
|
||||
|
||||
$this->testDebug('?,?', array('test',20), '\'test\',20');
|
||||
$this->testDebug('?', array( NULL ), 'NULL');
|
||||
$this->testDebug('title = ?', array( NULL ), 'title = NULL');
|
||||
@ -129,7 +128,7 @@ class Debug extends Blackhole
|
||||
$this->testDebug('?,?', array('hello'), '\'hello\',:slot1');
|
||||
|
||||
$this->testDebug('hello ?', 'world', 'hello ?');
|
||||
|
||||
|
||||
$this->testDebug(':slot0 :slot1 :slot2 :slot3 :slot4 :slot5 :slot6 :slot7 :slot8 :slot9 :slot10', array(
|
||||
'a','b','c','d','e','f','g','h','i','j','k'
|
||||
),"'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k'");
|
||||
|
@ -69,4 +69,3 @@ class Fusebox extends Blackhole
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,7 +256,6 @@ class Misc extends Blackhole
|
||||
|
||||
$bean->name = 'a';
|
||||
|
||||
|
||||
try {
|
||||
R::transaction( function () use ( $bean ) {
|
||||
R::store( $bean );
|
||||
@ -336,7 +335,6 @@ class Misc extends Blackhole
|
||||
|
||||
testpack( 'Misc Tests' );
|
||||
|
||||
|
||||
R::debug( 1 );
|
||||
|
||||
flush();
|
||||
|
@ -13,7 +13,7 @@ use RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper as SimpleFacadeBeanHelper;
|
||||
use RedBeanPHP\Repository as Repository;
|
||||
use RedBeanPHP\Repository\Fluid as FluidRepo;
|
||||
use RedBeanPHP\Repository\Frozen as FrozenRepo;
|
||||
|
||||
use RedBeanPHP\RedException as RedException;
|
||||
|
||||
/**
|
||||
* Toolbox
|
||||
@ -29,6 +29,22 @@ use RedBeanPHP\Repository\Frozen as FrozenRepo;
|
||||
*/
|
||||
class Toolbox extends Blackhole {
|
||||
|
||||
/**
|
||||
* Github issue #458, selectDatabase causes PHP notice undefined index
|
||||
* if database key not found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidDB()
|
||||
{
|
||||
try {
|
||||
R::selectDatabase( 'idontexist' );
|
||||
fail();
|
||||
} catch ( RedException $exception ) {
|
||||
pass();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether we can obtain a toolbox properly.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
<?php
|
||||
|
||||
namespace RedUNIT;
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ class CUBRID extends RedUNIT
|
||||
{
|
||||
/*
|
||||
* What drivers should be loaded for this test pack?
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTargetDrivers()
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
<?php
|
||||
namespace RedUNIT\CUBRID;
|
||||
use RedBeanPHP\Facade as R;
|
||||
use \RedBeanPHP\RedException as RedException;
|
||||
use \RedBeanPHP\RedException as RedException;
|
||||
/**
|
||||
* RedUNIT_CUBRID_Setget
|
||||
*
|
||||
@ -18,7 +18,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
{
|
||||
/**
|
||||
* Test numbers.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNumbers()
|
||||
@ -43,7 +43,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
|
||||
asrt( setget( -2147483647 ), "-2147483647" );
|
||||
asrt( setget( "-2147483647" ), "-2147483647" );
|
||||
|
||||
|
||||
asrt( setget( "2147483648" ), "2147483648.0000000000000000" );
|
||||
asrt( setget( "-2147483648" ), "-2147483648.0000000000000000" );
|
||||
|
||||
@ -53,7 +53,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
|
||||
/**
|
||||
* Test dates.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDates()
|
||||
@ -69,7 +69,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
|
||||
/**
|
||||
* Test strings.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testStrings()
|
||||
@ -85,7 +85,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
|
||||
/**
|
||||
* Test booleans.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBool()
|
||||
@ -99,7 +99,7 @@ class Setget extends \RedUNIT\CUBRID
|
||||
|
||||
/**
|
||||
* Test NULL.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNull()
|
||||
@ -107,8 +107,8 @@ class Setget extends \RedUNIT\CUBRID
|
||||
asrt( setget( "NULL" ), "NULL" );
|
||||
asrt( setget( "NULL" ), "NULL" );
|
||||
|
||||
asrt( setget( "0123", 1 ), "0123" );
|
||||
asrt( setget( "0000123", 1 ), "0000123" );
|
||||
asrt( setget( "0123" ), "0123" );
|
||||
asrt( setget( "0000123" ), "0000123" );
|
||||
|
||||
asrt( setget( NULL ), NULL );
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
<?php
|
||||
namespace RedUNIT\CUBRID;
|
||||
use RedBeanPHP\Facade as R;
|
||||
use \RedBeanPHP\QueryWriter\CUBRID as CUBRID;
|
||||
use \RedBeanPHP\QueryWriter\CUBRID as CUBRID;
|
||||
/**
|
||||
* RedUNIT_CUBRID_Writer
|
||||
*
|
||||
@ -18,7 +18,7 @@ class Writer extends \RedUNIT\CUBRID
|
||||
{
|
||||
/**
|
||||
* Test scanning and coding of values.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testScanningAndCoding()
|
||||
@ -28,26 +28,25 @@ class Writer extends \RedUNIT\CUBRID
|
||||
$writer = $toolbox->getWriter();
|
||||
$redbean = $toolbox->getRedBean();
|
||||
$pdo = $adapter->getDatabase();
|
||||
|
||||
|
||||
$writer->createTable( "testtable" );
|
||||
|
||||
$writer->addColumn( "testtable", "special", CUBRID::C_DATATYPE_SPECIAL_DATE );
|
||||
|
||||
|
||||
$cols = $writer->getColumns( "testtable" );
|
||||
|
||||
asrt( $writer->code( $cols['special'], TRUE ), CUBRID::C_DATATYPE_SPECIAL_DATE );
|
||||
|
||||
|
||||
asrt( $writer->code( $cols['special'], FALSE ), CUBRID::C_DATATYPE_SPECIFIED );
|
||||
|
||||
|
||||
$writer->addColumn( "testtable", "special2", CUBRID::C_DATATYPE_SPECIAL_DATETIME );
|
||||
|
||||
|
||||
$cols = $writer->getColumns( "testtable" );
|
||||
|
||||
asrt( $writer->code( $cols['special2'], TRUE ), CUBRID::C_DATATYPE_SPECIAL_DATETIME );
|
||||
|
||||
|
||||
asrt( $writer->code( $cols['special'], FALSE ), CUBRID::C_DATATYPE_SPECIFIED );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -276,7 +276,6 @@ class Foreignkeys extends Mysql
|
||||
//Now add non-dep key
|
||||
R::nuke();
|
||||
|
||||
|
||||
$sql = '
|
||||
CREATE TABLE book (
|
||||
id INT( 11 ) UNSIGNED NULL AUTO_INCREMENT,
|
||||
@ -363,7 +362,6 @@ class Foreignkeys extends Mysql
|
||||
|
||||
$writer->addIndex('song', 'index1', 'album_id');
|
||||
|
||||
|
||||
$indexes = R::getAll( 'SHOW INDEX FROM song' );
|
||||
|
||||
asrt( count( $indexes ), 2 );
|
||||
@ -379,7 +377,6 @@ class Foreignkeys extends Mysql
|
||||
|
||||
asrt( count( $indexes ), 3 );
|
||||
|
||||
|
||||
//Dont fail, just dont
|
||||
try {
|
||||
$writer->addIndex('song', 'index3', 'nonexistant');
|
||||
|
@ -55,6 +55,3 @@ class Issue411 extends Mysql
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -145,6 +145,3 @@ class Mix extends Mysql
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -48,6 +48,11 @@ class Setget extends Mysql
|
||||
asrt( setget( "1.0" ), "1" );
|
||||
asrt( setget( 1.0 ), "1" );
|
||||
|
||||
asrt( setget( "3.20" ), "3.20" );
|
||||
asrt( setget( "13.20" ), "13.20" );
|
||||
asrt( setget( "134.20" ), "134.20" );
|
||||
asrt( setget( 3.21 ), '3.21' );
|
||||
|
||||
asrt( setget( "0.12345678" ), "0.12345678" );
|
||||
asrt( setget( 0.12345678 ), "0.12345678" );
|
||||
|
||||
@ -133,8 +138,8 @@ class Setget extends Mysql
|
||||
asrt( setget( "NULL" ), "NULL" );
|
||||
asrt( setget( "NULL" ), "NULL" );
|
||||
|
||||
asrt( setget( "0123", 1 ), "0123" );
|
||||
asrt( setget( "0000123", 1 ), "0000123" );
|
||||
asrt( setget( "0123" ), "0123" );
|
||||
asrt( setget( "0000123" ), "0000123" );
|
||||
|
||||
asrt( setget( NULL ), NULL );
|
||||
|
||||
|
@ -157,7 +157,7 @@ class Writer extends \RedUNIT\Mysql
|
||||
asrt( $writer->scanType( FALSE ), MySQL::C_DATATYPE_BOOL );
|
||||
asrt( $writer->scanType( TRUE ), MySQL::C_DATATYPE_BOOL );
|
||||
asrt( $writer->scanType( INF ), MySQL::C_DATATYPE_TEXT7 );
|
||||
|
||||
|
||||
asrt( $writer->scanType( NULL ), MySQL::C_DATATYPE_BOOL );
|
||||
|
||||
asrt( $writer->scanType( 2 ), MySQL::C_DATATYPE_UINT32 );
|
||||
@ -179,6 +179,10 @@ class Writer extends \RedUNIT\Mysql
|
||||
|
||||
asrt( $writer->scanType( "2001-10-10 10:00:00" ), MySQL::C_DATATYPE_TEXT7 );
|
||||
|
||||
asrt( $writer->scanType( "1.23", TRUE ), MySQL::C_DATATYPE_SPECIAL_MONEY );
|
||||
asrt( $writer->scanType( "12.23", TRUE ), MySQL::C_DATATYPE_SPECIAL_MONEY );
|
||||
asrt( $writer->scanType( "124.23", TRUE ), MySQL::C_DATATYPE_SPECIAL_MONEY );
|
||||
|
||||
asrt( $writer->scanType( str_repeat( "lorem ipsum", 100 ) ), MySQL::C_DATATYPE_TEXT16 );
|
||||
|
||||
$writer->widenColumn( "testtable", "c1", MySQL::C_DATATYPE_UINT32 );
|
||||
@ -544,6 +548,37 @@ class Writer extends \RedUNIT\Mysql
|
||||
asrt( $cols['date'], 'date' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test money types.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTypesMon()
|
||||
{
|
||||
$bean = R::dispense( 'bean' );
|
||||
|
||||
$bean->amount = '22.99';
|
||||
|
||||
R::store( $bean );
|
||||
|
||||
$cols = R::getColumns( 'bean' );
|
||||
|
||||
asrt( $cols['amount'], 'decimal(10,2)' );
|
||||
|
||||
R::nuke();
|
||||
|
||||
$bean = R::dispense( 'bean' );
|
||||
|
||||
$bean->amount = '-22.99';
|
||||
|
||||
R::store( $bean );
|
||||
|
||||
$cols = R::getColumns( 'bean' );
|
||||
|
||||
asrt( $cols['amount'], 'decimal(10,2)' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Date-time
|
||||
*
|
||||
|
@ -35,6 +35,11 @@ class Setget extends Postgres
|
||||
asrt( setget( "-0.25" ), "-0.25" );
|
||||
asrt( setget( -0.25 ), "-0.25" );
|
||||
|
||||
asrt( setget( "3.20" ), "3.20" );
|
||||
asrt( setget( "13.20" ), "13.20" );
|
||||
asrt( setget( "134.20" ), "134.20" );
|
||||
asrt( setget( 3.21 ), '3.21' );
|
||||
|
||||
asrt( setget( "0.12345678" ), "0.12345678" );
|
||||
asrt( setget( 0.12345678 ), "0.12345678" );
|
||||
|
||||
|
@ -171,7 +171,6 @@ class Uuid extends Postgres
|
||||
$id = R::store( $mansion );
|
||||
//exit;
|
||||
|
||||
|
||||
asrt( is_string( $id ), TRUE );
|
||||
asrt( strlen( $id ), 36 );
|
||||
$haunted = R::load( 'mansion', $id );
|
||||
|
@ -500,6 +500,36 @@ class Writer extends Postgres
|
||||
asrt( $bean->circle, '<(9.2,1.2),7.9>' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test money types.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTypesMon()
|
||||
{
|
||||
$bean = R::dispense( 'bean' );
|
||||
|
||||
$bean->amount = '22.99';
|
||||
|
||||
R::store( $bean );
|
||||
|
||||
$cols = R::getColumns( 'bean' );
|
||||
|
||||
asrt( $cols['amount'], 'numeric' );
|
||||
|
||||
R::nuke();
|
||||
|
||||
$bean = R::dispense( 'bean' );
|
||||
|
||||
$bean->amount = '-22.99';
|
||||
|
||||
R::store( $bean );
|
||||
|
||||
$cols = R::getColumns( 'bean' );
|
||||
|
||||
asrt( $cols['amount'], 'numeric' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test money data type.
|
||||
*
|
||||
|
@ -8,7 +8,7 @@ require('../RedBeanPHP/QueryWriter/CUBRID.php');
|
||||
//Define extra test packages from the hook
|
||||
$extraTestsFromHook = array(
|
||||
'CUBRID/Setget',
|
||||
'CUBRID/Writer'
|
||||
'CUBRID/Writer'
|
||||
);
|
||||
|
||||
//Create a connection for this database
|
||||
|
@ -9,7 +9,6 @@ require 'RedUNIT.php';
|
||||
require 'RedUNIT/Base.php';
|
||||
require 'RedUNIT/Base/Performance.php';
|
||||
|
||||
|
||||
error_reporting( E_ALL );
|
||||
|
||||
//Load configuration file
|
||||
@ -19,7 +18,6 @@ if ( file_exists( 'config/test.ini' ) ) {
|
||||
die( 'Cant find configuration file.' );
|
||||
}
|
||||
|
||||
|
||||
//Configure the databases
|
||||
if ( isset( $ini['mysql'] ) ) {
|
||||
$dsn = "mysql:host={$ini['mysql']['host']};dbname={$ini['mysql']['schema']}";
|
||||
@ -52,34 +50,32 @@ $test = new \RedUNIT\Base\Performance();
|
||||
|
||||
$drivers = $test->getTargetDrivers();
|
||||
|
||||
|
||||
|
||||
foreach ( $drivers as $driver ) {
|
||||
|
||||
|
||||
if ( !isset( $ini[$driver] ) ) continue;
|
||||
if ( !isset( $_SERVER['argv'][1])) die('Missing parameter. Usage: php runperf.php <testname> <TIMES> ');
|
||||
|
||||
|
||||
$method = $_SERVER['argv'][1];
|
||||
|
||||
|
||||
if ($method === 'setup') {
|
||||
|
||||
|
||||
echo 'Setup...'.PHP_EOL;
|
||||
|
||||
|
||||
$test->$method();
|
||||
|
||||
echo 'READY'.PHP_EOL;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$times = 100;
|
||||
if (isset($_SERVER['argv'][2])) {
|
||||
$times = (int) $_SERVER['argv'][2];
|
||||
}
|
||||
|
||||
|
||||
echo "Performing test: $method with driver $driver ".PHP_EOL;
|
||||
|
||||
for ($j=0; $j<$times; $j++) {
|
||||
|
||||
|
||||
$t1 = microtime( TRUE );
|
||||
|
||||
$test->$method();
|
||||
@ -87,14 +83,14 @@ foreach ( $drivers as $driver ) {
|
||||
$t2 = microtime( TRUE );
|
||||
|
||||
$d[] = ($t2 - $t1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$s = array_sum($d);
|
||||
$a = ($s / $times);
|
||||
$mx = max($d);
|
||||
$mn = min($d);
|
||||
|
||||
|
||||
echo PHP_EOL."AVG: $a, MAX: $mx, MIN: $mn, TOTAL: $s, TIMES: $times ".PHP_EOL;
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
chdir( '..' );
|
||||
|
||||
|
||||
$xdebugSupported = (function_exists('xdebug_start_code_coverage'));
|
||||
|
||||
if ($xdebugSupported) xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
|
||||
@ -26,7 +25,6 @@ echo '*** RedUNIT ***'.PHP_EOL;
|
||||
echo 'Welcome to RedUNIT Unit testing framework for RedBeanPHP.'.PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
|
||||
|
||||
/**
|
||||
* Define some globals.
|
||||
*/
|
||||
@ -44,7 +42,6 @@ require_once( 'RedUNIT/Mysql.php' );
|
||||
require_once( 'RedUNIT/Postgres.php' );
|
||||
require_once( 'RedUNIT/Sqlite.php' );
|
||||
|
||||
|
||||
require_once( 'RedUNIT/Pretest.php' );
|
||||
|
||||
$extraTestsFromHook = array();
|
||||
@ -91,7 +88,6 @@ function activate_driver( $d )
|
||||
R::selectDatabase( $d );
|
||||
}
|
||||
|
||||
|
||||
$arguments = $_SERVER['argc'];
|
||||
|
||||
$mode = 'all';
|
||||
@ -198,8 +194,6 @@ $suffix = array(
|
||||
'Base/Close'
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Default (mode == all)
|
||||
if ( $mode == 'all' ) {
|
||||
$packList = $allPacks;
|
||||
@ -237,6 +231,9 @@ foreach ( $packList as $testPack ) {
|
||||
|
||||
maintestpack( str_replace( '_', ' ', get_class( $test ) ) );
|
||||
|
||||
$round = 0;
|
||||
$test->setRound( $round );
|
||||
|
||||
if ( $drivers && is_array( $drivers ) ) {
|
||||
foreach ( $drivers as $driver ) {
|
||||
if ( !isset( $ini[$driver] ) ) continue;
|
||||
@ -267,6 +264,7 @@ foreach ( $packList as $testPack ) {
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
$test->setRound( ++$round );
|
||||
|
||||
}
|
||||
} else {
|
||||
@ -276,7 +274,6 @@ foreach ( $packList as $testPack ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$xdebugSupported) {
|
||||
echo 'Done. No report - XDEBUG not installed.';
|
||||
exit(0);
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Here you can add logic to be executed during the bootstrapping
|
||||
* of RedUNIT.
|
||||
*
|
||||
*
|
||||
* You can define/use the following variables:
|
||||
*
|
||||
*
|
||||
* $hookPath -> add 1 additional path which will be searched for unit tests
|
||||
* $extraTestsFromHook -> array with additional test packs (will be executed if you pass 'all' argument to CLI runner)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
@ -409,7 +409,6 @@ class Model_PageWidget extends RedBean_SimpleModel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mock class to test proper model name
|
||||
* beautificattion for link table beans in FUSE.
|
||||
@ -484,7 +483,6 @@ class Model_Feed extends \RedbeanPHP\SimpleModel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UUID QueryWriter for MySQL for testing purposes.
|
||||
*/
|
||||
@ -576,9 +574,9 @@ class DiagnosticBean extends \RedBeanPHP\OODBBean {
|
||||
|
||||
class DiagnosticModel extends \RedBeanPHP\SimpleModel
|
||||
{
|
||||
|
||||
|
||||
private $logs = array();
|
||||
|
||||
|
||||
public function open()
|
||||
{
|
||||
$this->logs[] = array(
|
||||
@ -638,12 +636,12 @@ class DiagnosticModel extends \RedBeanPHP\SimpleModel
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getLogs()
|
||||
{
|
||||
return $this->logs;
|
||||
}
|
||||
|
||||
|
||||
public function getLogActionCount( $action = NULL )
|
||||
{
|
||||
if ( is_null( $action ) ) return count( $this->logs );
|
||||
@ -653,21 +651,19 @@ class DiagnosticModel extends \RedBeanPHP\SimpleModel
|
||||
}
|
||||
return $counter;
|
||||
}
|
||||
|
||||
|
||||
public function clearLog()
|
||||
{
|
||||
return $this->logs = array();
|
||||
}
|
||||
|
||||
|
||||
public function getDataFromLog( $logIndex = 0, $property )
|
||||
{
|
||||
return $this->logs[$logIndex]['data'][$property];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Model_Probe extends DiagnosticModel {};
|
||||
|
||||
|
||||
define('REDBEAN_OODBBEAN_CLASS', '\DiagnosticBean');
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Convenience function for test hook.
|
||||
* If you added the proper Writer class, the facade should be able
|
||||
* to automatically load it, i.e. \RedBeanPHP\QueryWriter\MyWriter
|
||||
*
|
||||
*
|
||||
* @global array $ini
|
||||
*
|
||||
*
|
||||
* @param string $name name of the connection (key)
|
||||
* @param string $dsn DSN to connect
|
||||
* @param string $user username
|
||||
@ -16,7 +16,7 @@ function add_writer_to_tests( $name, $dsn, $user, $pass )
|
||||
{
|
||||
|
||||
global $ini;
|
||||
|
||||
|
||||
\RedUNIT\Base::addToDriverList( $name );
|
||||
R::addDatabase( $name, $dsn, $user, $pass );
|
||||
|
||||
@ -400,7 +400,6 @@ function getIndexes( $tableNoQ )
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function are_cols_in_unique( $type, $properties )
|
||||
{
|
||||
sort( $properties );
|
||||
@ -414,7 +413,6 @@ function are_cols_in_unique( $type, $properties )
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
function get_uniques_for_type( $type )
|
||||
{
|
||||
$list = array();
|
||||
|
@ -5,6 +5,8 @@ namespace DeepCopy;
|
||||
use DeepCopy\Exception\CloneException;
|
||||
use DeepCopy\Filter\Filter;
|
||||
use DeepCopy\Matcher\Matcher;
|
||||
use DeepCopy\TypeFilter\TypeFilter;
|
||||
use DeepCopy\TypeMatcher\TypeMatcher;
|
||||
use ReflectionProperty;
|
||||
use DeepCopy\Reflection\ReflectionHelper;
|
||||
|
||||
@ -24,6 +26,12 @@ class DeepCopy
|
||||
*/
|
||||
private $filters = [];
|
||||
|
||||
/**
|
||||
* Type Filters to apply.
|
||||
* @var array
|
||||
*/
|
||||
private $typeFilters = [];
|
||||
|
||||
private $skipUncloneable = false;
|
||||
|
||||
/**
|
||||
@ -39,8 +47,8 @@ class DeepCopy
|
||||
|
||||
/**
|
||||
* Perform a deep copy of the object.
|
||||
* @param object $object
|
||||
* @return object
|
||||
* @param mixed $object
|
||||
* @return mixed
|
||||
*/
|
||||
public function copy($object)
|
||||
{
|
||||
@ -57,8 +65,22 @@ class DeepCopy
|
||||
];
|
||||
}
|
||||
|
||||
public function addTypeFilter(TypeFilter $filter, TypeMatcher $matcher)
|
||||
{
|
||||
$this->typeFilters[] = [
|
||||
'matcher' => $matcher,
|
||||
'filter' => $filter,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function recursiveCopy($var)
|
||||
{
|
||||
// Matches Type Filter
|
||||
if ($filter = $this->getFirstMatchedTypeFilter($this->typeFilters, $var)) {
|
||||
return $filter->apply($var);
|
||||
}
|
||||
|
||||
// Resource
|
||||
if (is_resource($var)) {
|
||||
return $var;
|
||||
@ -159,4 +181,43 @@ class DeepCopy
|
||||
// Copy the property
|
||||
$property->setValue($object, $this->recursiveCopy($propertyValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first filter that matches variable, NULL if no such filter found.
|
||||
* @param array $filterRecords Associative array with 2 members: 'filter' with value of type {@see TypeFilter} and
|
||||
* 'matcher' with value of type {@see TypeMatcher}
|
||||
* @param mixed $var
|
||||
* @return TypeFilter|null
|
||||
*/
|
||||
private function getFirstMatchedTypeFilter(array $filterRecords, $var)
|
||||
{
|
||||
$matched = $this->first(
|
||||
$filterRecords,
|
||||
function (array $record) use ($var) {
|
||||
/* @var TypeMatcher $matcher */
|
||||
$matcher = $record['matcher'];
|
||||
|
||||
return $matcher->matches($var);
|
||||
}
|
||||
);
|
||||
|
||||
return isset($matched) ? $matched['filter'] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns first element that matches predicate, NULL if no such element found.
|
||||
* @param array $elements
|
||||
* @param callable $predicate Predicate arguments are: element.
|
||||
* @return mixed|null
|
||||
*/
|
||||
private function first(array $elements, callable $predicate)
|
||||
{
|
||||
foreach ($elements as $element) {
|
||||
if (call_user_func($predicate, $element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Match a property by its type
|
||||
*
|
||||
* @deprecated It is recommended to use {@see DeepCopy\TypeFilter\TypeFilter} instead, as it applies on all occurrences
|
||||
* of given type in copied context (eg. array elements), not just on object properties.
|
||||
*/
|
||||
class PropertyTypeMatcher implements Matcher
|
||||
{
|
||||
|
@ -2,6 +2,12 @@
|
||||
|
||||
All notable changes of the PHP_CodeCoverage 3.0 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [3.0.2] - 2015-11-12
|
||||
|
||||
### Changed
|
||||
|
||||
* It is now optional that `@deprecated` code is ignored
|
||||
|
||||
## [3.0.1] - 2015-10-06
|
||||
|
||||
### Fixed
|
||||
@ -19,6 +25,7 @@ All notable changes of the PHP_CodeCoverage 3.0 release series are documented in
|
||||
* The blacklist functionality has been removed
|
||||
* PHP_CodeCoverage is no longer supported on PHP 5.3, PHP 5.4, and PHP 5.5
|
||||
|
||||
[3.0.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/2.2...3.0.0
|
||||
|
||||
|
@ -57,6 +57,11 @@ class PHP_CodeCoverage
|
||||
*/
|
||||
private $processUncoveredFilesFromWhitelist = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $ignoreDeprecatedCode = false;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
@ -486,6 +491,23 @@ class PHP_CodeCoverage
|
||||
$this->disableIgnoredLines = $flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $flag
|
||||
* @throws PHP_CodeCoverage_InvalidArgumentException
|
||||
* @since Method available since Release 3.0.2
|
||||
*/
|
||||
public function setIgnoreDeprecatedCode($flag)
|
||||
{
|
||||
if (!is_bool($flag)) {
|
||||
throw PHP_CodeCoverage_InvalidArgumentException::create(
|
||||
1,
|
||||
'boolean'
|
||||
);
|
||||
}
|
||||
|
||||
$this->ignoreDeprecatedCode = $flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the @covers annotation filtering.
|
||||
*
|
||||
@ -732,7 +754,7 @@ class PHP_CodeCoverage
|
||||
|
||||
$this->ignoredLines[$filename][] = $token->getLine();
|
||||
|
||||
if (strpos($docblock, '@codeCoverageIgnore') || strpos($docblock, '@deprecated')) {
|
||||
if (strpos($docblock, '@codeCoverageIgnore') || ($this->ignoreDeprecatedCode && strpos($docblock, '@deprecated'))) {
|
||||
$endLine = $token->getEndLine();
|
||||
|
||||
for ($i = $token->getLine(); $i <= $endLine; $i++) {
|
||||
|
@ -58,7 +58,7 @@ abstract class PHP_CodeCoverage_Report_HTML_Renderer
|
||||
*/
|
||||
public function __construct($templatePath, $generator, $date, $lowUpperBound, $highLowerBound)
|
||||
{
|
||||
$version = new SebastianBergmann\Version('3.0.1', dirname(dirname(dirname(dirname(__DIR__)))));
|
||||
$version = new SebastianBergmann\Version('3.0.2', dirname(dirname(dirname(dirname(__DIR__)))));
|
||||
|
||||
$this->templatePath = $templatePath;
|
||||
$this->generator = $generator;
|
||||
|
@ -238,6 +238,28 @@ class PHP_CodeCoverageTest extends PHP_CodeCoverage_TestCase
|
||||
$this->coverage->setMapTestClassNameToCoveredClassName(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setIgnoreDeprecatedCode
|
||||
*/
|
||||
public function testSetIgnoreDeprecatedCode()
|
||||
{
|
||||
$this->coverage->setIgnoreDeprecatedCode(true);
|
||||
$this->assertAttributeEquals(
|
||||
true,
|
||||
'ignoreDeprecatedCode',
|
||||
$this->coverage
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::setIgnoreDeprecatedCode
|
||||
* @expectedException PHP_CodeCoverage_Exception
|
||||
*/
|
||||
public function testSetIgnoreDeprecatedCodeThrowsExceptionForInvalidArgument()
|
||||
{
|
||||
$this->coverage->setIgnoreDeprecatedCode(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_CodeCoverage::clear
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user