forked from mjpearson/Pandra
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.php
executable file
·61 lines (52 loc) · 2.04 KB
/
config.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
<?php
/**
* Config
*
* @author Michael Pearson <[email protected]>
* @copyright 2010 phpgrease.net
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
* @version 0.2
* @package pandra
*/
//error_reporting(E_ALL);
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift-php/';
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
// Config xml path for Cassandra
define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-incubating-0.5.0/conf/storage-conf.xml');
define('MODEL_OUT_DIR', dirname(__FILE__).'/models/');
define('SCHEMA_PATH', dirname(__FILE__).'/schemas/');
define('THRIFT_PORT_DEFAULT', 9160);
define('DEFAULT_ROW_LIMIT', 10);
define('PERSIST_CONNECTIONS', FALSE); // TSocket Persistence
// horrendous autoloader in the absense of namespace
function _pandraAutoLoad($className) {
// seperate classes and interfaces for clarity
$fExt = array('.class.php', '.interface.php');
// strip prefix
$className = preg_replace('/^pandra/i', '', $className);
// class path relative to config
$classPath = dirname(__FILE__)."/lib/";
if (preg_match('/^(Query|Clause)/', $className)) {
$classPath .= 'query/';
} elseif (preg_match('/^Log/', $className)) {
$classPath .= 'logging/';
}
foreach ($fExt as $ext) {
$classFile = $classPath.$className.$ext;
if (file_exists($classFile)) {
require_once($classFile);
break;
// Check if it's an external class we might know about
} else if (file_exists($classPath.'/ext/'.$className.$ext)) {
require_once($classPath.'/ext/'.$className.$ext);
break;
}
}
}
spl_autoload_register('_pandraAutoLoad');
define('PANDRA_64', PHP_INT_SIZE == 8);
?>