diff --git a/config.php b/config.php index 19af746..d3c71db 100755 --- a/config.php +++ b/config.php @@ -10,51 +10,18 @@ */ //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'); +require_once dirname(__FILE__).'/lib/loader.php'; 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 - -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); +define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-0.6.0/conf/storage-conf.xml'); ?> \ No newline at end of file diff --git a/lib/Core.class.php b/lib/Core.class.php index 026a2a3..0fd7a76 100755 --- a/lib/Core.class.php +++ b/lib/Core.class.php @@ -786,9 +786,4 @@ static public function getRangeKeys($keySpace, } } } - -// Setup our capabilities -PandraCore::setMemcachedAvailable(class_exists('Memcached')); - -PandraCore::setAPCAvailable(function_exists('apc_sma_info') && apc_sma_info() !== FALSE); ?> \ No newline at end of file diff --git a/lib/Validator.class.php b/lib/Validator.class.php index e6284b1..4b55331 100644 --- a/lib/Validator.class.php +++ b/lib/Validator.class.php @@ -132,8 +132,11 @@ static public function check($value, $label, $typeDefs, &$errors) { if ($error) $errorMsg[] = "Invalid URL"; break; - case 'int' : case 'float' : + $error = !is_float($value); + if ($error) $errorMsg[] = "Field error, expected ".$type; + break; + case 'int' : case 'numeric' : $error = !is_numeric($value); if ($error) $errorMsg[] = "Field error, expected ".$type; diff --git a/lib/loader.php b/lib/loader.php new file mode 100644 index 0000000..c06f7e0 --- /dev/null +++ b/lib/loader.php @@ -0,0 +1,45 @@ + + * @copyright 2010 phpgrease.net + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License + * @version 0.2 + * @package pandra + */ +define('PANDRA_64', PHP_INT_SIZE == 8); +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__)."/"; + + if (preg_match('/^(Query|Clause)/', $className)) { + $classPath .= 'query/'; + } elseif (preg_match('/^Log/', $className)) { + $classPath .= 'logging/'; + } elseif (preg_match('/^UUID/', $className)) { + $classPath .= 'uuid/'; + } + + foreach ($fExt as $ext) { + $classFile = $classPath.$className.$ext; + if (file_exists($classFile)) { + require_once($classFile); + break; + } + } +} +spl_autoload_register('_pandraAutoLoad'); + +// Setup our capabilities +PandraCore::setMemcachedAvailable(class_exists('Memcached')); +PandraCore::setAPCAvailable(function_exists('apc_sma_info') && apc_sma_info() !== FALSE); +?> \ No newline at end of file diff --git a/lib/ext/UUID.class.php b/lib/uuid/UUID.class.php similarity index 100% rename from lib/ext/UUID.class.php rename to lib/uuid/UUID.class.php