Column, index, and stored routine, nor are column aliases . Trigger names are case sensitive, which differs from standard SQL.see Identifier-case-sensitivity
$ name = strtolower ($ parts [0]);and
$ name = strtolower ($ name);
class MyDoctrine_Table extends Doctrine_Table
{
public function setColumn($name, $type, $length = null , $options = array(), $prepend = false )
{
if (is_string($options)) {
$options = explode( '|' , $options);
}
foreach ($options as $k => $option) {
if (is_numeric($k)) {
if ( ! empty($option)) {
$options[$option] = true ;
}
unset($options[$k]);
}
}
// extract column name & field name
if (stripos($name, ' as ' ))
{
if (strpos($name, ' as ' )) {
$parts = explode( ' as ' , $name);
} else {
$parts = explode( ' AS ' , $name);
}
if (count($parts) > 1) {
$fieldName = $parts[1];
} else {
$fieldName = $parts[0];
}
//$name = strtolower($parts[0]);
$name = $parts[0];
} else {
$fieldName = $name;
//$name = strtolower($name);
}
$name = trim($name);
$fieldName = trim($fieldName);
if ($prepend) {
$ this ->_columnNames = array_merge(array($fieldName => $name), $ this ->_columnNames);
$ this ->_fieldNames = array_merge(array($name => $fieldName), $ this ->_fieldNames);
} else {
$ this ->_columnNames[$fieldName] = $name;
$ this ->_fieldNames[$name] = $fieldName;
}
if ($length == null ) {
switch ($type) {
case 'integer' :
$length = 8;
break ;
case 'decimal' :
$length = 18;
break ;
case 'string' :
case 'clob' :
case 'float' :
case 'integer' :
case 'array' :
case 'object' :
case 'blob' :
case 'gzip' :
//$length = 2147483647;
//All the DataDict driver classes have work-arounds to deal
//with unset lengths.
$length = null ;
break ;
case 'boolean' :
$length = 1;
case 'date' :
// YYYY-MM-DD ISO 8601
$length = 10;
case 'time' :
// HH:NN:SS+00:00 ISO 8601
$length = 14;
case 'timestamp' :
// YYYY-MM-DDTHH:MM:SS+00:00 ISO 8601
$length = 25;
break ;
}
}
$options[ 'type' ] = $type;
$options[ 'length' ] = $length;
if ($prepend) {
$ this ->_columns = array_merge(array($name => $options), $ this ->_columns);
} else {
$ this ->_columns[$name] = $options;
}
if (isset($options[ 'primary' ]) && $options[ 'primary' ]) {
if (isset($ this ->_identifier)) {
$ this ->_identifier = (array) $ this ->_identifier;
}
if ( ! in_array($fieldName, $ this ->_identifier)) {
$ this ->_identifier[] = $fieldName;
}
}
if (isset($options[ 'default' ])) {
$ this ->hasDefaultValues = true ;
}
}
}
* This source code was highlighted with Source Code Highlighter .
// lowercase
require_once(dirname(__FILE__) . '/lib/doctrine_extra/MyDoctrine/Table.php' );
$conn->setAttribute(Doctrine::ATTR_TABLE_CLASS, 'MyDoctrine_Table' );
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/81891/
All Articles