-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.php
87 lines (72 loc) · 2.05 KB
/
cloud.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Serverboy Cloud
* http://cloud.serverboy.net/
*
* PHP version 5
*
* Copyright 2011 Matt Basta
*
* @author Matt Basta <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
$location = dirname(__FILE__);
define('CLOUD_PATH_PREFIX', $location . (strlen($location) > 1 ? '/' : ''));
require(CLOUD_PATH_PREFIX . 'libraries/simpleObjects.php');
// Universal DB Driver Interface
require(CLOUD_PATH_PREFIX . 'libraries/driver.php');
require(CLOUD_PATH_PREFIX . 'libraries/driver.table.php');
require(CLOUD_PATH_PREFIX . 'libraries/column.php');
// Token class and helpers
require(CLOUD_PATH_PREFIX . 'libraries/token.php');
class cloud {
public static function connect($type, $credentials) {
$db_path = CLOUD_PATH_PREFIX . 'engines/' . $type . '.driver.php';
require_once($db_path);
$db_class = $type . '_driver';
$db = new $db_class($credentials);
return $db;
}
}
function _comp($x, $comparison, $y) {
return new comparison($x, $comparison, $y);
}
function _and() {
if(func_num_args() > 1)
return new logicCombinator(func_get_args(), 'AND');
else {
$arg = func_get_arg(0);
if(is_array($arg))
return new logicCombinator($arg, 'AND');
else
return $arg;
}
}
function _st($token) {
if($token instanceof simpleToken)
return $token;
return new simpleToken($token);
}
function _or() {
if(func_num_args() > 1)
return new logicCombinator(func_get_args(), 'OR');
else {
$arg = func_get_arg(0);
if(is_array($arg))
return new logicCombinator($arg, 'OR');
else
return $arg;
}
}