drsvw88664
2011-08-17 08:06
浏览 67

将ASP.net代码转换为PHP&mysql [关闭]

i was looking out for something to convert my asp.net code to php & mysql.

I used a website that claimed to be able to convert but it seems to be not so great when it comes to performance.

I don't know how easy or tough it is to do the conversion as I don't have knowledge of either but I learnt a bit of PHP through w3schools and got an example to refer from a php document to do some of my conversion from .net to php.

The thing is that there is a certain bit of code where I'm unable to think where to proceed from there.

if anyone can help me with this? The correct reply could be useful to anybody else referring for a conversion from asp.net to php and mysql. There is no other post that I found for my question on stack overflow.

<WebMethod()> _
    Public Function saveBeerPot(ByVal Potdata As XmlElement) As String
        Dim PotXml As New XmlDocument
        PotXml.LoadXml(Server.HtmlDecode(Potdata.OuterXml))
        Dim m_nodelist As XmlNodeList

        m_nodelist = PotXml.SelectNodes("/DocumentElement/Table")
        Dim status As String = "no data"

        Dim _connectionString As String
        Dim strSQL As String

        Try
            _connectionString = ConfigurationManager.ConnectionStrings("AESSYSTEM_DB").ConnectionString
            Dim sqldb As New SqlDatabase(_connectionString)

            Dim XmlNode = PotXml.FirstChild

            Dim xmlNodeT = XmlNode.FirstChild

            m_nodelist = xmlNodeT.ChildNodes


            If m_nodelist.Count > 0 Then

                Dim _pot_id = m_nodelist.Item(0).InnerText
                Dim _pot_name = m_nodelist.Item(1).InnerText
                Dim _owner_user_id = m_nodelist.Item(2).InnerText
                Dim _language_id = m_nodelist.Item(3).InnerText
                Dim _currency_id = m_nodelist.Item(4).InnerText
                Dim _skin_id = m_nodelist.Item(5).InnerText
                Dim _minimum_check = m_nodelist.Item(6).InnerText
                Dim _minimum_amount = m_nodelist.Item(7).InnerText.Replace(",", ".")
                Dim _pot_fund = m_nodelist.Item(8).InnerText.Replace(",", ".")
                Dim _password = m_nodelist.Item(9).InnerText

                status += _password
                If _minimum_amount.Length = 0 Then
                    _minimum_amount = "0"
                End If

                If _pot_id.Length = 0 Then

                    Dim _pot_guid = generateGuid()
                    strSQL = "INSERT INTO POT (pot_name, owner_user_id, language_id, currency_id, skin_id, minimum_check, minimum_amount, pot_fund,pot_guid,password,checkout,lastcheckout,autoupdate,created_date,nextautoupdatedate)"
                    strSQL += " values('" + _pot_name + "', '" +
_owner_user_id + "', '" + _language_id + "', '" + _currency_id + "', '" + _skin_id + "', '" + _minimum_check + "', '" + _minimum_amount + "', '" + _pot_fund + "', '" + _pot_guid + "', '" + _password + "','0','0','8','" + System.DateTime.Today.ToString + "','" + System.DateTime.Today.ToString + "')"
                    strSQL += "SELECT IDENT_CURRENT('POT');"

                    _pot_id = sqldb.ExecuteScalar(strSQL, CommandType.Text).ToString()
                    strSQL = "INSERT INTO PotUsers (pot_id,user_id,current_amount)"
                    strSQL += "values('" + _pot_id + "','" +
_owner_user_id + "', '0')"
                Else

                    strSQL = "UPDATE POT SET pot_name = '" + _pot_name
+ "', language_id = '" + _language_id + "', currency_id = '" +
_currency_id + "', skin_id = '" + _skin_id + "', minimum_check = '" +
_minimum_check + "', minimum_amount = '" + _minimum_amount + "'"
                    strSQL += " WHERE pot_id = '" + _pot_id + "'"

                    status += strSQL
                End If

                sqldb.ExecuteNonQuery(strSQL, CommandType.Text)
                status = "inserted"
            End If
            Return status


        Catch ex As Exception
            status += ex.Message
            Return status
        End Try

    End Function
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutui2016 2011-08-17 08:19
    已采纳

    You won't find a perfect conversion tool from .NET to PHP, it will most probably require some effort on your behalf...

    I think you just need to look at this in separate chunks and break the code down. If you use MSDN and search for things like WebMethod and the other types and methods you are unsure about you should be able to piece it together in PHP in not too much time.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题