cvs: pear /MDB2/MDB2/Driver/Manager Common.php mysql.php mysqli.php sqlite.php
| From: | Lukas Smith | Date: | Mon, 01 May 2006 11:10:21 +0000 |
| Subject: | cvs: pear /MDB2/MDB2/Driver/Manager Common.php mysql.php mysqli.php sqlite.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39930@lists.php.net to get a copy of this message | ||
lsmith Mon May 1 11:10:21 2006 UTC
Modified files:
/pear/MDB2/MDB2/Driver/Manager Common.php mysql.php mysqli.php
sqlite.php
Log:
- added ability to hint that a constraint is a primary key in dropConstraint()
http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Manager/Common.php?r1=1.50&r2=1.51&diff_format=u
Index: pear/MDB2/MDB2/Driver/Manager/Common.php
diff -u pear/MDB2/MDB2/Driver/Manager/Common.php:1.50 pear/MDB2/MDB2/Driver/Manager/Common.php:1.51
--- pear/MDB2/MDB2/Driver/Manager/Common.php:1.50 Sun Apr 30 19:12:35 2006
+++ pear/MDB2/MDB2/Driver/Manager/Common.php Mon May 1 11:10:21 2006
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.50 2006/04/30 19:12:35 lsmith Exp $
+// $Id: Common.php,v 1.51 2006/05/01 11:10:21 lsmith Exp $
//
/**
@@ -696,12 +696,13 @@
/**
* drop existing constraint
*
- * @param string $table name of table that should be used in method
+ * @param string $table name of table that should be used in method
* @param string $name name of the constraint to be dropped
+ * @param string $primary hint if the constraint is primary
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
- function dropConstraint($table, $name)
+ function dropConstraint($table, $name, $primary = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Manager/mysql.php?r1=1.71&r2=1.72&diff_format=u
Index: pear/MDB2/MDB2/Driver/Manager/mysql.php
diff -u pear/MDB2/MDB2/Driver/Manager/mysql.php:1.71 pear/MDB2/MDB2/Driver/Manager/mysql.php:1.72
--- pear/MDB2/MDB2/Driver/Manager/mysql.php:1.71 Mon May 1 10:45:02 2006
+++ pear/MDB2/MDB2/Driver/Manager/mysql.php Mon May 1 11:10:21 2006
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: mysql.php,v 1.71 2006/05/01 10:45:02 lsmith Exp $
+// $Id: mysql.php,v 1.72 2006/05/01 11:10:21 lsmith Exp $
//
require_once 'MDB2/Driver/Manager/Common.php';
@@ -798,12 +798,13 @@
/**
* drop existing constraint
*
- * @param string $table name of table that should be used in method
+ * @param string $table name of table that should be used in method
* @param string $name name of the constraint to be dropped
+ * @param string $primary hint if the constraint is primary
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
- function dropConstraint($table, $name)
+ function dropConstraint($table, $name, $primary = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
@@ -811,7 +812,7 @@
}
$table = $db->quoteIdentifier($table, true);
- if (strtolower($name) == 'primary') {
+ if ($primary || strtolower($name) == 'primary') {
$query = "ALTER TABLE $table DROP PRIMARY KEY";
} else {
$name = $db->quoteIdentifier($db->getIndexName($name), true);
http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Manager/mysqli.php?r1=1.57&r2=1.58&diff_format=u
Index: pear/MDB2/MDB2/Driver/Manager/mysqli.php
diff -u pear/MDB2/MDB2/Driver/Manager/mysqli.php:1.57 pear/MDB2/MDB2/Driver/Manager/mysqli.php:1.58
--- pear/MDB2/MDB2/Driver/Manager/mysqli.php:1.57 Mon May 1 10:45:02 2006
+++ pear/MDB2/MDB2/Driver/Manager/mysqli.php Mon May 1 11:10:21 2006
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: mysqli.php,v 1.57 2006/05/01 10:45:02 lsmith Exp $
+// $Id: mysqli.php,v 1.58 2006/05/01 11:10:21 lsmith Exp $
//
require_once 'MDB2/Driver/Manager/Common.php';
@@ -776,9 +776,13 @@
$type = '';
$name = $db->quoteIdentifier($db->getIndexName($name), true);
if (array_key_exists('primary', $definition) &&
$definition['primary']) {
+ if (strtolower($name) != 'primary') {
+ return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
+ 'Primary Key may must be named primary');
+ }
$type = 'PRIMARY';
$name = 'KEY';
- } elseif (array_key_exists('unique', $definition) &&
$definition['unique']) {
+ } else if (array_key_exists('unique', $definition) &&
$definition['unique']) {
$type = 'UNIQUE';
}
@@ -798,12 +802,13 @@
/**
* drop existing constraint
*
- * @param string $table name of table that should be used in method
+ * @param string $table name of table that should be used in method
* @param string $name name of the constraint to be dropped
+ * @param string $primary hint if the constraint is primary
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
- function dropConstraint($table, $name)
+ function dropConstraint($table, $name, $primary = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
http://cvs.php.net/viewcvs.cgi/pear/MDB2/MDB2/Driver/Manager/sqlite.php?r1=1.48&r2=1.49&diff_format=u
Index: pear/MDB2/MDB2/Driver/Manager/sqlite.php
diff -u pear/MDB2/MDB2/Driver/Manager/sqlite.php:1.48 pear/MDB2/MDB2/Driver/Manager/sqlite.php:1.49
--- pear/MDB2/MDB2/Driver/Manager/sqlite.php:1.48 Sat Apr 15 10:48:06 2006
+++ pear/MDB2/MDB2/Driver/Manager/sqlite.php Mon May 1 11:10:21 2006
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: sqlite.php,v 1.48 2006/04/15 10:48:06 lsmith Exp $
+// $Id: sqlite.php,v 1.49 2006/05/01 11:10:21 lsmith Exp $
//
require_once 'MDB2/Driver/Manager/Common.php';
@@ -572,19 +572,20 @@
/**
* drop existing constraint
*
- * @param string $table name of table that should be used in method
+ * @param string $table name of table that should be used in method
* @param string $name name of the constraint to be dropped
+ * @param string $primary hint if the constraint is primary
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
- function dropConstraint($table, $name)
+ function dropConstraint($table, $name, $primary = false)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
}
- if ($name == 'PRIMARY') {
+ if ($primary || $name == 'PRIMARY') {
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'dropConstraints: Dropping Primary Constraints is not supported');
}