📄 common.php
字号:
* Obtain DBMS specific SQL code portion needed to declare a date type * field to be used in statements like CREATE TABLE. * * @param string $name name the field to be declared. * @param array $field associative array with the name of the properties * of the field being declared as array indexes. Currently, the types * of supported field properties are as follows: * * default * Date value to be used as default for this field. * * notnull * Boolean flag that indicates whether this field is constrained * to not be set to null. * @return string DBMS specific SQL code portion that should be used to * declare the specified field. * @access protected */ function _getDateDeclaration($name, $field) { return $this->_getDeclaration($name, $field); } // }}} // {{{ _getTimestampDeclaration() /** * Obtain DBMS specific SQL code portion needed to declare a timestamp * field to be used in statements like CREATE TABLE. * * @param string $name name the field to be declared. * @param array $field associative array with the name of the properties * of the field being declared as array indexes. Currently, the types * of supported field properties are as follows: * * default * Timestamp value to be used as default for this field. * * notnull * Boolean flag that indicates whether this field is constrained * to not be set to null. * @return string DBMS specific SQL code portion that should be used to * declare the specified field. * @access protected */ function _getTimestampDeclaration($name, $field) { return $this->_getDeclaration($name, $field); } // }}} // {{{ _getTimeDeclaration() /** * Obtain DBMS specific SQL code portion needed to declare a time * field to be used in statements like CREATE TABLE. * * @param string $name name the field to be declared. * @param array $field associative array with the name of the properties * of the field being declared as array indexes. Currently, the types * of supported field properties are as follows: * * default * Time value to be used as default for this field. * * notnull * Boolean flag that indicates whether this field is constrained * to not be set to null. * @return string DBMS specific SQL code portion that should be used to * declare the specified field. * @access protected */ function _getTimeDeclaration($name, $field) { return $this->_getDeclaration($name, $field); } // }}} // {{{ _getFloatDeclaration() /** * Obtain DBMS specific SQL code portion needed to declare a float type * field to be used in statements like CREATE TABLE. * * @param string $name name the field to be declared. * @param array $field associative array with the name of the properties * of the field being declared as array indexes. Currently, the types * of supported field properties are as follows: * * default * Float value to be used as default for this field. * * notnull * Boolean flag that indicates whether this field is constrained * to not be set to null. * @return string DBMS specific SQL code portion that should be used to * declare the specified field. * @access protected */ function _getFloatDeclaration($name, $field) { return $this->_getDeclaration($name, $field); } // }}} // {{{ _getDecimalDeclaration() /** * Obtain DBMS specific SQL code portion needed to declare a decimal type * field to be used in statements like CREATE TABLE. * * @param string $name name the field to be declared. * @param array $field associative array with the name of the properties * of the field being declared as array indexes. Currently, the types * of supported field properties are as follows: * * default * Decimal value to be used as default for this field. * * notnull * Boolean flag that indicates whether this field is constrained * to not be set to null. * @return string DBMS specific SQL code portion that should be used to * declare the specified field. * @access protected */ function _getDecimalDeclaration($name, $field) { return $this->_getDeclaration($name, $field); } // }}} // {{{ compareDefinition() /** * Obtain an array of changes that may need to applied * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access public */ function compareDefinition($current, $previous) { $type = !empty($current['type']) ? $current['type'] : null; if (!method_exists($this, "_compare{$type}Definition")) { $db =& $this->getDBInstance(); if (PEAR::isError($db)) { return $db; } if (!empty($db->options['datatype_map_callback'][$type])) { $parameter = array('current' => $current, 'previous' => $previous); $change = call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter)); return $change; } return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, 'type "'.$current['type'].'" is not yet supported', __FUNCTION__); } if (empty($previous['type']) || $previous['type'] != $type) { return $current; } $change = $this->{"_compare{$type}Definition"}($current, $previous); if ($previous['type'] != $type) { $change['type'] = true; } $previous_notnull = !empty($previous['notnull']) ? $previous['notnull'] : false; $notnull = !empty($current['notnull']) ? $current['notnull'] : false; if ($previous_notnull != $notnull) { $change['notnull'] = true; } $previous_default = array_key_exists('default', $previous) ? $previous['default'] : ($previous_notnull ? '' : null); $default = array_key_exists('default', $current) ? $current['default'] : ($notnull ? '' : null); if ($previous_default !== $default) { $change['default'] = true; } return $change; } // }}} // {{{ _compareIntegerDefinition() /** * Obtain an array of changes that may need to applied to an integer field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareIntegerDefinition($current, $previous) { $change = array(); $previous_unsigned = !empty($previous['unsigned']) ? $previous['unsigned'] : false; $unsigned = !empty($current['unsigned']) ? $current['unsigned'] : false; if ($previous_unsigned != $unsigned) { $change['unsigned'] = true; } $previous_autoincrement = !empty($previous['autoincrement']) ? $previous['autoincrement'] : false; $autoincrement = !empty($current['autoincrement']) ? $current['autoincrement'] : false; if ($previous_autoincrement != $autoincrement) { $change['autoincrement'] = true; } return $change; } // }}} // {{{ _compareTextDefinition() /** * Obtain an array of changes that may need to applied to an text field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareTextDefinition($current, $previous) { $change = array(); $previous_length = !empty($previous['length']) ? $previous['length'] : 0; $length = !empty($current['length']) ? $current['length'] : 0; if ($previous_length != $length) { $change['length'] = true; } $previous_fixed = !empty($previous['fixed']) ? $previous['fixed'] : 0; $fixed = !empty($current['fixed']) ? $current['fixed'] : 0; if ($previous_fixed != $fixed) { $change['fixed'] = true; } return $change; } // }}} // {{{ _compareCLOBDefinition() /** * Obtain an array of changes that may need to applied to an CLOB field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareCLOBDefinition($current, $previous) { return $this->_compareTextDefinition($current, $previous); } // }}} // {{{ _compareBLOBDefinition() /** * Obtain an array of changes that may need to applied to an BLOB field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareBLOBDefinition($current, $previous) { return $this->_compareTextDefinition($current, $previous); } // }}} // {{{ _compareDateDefinition() /** * Obtain an array of changes that may need to applied to an date field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareDateDefinition($current, $previous) { return array(); } // }}} // {{{ _compareTimeDefinition() /** * Obtain an array of changes that may need to applied to an time field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareTimeDefinition($current, $previous) { return array(); } // }}} // {{{ _compareTimestampDefinition() /** * Obtain an array of changes that may need to applied to an timestamp field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareTimestampDefinition($current, $previous) { return array(); } // }}} // {{{ _compareBooleanDefinition() /** * Obtain an array of changes that may need to applied to an boolean field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareBooleanDefinition($current, $previous) { return array(); } // }}} // {{{ _compareFloatDefinition() /** * Obtain an array of changes that may need to applied to an float field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareFloatDefinition($current, $previous) { return array(); } // }}} // {{{ _compareDecimalDefinition() /** * Obtain an array of changes that may need to applied to an decimal field * * @param array $current new definition * @param array $previous old definition * @return array containing all changes that will need to be applied * @access protected */ function _compareDecimalDefinition($current, $previous)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -