]> git.andy128k.dev Git - ipf.git/commitdiff
cleanup
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 18:05:21 +0000 (21:05 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 18:05:21 +0000 (21:05 +0300)
ipf/form/field/varchar.php
ipf/orm/adapter.php
ipf/orm/connection.php
ipf/orm/manager.php
ipf/orm/overloadable.php [deleted file]
ipf/orm/query.php
ipf/orm/query/abstract.php
ipf/router.php

index 46e2fb3df2ecc655e871cf1f773ea8ac12cdccc9..de44321648143d0357a822866cfb5507077b8a2f 100644 (file)
@@ -1,11 +1,13 @@
 <?php
 
-class IPF_Form_Field_Varchar extends IPF_Form_Field{
+class IPF_Form_Field_Varchar extends IPF_Form_Field
+{
     public $widget = 'IPF_Form_Widget_TextInput';
     public $max_length = null;
     public $min_length = null;
 
-    public function clean($value){
+    public function clean($value)
+    {
         parent::clean($value);
         if (in_array($value, $this->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;
index 06b9b5189cb2c28b409467c24d5c52239d1f2069..1ca145acfc721d0ea9f664d35ec2093215e34b91 100644 (file)
@@ -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
+}
index 0d161a0aa0db350d789ab12fbb0c742f43fa7d27..13c2c82aed9c5fbf3f43a6ae301062e111d133e7 100644 (file)
@@ -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'];
 
index 4e64efdd02388c0c87eeb244e19c17c5da7209ff..93dfa1372b897fa2c907948af6f5fc3e7eb73363 100644 (file)
@@ -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 (file)
index a1175c3..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-interface IPF_ORM_Overloadable {
-    public function __call($m, $a);
-}
\ No newline at end of file
index 29fb6188dcfe371dbf1ccdf02846142e0bc0b796..7124026a66db8d8212f94e39b770e03dea22ff82 100644 (file)
@@ -80,7 +80,6 @@ class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable, Seriali
         $this->_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;
         }
 
index 93b52af03da14f5a98b4d5e0d6d4f7776f25cc6e..d6149da75fb6a299f1530f339040bd94098e594a 100644 (file)
@@ -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);
         }
index 3355ae67500c94581c29c48a93bc7063407815d0..d19d3c4aa72740076248abab46db222b9b75e47d 100644 (file)
@@ -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) {