updated firebird and mysql drivers
This commit is contained in:
parent
85559a7f35
commit
f02ad22cc4
@ -165,6 +165,28 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict {
|
|||||||
|
|
||||||
return array($type, $length, $unsigned, $fixed);
|
return array($type, $length, $unsigned, $fixed);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||||
|
* of a field declaration to be used in statements like CREATE TABLE.
|
||||||
|
*
|
||||||
|
* @param string $charset name of the charset
|
||||||
|
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||||
|
* of a field declaration.
|
||||||
|
*/
|
||||||
|
public function getCharsetFieldDeclaration($charset) {
|
||||||
|
return 'CHARACTER SET '.$charset;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Obtain DBMS specific SQL code portion needed to set the COLLATION
|
||||||
|
* of a field declaration to be used in statements like CREATE TABLE.
|
||||||
|
*
|
||||||
|
* @param string $collation name of the collation
|
||||||
|
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||||
|
* of a field declaration.
|
||||||
|
*/
|
||||||
|
public function getCollationFieldDeclaration($collation) {
|
||||||
|
return 'COLLATE '.$collation;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* list all tables in the current database
|
* list all tables in the current database
|
||||||
*
|
*
|
||||||
|
@ -266,6 +266,71 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
|
|||||||
|
|
||||||
return array($type, $length, $unsigned, $fixed);
|
return array($type, $length, $unsigned, $fixed);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||||
|
* of a field declaration to be used in statements like CREATE TABLE.
|
||||||
|
*
|
||||||
|
* @param string $charset name of the charset
|
||||||
|
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||||
|
* of a field declaration.
|
||||||
|
*/
|
||||||
|
public function getCharsetFieldDeclaration($charset) {
|
||||||
|
return 'CHARACTER SET '.$charset;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Obtain DBMS specific SQL code portion needed to set the COLLATION
|
||||||
|
* of a field declaration to be used in statements like CREATE TABLE.
|
||||||
|
*
|
||||||
|
* @param string $collation name of the collation
|
||||||
|
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||||
|
* of a field declaration.
|
||||||
|
*/
|
||||||
|
public function getCollationFieldDeclaration($collation) {
|
||||||
|
return 'COLLATE '.$collation;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Obtain DBMS specific SQL code portion needed to declare an integer type
|
||||||
|
* field to be used in statements like CREATE TABLE.
|
||||||
|
*
|
||||||
|
* @param string $name name the field to be declared.
|
||||||
|
* @param string $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:
|
||||||
|
*
|
||||||
|
* unsigned
|
||||||
|
* Boolean flag that indicates whether the field
|
||||||
|
* should be declared as unsigned integer if
|
||||||
|
* possible.
|
||||||
|
*
|
||||||
|
* default
|
||||||
|
* Integer 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.
|
||||||
|
*/
|
||||||
|
public function getIntegerDeclaration($name, $field) {
|
||||||
|
$default = $autoinc = '';
|
||||||
|
if (!empty($field['autoincrement'])) {
|
||||||
|
$autoinc = ' AUTO_INCREMENT PRIMARY KEY';
|
||||||
|
} elseif (array_key_exists('default', $field)) {
|
||||||
|
if ($field['default'] === '') {
|
||||||
|
$field['default'] = empty($field['notnull']) ? null : 0;
|
||||||
|
}
|
||||||
|
$default = ' DEFAULT '.$this->conn->getDbh()->quote($field['default']);
|
||||||
|
} elseif (empty($field['notnull'])) {
|
||||||
|
$default = ' DEFAULT NULL';
|
||||||
|
}
|
||||||
|
|
||||||
|
$notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
||||||
|
$unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED';
|
||||||
|
$name = $this->conn->quoteIdentifier($name, true);
|
||||||
|
return $name . ' ' . $this->getTypeDeclaration($field) . $unsigned . $default . $notnull . $autoinc;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* lists all databases
|
* lists all databases
|
||||||
*
|
*
|
||||||
|
@ -44,10 +44,10 @@ class Doctrine_Expression_Firebird extends Doctrine_Expression {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* build string to define escape pattern string
|
* build string to define escape pattern string
|
||||||
*
|
*
|
||||||
* @return string define escape pattern
|
* @return string define escape pattern
|
||||||
*/
|
*/
|
||||||
public function patternEscapeString() {
|
function patternEscapeString() {
|
||||||
return " ESCAPE '". $db->escape_pattern ."'";
|
return " ESCAPE '". $this->conn->string_quoting['escape_pattern'] ."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ Doctrine::autoload('Doctrine_Expression');
|
|||||||
/**
|
/**
|
||||||
* Doctrine_Expression_Mysql
|
* Doctrine_Expression_Mysql
|
||||||
*
|
*
|
||||||
* @package Doctrine
|
* @package Doctrine
|
||||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||||
* @category Object Relational Mapping
|
* @category Object Relational Mapping
|
||||||
* @link www.phpdoctrine.com
|
* @link www.phpdoctrine.com
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||||
*/
|
*/
|
||||||
class Doctrine_Expression_Mysql extends Doctrine_Expression {
|
class Doctrine_Expression_Mysql extends Doctrine_Expression {
|
||||||
/**
|
/**
|
||||||
* returns the regular expression operator
|
* returns the regular expression operator
|
||||||
@ -38,5 +38,53 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression {
|
|||||||
*/
|
*/
|
||||||
public function regexp() {
|
public function regexp() {
|
||||||
return 'RLIKE';
|
return 'RLIKE';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* build a pattern matching string
|
||||||
|
*
|
||||||
|
* EXPERIMENTAL
|
||||||
|
*
|
||||||
|
* WARNING: this function is experimental and may change signature at
|
||||||
|
* any time until labelled as non-experimental
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||||
|
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||||
|
* @param string $field optional field name that is being matched against
|
||||||
|
* (might be required when emulating ILIKE)
|
||||||
|
*
|
||||||
|
* @return string SQL pattern
|
||||||
|
*/
|
||||||
|
public function matchPattern($pattern, $operator = null, $field = null) {
|
||||||
|
$match = '';
|
||||||
|
if (!is_null($operator)) {
|
||||||
|
$field = is_null($field) ? '' : $field.' ';
|
||||||
|
$operator = strtoupper($operator);
|
||||||
|
switch ($operator) {
|
||||||
|
// case insensitive
|
||||||
|
case 'ILIKE':
|
||||||
|
$match = $field.'LIKE ';
|
||||||
|
break;
|
||||||
|
// case sensitive
|
||||||
|
case 'LIKE':
|
||||||
|
$match = $field.'LIKE BINARY ';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||||
|
'not a supported operator type:'. $operator, __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$match.= "'";
|
||||||
|
foreach ($pattern as $key => $value) {
|
||||||
|
if ($key % 2) {
|
||||||
|
$match.= $value;
|
||||||
|
} else {
|
||||||
|
$match.= $db->escapePattern($db->escape($value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$match.= "'";
|
||||||
|
$match.= $this->patternEscapeString();
|
||||||
|
return $match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user