UpdateDatabase/MysqlEngineCharset.php
[Pman.Core] / UpdateDatabase / MysqlEngineCharset.php
index 6ec6706..0d3d872 100644 (file)
@@ -7,14 +7,24 @@
 class Pman_Core_UpdateDatabase_MysqlEngineCharset {
     
     var $dburl;
-    var $schema;
-    var $links;
+    var $schema = array();
+    var $links = array();
+    var $views = array();
     
     function __construct()
     {
           
         $this->loadIniFiles(); //?? shared???
         
+        $dbo = DB_DataObject::factory('core_enum');
+        if (is_a($dbo, 'PDO_DataObject')) {
+            
+            $this->views = $dbo->generator()->introspection()->getListOf('views');
+        } else {
+            $db = DB_DataObject::factory('core_enum')->getDatabaseConnection();
+            $this->views = $db->getListOf( 'views');  // needs updated pear... 
+        }
+        
         // update the engine first - get's around 1000 character limit on indexes..cd
         // however - Innodb does not support fulltext indexes, so this may fail...
         $this->updateEngine(); 
@@ -32,10 +42,14 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
         $ff->generateDataobjectsCache(true);
         $this->dburl = parse_url($ff->database);
         
+         
         $dbini = 'ini_'. basename($this->dburl['path']);
         
         
-        $iniCache = $ff->DB_DataObject[$dbini];
+        $iniCache = isset( $ff->PDO_DataObject) ?  $ff->PDO_DataObject['schema_location'] : $ff->DB_DataObject[$dbini];
+        if (!file_exists($iniCache)) {
+            return;
+        }
         
         $this->schema = parse_ini_file($iniCache, true);
         $this->links = parse_ini_file(preg_replace('/\.ini$/', '.links.ini', $iniCache), true);
@@ -46,8 +60,7 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
    
     function updateCharacterSet()
     {
-        $db = DB_DataObject::factory('core_enum')->getDatabaseConnection();
-        $views = $db->getListOf(  'views');
+        $views = $this->views;
         
         
         foreach (array_keys($this->schema) as $tbl){
@@ -72,7 +85,7 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
                 WHERE
                         CCSA.collation_name = T.table_collation
                     AND
-                        T.table_schema = '{$ce->database()}' -- COLLATE utf8_general_ci
+                        T.table_schema = DATABASE() -- COLLATE utf8_general_ci
                     AND
                         T.table_name = '{$tbl}' -- COLLATE utf8_general_ci
             ");
@@ -101,20 +114,24 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
         $db = DB_DataObject::factory('core_enum');
         $db->query("show variables like 'innodb_file_per_table'");
         $db->fetch();
-        if ($db->Value == 'OFF') {
-            die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+        
+        $pg = HTML_FlexyFramework::get()->page;
+        
+        if (empty($pg->opts['skip-mysql-checks'])) {
+            if ($db->Value == 'OFF') {
+                die("Error: set innodb_file_per_table = 1 in my.cnf\n\n");
+            }
+            
         }
         
+        
         // get a list of table views...
         // innodb in single files is far more efficient that MYD or one big innodb file.
         // first check if database is using this format.
         
         
         
-        $db = DB_DataObject::factory('core_enum')->getDatabaseConnection();
-        $views = $db->getListOf(  'views');
-        
-        
+        $views = $this->views;
         
         
         foreach (array_keys($this->schema) as $tbl){
@@ -134,7 +151,7 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
                 from
                     information_schema.tables
                 where
-                    table_schema='{$ce->database()}'
+                    table_schema= DATABASE()
                     and
                     table_name = '{$tbl}'
             ");
@@ -147,6 +164,13 @@ class Pman_Core_UpdateDatabase_MysqlEngineCharset {
                 echo "InnoDB: SKIP $tbl\n";
                 continue;
             }
+            if($ce->engine == 'ndbcluster' ){
+                echo "ndbcluster: SKIP $tbl\n";
+                continue;
+            }
+            
+            // should really determine if we are running in cluster ready ...
+            
             // this used to be utf8_unicode_ci
             //as the default collation for stored procedure parameters is utf8_general_ci and you can't mix collations.