Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #12800 add alterDatabase
Submitted: 2007-12-31 19:16 UTC
From: afz Assigned: quipo
Status: Closed Package: MDB2 (version CVS)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 39 + 50 = ?

 
 [2007-12-31 19:16 UTC] afz (Ali Fazelzade)
Description: ------------ hi, i provide a patch for support change database charset via alterDatabase. tnx and happy new year.

Comments

 [2007-12-31 19:21 UTC] afz (Ali Fazelzade)
why i can't upload patch file into a ticket!!! Index: Common.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/Manager/Common.php,v retrieving revision 1.69 diff -u -r1.69 Common.php --- Common.php 19 Dec 2007 20:03:31 -0000 1.69 +++ Common.php 1 Jan 2008 19:04:25 -0000 @@ -199,6 +199,29 @@ } // }}} + // {{{ alterDatabase() + + /** + * alter an existing database + * + * @param string $name name of the database that should be created + * @param array $options array with charset, collation info + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function alterDatabase($database, $options = array()) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'method not implemented', __FUNCTION__); + } + + // }}} // {{{ dropDatabase() /** Index: mssql.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/Manager/mssql.php,v retrieving revision 1.94 diff -u -r1.94 mssql.php --- mssql.php 19 Dec 2007 20:03:31 -0000 1.94 +++ mssql.php 1 Jan 2008 19:14:51 -0000 @@ -92,6 +92,31 @@ return $db->standaloneQuery($query, null, true); } + // {{{ alterDatabase() + /** + * create a new database + * + * @param string $name name of the database that is intended to be changed + * @param array $options array with collation info + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function alterDatabase($name, $options = array()) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $name = $db->quoteIdentifier($name, true); + $query = "ALTER DATABASE $name"; + if (!empty($options['collation'])) { + $query .= ' COLLATE ' . $options['collation']; + } + return $db->standaloneQuery($query, null, true); + } + // }}} // {{{ dropDatabase() Index: mysql.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/Manager/mysql.php,v retrieving revision 1.101 diff -u -r1.101 mysql.php --- mysql.php 19 Dec 2007 20:03:31 -0000 1.101 +++ mysql.php 1 Jan 2008 19:08:13 -0000 @@ -92,6 +92,40 @@ } // }}} + // {{{ alterDatabase() + + /** + * alter an existing database + * + * @param string $name name of the database that is intended to be changed + * @param array $options array with charset, collation info + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function alterDatabase($name, $options = array()) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $name = $db->quoteIdentifier($name, true); + $query = 'ALTER DATABASE ' . $name; + if (!empty($options['charset'])) { + $query .= ' DEFAULT CHARACTER SET ' . $options['charset']; + } + if (!empty($options['collation'])) { + $query .= ' COLLATE ' . $options['collation']; + } + $result = $db->exec($query); + if (PEAR::isError($result)) { + return $result; + } + return MDB2_OK; + } + + // }}} // {{{ dropDatabase() /** Index: mysqli.php =================================================================== RCS file: /repository/pear/MDB2/MDB2/Driver/Manager/mysqli.php,v retrieving revision 1.88 diff -u -r1.88 mysqli.php --- mysqli.php 19 Dec 2007 20:03:31 -0000 1.88 +++ mysqli.php 1 Jan 2008 19:08:48 -0000 @@ -92,6 +92,40 @@ } // }}} + // {{{ alterDatabase() + + /** + * alter an existing database + * + * @param string $name name of the database that is intended to be changed + * @param array $options array with charset, collation info + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function alterDatabase($name, $options = array()) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $name = $db->quoteIdentifier($name, true); + $query = 'ALTER DATABASE ' . $name; + if (!empty($options['charset'])) { + $query .= ' DEFAULT CHARACTER SET ' . $options['charset']; + } + if (!empty($options['collation'])) { + $query .= ' COLLATE ' . $options['collation']; + } + $result = $db->exec($query); + if (PEAR::isError($result)) { + return $result; + } + return MDB2_OK; + } + + // }}} // {{{ dropDatabase() /**
 [2008-01-12 13:31 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.