From: Andrey Kutejko Date: Sat, 8 Jun 2013 18:05:21 +0000 (+0300) Subject: cleanup X-Git-Tag: 0.5~264 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=eb8d6c198e8110c54d40356bf9a123ecede5aa1d;p=ipf.git cleanup --- diff --git a/ipf/form/field/varchar.php b/ipf/form/field/varchar.php index 46e2fb3..de44321 100644 --- a/ipf/form/field/varchar.php +++ b/ipf/form/field/varchar.php @@ -1,11 +1,13 @@ empty_values)) { $value = ''; @@ -20,14 +22,16 @@ class IPF_Form_Field_Varchar extends IPF_Form_Field{ return $value; } - public function widgetAttrs($widget){ + public function widgetAttrs($widget) + { if ($this->max_length !== null and in_array(get_class($widget), array('IPF_Form_Widget_TextInput', 'IPF_Form_Widget_PasswordInput'))) { return array('maxlength'=>$this->max_length); } return array(); } - protected function getWidget(){ + protected function getWidget() + { if ($this->max_length>255) return 'IPF_Form_Widget_TextAreaInput'; return $this->widget; diff --git a/ipf/orm/adapter.php b/ipf/orm/adapter.php index 06b9b51..1ca145a 100644 --- a/ipf/orm/adapter.php +++ b/ipf/orm/adapter.php @@ -71,4 +71,4 @@ class IPF_ORM_Adapter const PARAM_NULL = 0; const PARAM_STMT = 4; const PARAM_STR = 2; -} \ No newline at end of file +} diff --git a/ipf/orm/connection.php b/ipf/orm/connection.php index 0d161a0..13c2c82 100644 --- a/ipf/orm/connection.php +++ b/ipf/orm/connection.php @@ -50,13 +50,11 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta public function __construct(IPF_ORM_Manager $manager, $adapter, $user = null, $pass = null) { if (is_object($adapter)) { - if ( ! ($adapter instanceof PDO) && ! in_array('IPF_ORM_Adapter_Interface', class_implements($adapter))) { - throw new IPF_ORM_Exception('First argument should be an instance of PDO or implement IPF_ORM_Adapter_Interface'); + if (!($adapter instanceof PDO)) { + throw new IPF_ORM_Exception('First argument should be an instance of PDO'); } $this->dbh = $adapter; - $this->isConnected = true; - } else if (is_array($adapter)) { $this->pendingAttributes[IPF_ORM::ATTR_DRIVER_NAME] = $adapter['scheme']; diff --git a/ipf/orm/manager.php b/ipf/orm/manager.php index 4e64efd..93dfa13 100644 --- a/ipf/orm/manager.php +++ b/ipf/orm/manager.php @@ -60,9 +60,9 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato public function getQueryRegistry() { - if ( ! isset($this->_queryRegistry)) { - $this->_queryRegistry = new IPF_ORM_Query_Registry; - } + if ( ! isset($this->_queryRegistry)) { + $this->_queryRegistry = new IPF_ORM_Query_Registry; + } return $this->_queryRegistry; } @@ -73,23 +73,17 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato return $this; } - public static function connection($adapter = null, $name = null) + public static function connection() { - if ($adapter == null) { - return IPF_ORM_Manager::getInstance()->getCurrentConnection(); - } else { - return IPF_ORM_Manager::getInstance()->openConnection($adapter, $name); - } + return IPF_ORM_Manager::getInstance()->getCurrentConnection(); } public function openConnection($adapter, $name = null, $setCurrent = true, $persistent = false) { if (is_object($adapter)) { - if ( ! ($adapter instanceof PDO) && ! in_array('IPF_ORM_Adapter_Interface', class_implements($adapter))) { - throw new IPF_ORM_Exception("First argument should be an instance of PDO or implement IPF_ORM_Adapter_Interface"); - } - - $driverName = $adapter->getAttribute(IPF_ORM::ATTR_DRIVER_NAME); + if (!($adapter instanceof PDO)) + throw new IPF_ORM_Exception("First argument should be an instance of PDO"); + $driverName = $adapter->getAttribute(PDO::ATTR_DRIVER_NAME); } else if (is_array($adapter)) { if ( ! isset($adapter[0])) { throw new IPF_ORM_Exception('Empty data source name given.'); diff --git a/ipf/orm/overloadable.php b/ipf/orm/overloadable.php deleted file mode 100644 index a1175c3..0000000 --- a/ipf/orm/overloadable.php +++ /dev/null @@ -1,5 +0,0 @@ -_expressionMap = array(); $this->_subqueryAliases = array(); $this->_needsSubquery = false; - $this->_isLimitSubqueryUsed = false; } public function createSubquery() @@ -769,7 +768,6 @@ class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable, Seriali if ( ! empty($this->_sqlParts['limit']) && $this->_needsSubquery && $table->getAttribute(IPF_ORM::ATTR_QUERY_LIMIT) == IPF_ORM::LIMIT_RECORDS) { - $this->_isLimitSubqueryUsed = true; $needsSubQuery = true; } diff --git a/ipf/orm/query/abstract.php b/ipf/orm/query/abstract.php index 93b52af..d6149da 100644 --- a/ipf/orm/query/abstract.php +++ b/ipf/orm/query/abstract.php @@ -71,7 +71,6 @@ abstract class IPF_ORM_Query_Abstract ); protected $_enumParams = array(); - protected $_isLimitSubqueryUsed = false; protected $_pendingSetParams = array(); protected $_components; protected $_preQueried = false; @@ -229,11 +228,6 @@ abstract class IPF_ORM_Query_Abstract return $this->_view; } - public function isLimitSubqueryUsed() - { - return $this->_isLimitSubqueryUsed; - } - public function convertEnums($params) { $table = $this->getRoot(); @@ -462,11 +456,6 @@ abstract class IPF_ORM_Query_Abstract $query = $this->_view->getSelectSql(); } - if ($this->isLimitSubqueryUsed() && - $this->_conn->getAttribute(IPF_ORM::ATTR_DRIVER_NAME) !== 'mysql') { - $params = array_merge($params, $params); - } - if ($this->_type !== self::SELECT) { return $this->_conn->exec($query, $params); } diff --git a/ipf/router.php b/ipf/router.php index 3355ae6..d19d3c4 100644 --- a/ipf/router.php +++ b/ipf/router.php @@ -2,7 +2,8 @@ class IPF_Router { - public static function response500($e){ + public static function response500($e) + { if (IPF::get('debug')) return new IPF_HTTP_Response_ServerErrorDebug($e); else @@ -12,7 +13,7 @@ class IPF_Router public static function dispatch($query='') { try{ - $query = preg_replace('#^(/)+#', '/', '/'.$query); + $query = preg_replace('#^(/)+#', '/', '/'.$query); $req = new IPF_HTTP_Request($query); $middleware = array(); foreach (IPF::get('middlewares', array()) as $mw) {