<?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 = '';
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;
const PARAM_NULL = 0;
const PARAM_STMT = 4;
const PARAM_STR = 2;
-}
\ No newline at end of file
+}
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'];
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;
}
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.');
+++ /dev/null
-<?php
-
-interface IPF_ORM_Overloadable {
- public function __call($m, $a);
-}
\ No newline at end of file
$this->_expressionMap = array();
$this->_subqueryAliases = array();
$this->_needsSubquery = false;
- $this->_isLimitSubqueryUsed = false;
}
public function createSubquery()
if ( ! empty($this->_sqlParts['limit']) && $this->_needsSubquery &&
$table->getAttribute(IPF_ORM::ATTR_QUERY_LIMIT) == IPF_ORM::LIMIT_RECORDS) {
- $this->_isLimitSubqueryUsed = true;
$needsSubQuery = true;
}
);
protected $_enumParams = array();
- protected $_isLimitSubqueryUsed = false;
protected $_pendingSetParams = array();
protected $_components;
protected $_preQueried = false;
return $this->_view;
}
- public function isLimitSubqueryUsed()
- {
- return $this->_isLimitSubqueryUsed;
- }
-
public function convertEnums($params)
{
$table = $this->getRoot();
$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);
}
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
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) {