cvs: pear /MDB2 package_mssql.php /MDB2/MDB2/Driver/Manager mssql.php
| From: | Lorenzo Alberton | Date: | Sun, 04 Mar 2007 20:00:23 +0000 |
| Subject: | cvs: pear /MDB2 package_mssql.php /MDB2/MDB2/Driver/Manager mssql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44948@lists.php.net to get a copy of this message | ||
quipo Sun Mar 4 20:00:23 2007 UTC
Modified files:
/pear/MDB2/MDB2/Driver/Manager mssql.php
/pear/MDB2 package_mssql.php
Log:
implemented listTableConstraints() in the Manager module
http://cvs.php.net/viewvc.cgi/pear/MDB2/MDB2/Driver/Manager/mssql.php?r1=1.83&r2=1.84&diff_format=u
Index: pear/MDB2/MDB2/Driver/Manager/mssql.php
diff -u pear/MDB2/MDB2/Driver/Manager/mssql.php:1.83 pear/MDB2/MDB2/Driver/Manager/mssql.php:1.84
--- pear/MDB2/MDB2/Driver/Manager/mssql.php:1.83 Wed Jan 17 06:49:07 2007
+++ pear/MDB2/MDB2/Driver/Manager/mssql.php Sun Mar 4 20:00:22 2007
@@ -2,7 +2,7 @@
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
-// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
+// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith |
// | All rights reserved. |
// +----------------------------------------------------------------------+
@@ -39,10 +39,12 @@
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
-// | Author: Frank M. Kromann <frank@kromann.info> |
+// | Authors: Frank M. Kromann <frank@kromann.info> |
+// | David Coallier <davidc@php.net> |
+// | Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+
//
-// $Id: mssql.php,v 1.83 2007/01/17 06:49:07 davidc Exp $
+// $Id: mssql.php,v 1.84 2007/03/04 20:00:22 quipo Exp $
//
require_once 'MDB2/Driver/Manager/Common.php';
@@ -56,6 +58,7 @@
* @category Database
* @author Frank M. Kromann <frank@kromann.info>
* @author David Coallier <davidc@php.net>
+ * @author Lorenzo Alberton <l.alberton@quipo.it>
*/
class MDB2_Driver_Manager_mssql extends MDB2_Driver_Manager_Common
{
@@ -468,6 +471,47 @@
}
// }}}
+ // {{{ listTableConstraints()
+
+ /**
+ * list all constraints in a table
+ *
+ * @param string $table name of table that should be used in method
+ * @return mixed array of constraint names on success, a MDB2 error on failure
+ * @access public
+ */
+ function listTableConstraints($table)
+ {
+ $db =& $this->getDBInstance();
+ if (PEAR::isError($db)) {
+ return $db;
+ }
+ $table = $db->quoteIdentifier($table, true);
+
+ $query = "SELECT c.constraint_name
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS c
+ WHERE c.constraint_catalog = DB_NAME()
+ AND c.table_name = '$table'";
+ $constraints = $db->queryCol($query);
+ if (PEAR::isError($constraints)) {
+ return $constraints;
+ }
+
+ $result = array();
+ foreach ($constraints as $constraint) {
+ $constraint = $this->_fixIndexName($constraint);
+ if (!empty($constraint)) {
+ $result[$constraint] = true;
+ }
+ }
+
+ if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
+ $result = array_change_key_case($result, $db->options['field_case']);
+ }
+ return array_keys($result);
+ }
+
+ // }}}
// {{{ createSequence()
/**
@@ -572,4 +616,4 @@
}
// }}}
-?>
+?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/pear/MDB2/package_mssql.php?r1=1.78&r2=1.79&diff_format=u
Index: pear/MDB2/package_mssql.php
diff -u pear/MDB2/package_mssql.php:1.78 pear/MDB2/package_mssql.php:1.79
--- pear/MDB2/package_mssql.php:1.78 Sun Mar 4 19:35:43 2007
+++ pear/MDB2/package_mssql.php Sun Mar 4 20:00:23 2007
@@ -42,6 +42,7 @@
- implemented getTableIndexDefinition() in the Reverse module
- implemented getTableConstraintDefinition() in the Reverse module
- implemented getTriggerDefinition() in the Reverse module
+- implemented listTableConstraints() in the Manager module
- implemented guid() in the Function module [globally unique identifier]
- implemented a fallback mechanism within getTableIndexDefinition() in the Reverse
module to ignore the 'idxname_format' option and use the index name as provided