PageRenderTime 150ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Upload/documents/handbook/developer-guide/developer-guide-safe/to-prevent-sql-injection.html

http://dyhb-frame.googlecode.com/
HTML | 112 lines | 107 code | 5 blank | 0 comment | 0 complexity | 424f89460582c53a0d0544965cb7bb06 MD5 | raw file
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>The DoYouHaoBaby PHP Framework For PHP5 | ????????</title>
  5. <meta http-equiv="content-type" content="text/html; charset=gbk" />
  6. <meta name="Author" content="???Dyhb">
  7. <meta name="Keywords" content="DoYouHaoBaby,Framework">
  8. <meta name="Description" content="The DoYouHaoBaby PHP Framework | ?????????????">
  9. <link rel="stylesheet" type="text/css" href="./../../media/css/style.css" />
  10. <link rel="stylesheet" type="text/css" href="./../../media/css/highlight.css" />
  11. </head>
  12. <body style="margin:0">
  13. <div id="header"><img src="./../../media/images/logo.png" border="0" title="The DoYouHaoBaby PHP Framework Logo" ></div>
  14. <div id="content">
  15. <div id="version">
  16. The DoYouHaoBaby PHP Framework????????<br>
  17. Copyright(c) <a href="http://doyouhaobaby.net">DoYouHaoBaby.NET</a>
  18. All Rights Reserved.
  19. </div>
  20. <div class="menu">
  21. <table cellspacing=0 cellpadding=0 width="95%" border=0>
  22. <tbody>
  23. <tr>
  24. <th align=middle colspan=3>The DoYouHaoBaby PHP Framework????????</th>
  25. </tr>
  26. <tr>
  27. <td valign=bottom align=left width="25%">
  28. <a accesskey="p" href="../../index.html">??</a>?
  29. </td>
  30. <td valign=bottom align=middle width="50%">
  31. </td>
  32. <td valign=bottom align=right width="25%">
  33. <a accesskey="n" href="./index.html">??</a>
  34. </td>
  35. </tr>
  36. </tbody>
  37. </table>
  38. </div>
  39. <div id="box">
  40. <div class="title">[ ??SQL?? ]</div>
  41. <div class="detail">
  42. <p>
  43. ??WEB?????SQL???????????????????????????????????????????????????</p>
  44. <p>
  45. ?????????<span style="color: rgb(0, 128, 0);"><strong>DoYouHaoBaby\LibPHP\App\Package\Db\DbObj\DbObjDriver\DbQualifyStrMysql.class.php</strong></span>?????????</p>
  46. <p><DIV class=dp-highlighter><DIV class=bar></DIV>
  47. <OL class=dp-j>
  48. <LI class=alt><SPAN><SPAN class=keyword>public</SPAN><SPAN>&nbsp;function&nbsp;qualifyStr($Value){ &nbsp;&nbsp;</SPAN></SPAN></LI>
  49. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>if</SPAN><SPAN>(is_array($Value)){</SPAN><SPAN class=comment>//&nbsp;????? </SPAN><SPAN>&nbsp;&nbsp;</SPAN></SPAN></LI>
  50. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach($Value&nbsp;as&nbsp;$nOffset=&gt;&nbsp;$sV){ &nbsp;&nbsp;</SPAN></LI>
  51. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Value[$nOffset]=$</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;qualifyStr($sV); &nbsp;&nbsp;</SPAN></SPAN></LI>
  52. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</SPAN></LI>
  53. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;$Value; &nbsp;&nbsp;</SPAN></SPAN></LI>
  54. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</SPAN></LI>
  55. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>if</SPAN><SPAN>(is_int($Value)){&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;$Value;&nbsp;}</SPAN><SPAN class=comment>//&nbsp;int </SPAN><SPAN>&nbsp;&nbsp;</SPAN></SPAN></LI>
  56. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>if</SPAN><SPAN>(is_bool($Value)){ &nbsp;&nbsp;</SPAN></SPAN></LI>
  57. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;$Value?$</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;_oConnect-&gt;getTrueValue():&nbsp;$</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;_oConnect-&gt;getFalseValue(); &nbsp;&nbsp;</SPAN></SPAN></LI>
  58. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</SPAN></LI>
  59. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>if</SPAN><SPAN>(is_null($Value)){</SPAN><SPAN class=comment>//&nbsp;Null? </SPAN><SPAN>&nbsp;&nbsp;</SPAN></SPAN></LI>
  60. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;$</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;_oConnect-&gt;getNullValue(); &nbsp;&nbsp;</SPAN></SPAN></LI>
  61. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</SPAN></LI>
  62. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>if</SPAN><SPAN>(!($Value&nbsp;</SPAN><SPAN class=keyword>instanceof</SPAN><SPAN>&nbsp;DbExpression)){ &nbsp;&nbsp;</SPAN></SPAN></LI>
  63. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;G::getMagicQuotesGpc()?</SPAN><SPAN class=string>"'"</SPAN><SPAN>.$Value.</SPAN><SPAN class=string>"'"</SPAN><SPAN>:</SPAN><SPAN class=string>"'"</SPAN><SPAN>.mysql_real_escape_string($Value,$</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;_oConnect-&gt;getCurrentConnect()).</SPAN><SPAN class=string>"'"</SPAN><SPAN>; &nbsp;&nbsp;</SPAN></SPAN></LI>
  64. <LI class=alt><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;</SPAN></LI>
  65. <LI><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=keyword>return</SPAN><SPAN>&nbsp;$Value-&gt;makeSql($</SPAN><SPAN class=keyword>this</SPAN><SPAN>-&gt;_oConnect); &nbsp;&nbsp;</SPAN></SPAN></LI>
  66. <LI class=alt><SPAN>&nbsp;}&nbsp;&nbsp;</SPAN></LI></OL></DIV></p>
  67. <p>
  68. ???</p>
  69. <p><DIV class=dp-highlighter><OL class=dp-j>
  70. <LI class=alt><SPAN><SPAN>$oUser=UserModel::F('user_id=?',$_GET['id'])-&gt;getOne();&nbsp;&nbsp;</SPAN></SPAN></LI></OL></DIV></p>
  71. <p>
  72. ????????????id????????????????????????DoYouHaoBaby ???????CURD??????????????????</p>
  73. <p>
  74. ???????????????????????????????????????????????????SQL??????????</p>
  75. <p>
  76. ????????????????????????????</p>
  77. <p>
  78. ??????????????????????????<span style="color: rgb(255, 0, 0);"><strong>??????</strong></span></p>
  79. <p>
  80. ??????????????????????????</p>
  81. <p>
  82. ?????????????????<DIV class=dp-highlighter><OL class=dp-j>
  83. <LI class=alt><SPAN><SPAN>$nId=intval(G::getGpc('id','G'));&nbsp;&nbsp;</SPAN></SPAN></LI></OL></DIV></p>
  84. <p>
  85. ??????????????????????????????</p>
  86. </div>
  87. </div>
  88. <div class="menu">
  89. <table cellspacing=0 cellpadding=0 width="95%" border=0>
  90. <tbody>
  91. <tr>
  92. <td valign=top align=middle width="34%">
  93. <a accesskey="h" href="../../index.html">??</a>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td valign=top align=middle width="34%">
  98. <a accesskey="u" href="./index.html">??</a>
  99. </td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. </div>
  104. </div>
  105. <div id="footer">Copyright (c) <a href="http://doyouhaobaby.net" title="The DoYouHaoBaby Framework" >DoYouHaoBaby</a> All rights reserved.?</div>
  106. </body>
  107. </html>