转换PHP代码到c#尝试make程序将myisam db转换为innodb

时间:2015-06-25 09:48:14

标签: c# php mysql

我正在尝试制作一个将MYISAM转换为INNODB的应用

如果发现这个PHP脚本代码

<?php
    // connect your database here first 
    // 

    // Actual code starts here 

    $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_SCHEMA = 'your_database_name' 
        AND ENGINE = 'MyISAM'";

    $rs = mysql_query($sql);

    while($row = mysql_fetch_array($rs))
    {
        $tbl = $row[0];
        $sql = "ALTER TABLE `$tbl` ENGINE=INNODB";
        mysql_query($sql);
    }
?>

然后我试着把它变成i#c

public static void UpdateDB()
        {
            using (var cnn = new MYSQLCONNECTION(con))
            {
                cnn.Open();
                using (var cmd = new MYSQLCOMMAND("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + db + "' AND ENGINE = 'MyISAM'", cnn))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {

                        }   
                    }
                }
            }
        }

我无法理解这些代码是什么意思

$tbl = $row[0];
$sql = "ALTER TABLE `$tbl` ENGINE=INNODB";
mysql_query($sql);

我试过,但我失败了任何人都可以帮助我

感谢

0 个答案:

没有答案