ホームページ >バックエンド開発 >PHPチュートリアル >比較的完全な関数を備えたデータベース操作クラス_PHP チュートリアル
<ol class="dp-c"> <li class="alt"><span><span><?php </span></span></li><li><span class="comment">/* </span> </li><li class="alt"><span><span class="comment">* 著者 墨龙 </span> </span></li><li><span><span class="comment">* 時間 2 010年12月2日 15:50:35 </span> </span></li><li class="alt"><span><span class="comment"> */</span><span> </span></span></li><li><span> </span></li><li class="alt"><span class="vars">$db</span><span> = </span><span class="keyword">new</span><span> mysql(</span><span class="vars">$db_host</span><span>,</span><span class="vars">$db _user</span><span>,</span><span class="vars">$db_password</span><span>,</span><span class="vars">$db_table </span><span>,</span><span class="vars">$db_conn</span><span>,</span><span class="vars">$pre</span><span>,</span><span class="vars">$coding</span><span>); </span></li><li><span> </span></li><li class="alt"><span class="keyword">class</span><span> mysql{ </span></li><li><span> </span></li><li class="alt"><span> </span><span class="keyword">private</span><span> </span><span class="vars">$db_host</span><span>; </span></li><li><span> </span><span class="keyword">プライベート</span><span> </span><span class="vars">$db_user</span><span>; </span></li><li class="alt"><span> </span><span class="keyword">プライベート</span><span> </span><span class="vars">$db_password</span><span>; </span></li><li><span> </span><span class="keyword">プライベート</span><span> </span><span class="vars">$db_table</span><span>; </span></li><li class="alt"><span> </span><span class="keyword">プライベート</span><span> </span><span class="vars">$db_conn</span><span>; </span><span class="comment">//データ库连接标识; </span><span> </span></li><li><span> </span><span class="keyword">プライベート</span><span> </span><span class="vars">$result</span><span>; </span><span class="comment">//実行クエリコマンドの結果资源标识 </span><span> </span></li><li class="alt"><span> </span><span class="keyword">private</span><span> </span><span class="vars">$sql</span><span>; </span><span class="comment">//sql执行语句 </span><span> </span></li><li><span> </span><span class="keyword">private</span><span> </span><span class="vars">$pre</span><span>; </span><span class="comment">//データベース库表前缀 </span><span> </span></li><li class="alt"><span> </span><span class="keyword">private</span><span> </span><span class="vars">$coding</span><span>; </span><span class="comment">//データ库编、GBK,UTF8,gb2312 </span><span> </span></li><li><span> </span></li><li class="alt"><span> </span></li><li><span> </span><span class="keyword">関数</span><span> __construct(</span><span class="vars">$db_host</span><span>,</span><span class="vars">$db_user</span><span>,</span><span class="vars">$ db_password</span><span>、</span><span class="vars">$db_table</span><span>、</span><span class="vars">$db_conn</span><span>、</span><span class="vars">$pre</span><span>、</span><span class="vars">$coding</span><span>){ </span></li><li class="alt"><span> </span></li><li><span> </span><span class="vars">$this</span><span>-> db_host = </span><span class="vars">$db_host</span><span>; </span></span></li> <li class="alt"> <span> </span><span class="vars">$this</span><span>->db_user = </span><span class="vars">$db_user</span><span>; </span> </li> <li> <span> </span><span class="vars">$this</span><span>->db_password = </span><span class="vars">$db_password</span><span>; </span> </li> <li class="alt"> <span> db_conn = </span><span class="vars">$db_conn</span><span>; </span><span class="vars"></span><span> </span> </li>->pre = <li> <span>$pre</span><span class="vars">; </span><span></span><span class="vars"> </span><span>$this</span> </li>->coding = <li class="alt"> <span>$coding</span><span class="vars"> ; </span><span></span><span class="vars"> </span><span>$this</span> </li>->接続 (); <li> <span></span><span class="vars"> (</span><span>$this</span><span class="vars">->db_host,</span><span>$this</span> </li>->db_user,<li class="alt"> <span>$this</span><span class="vars">->db_password) </span><span>or</span> </li> <li><span>die</span></li>( <li class="alt"> <span>$this</span> </li>->show_error(<li><span>"データベース リンク エラー。データベース リンクの構成を確認してください。"</span></li>) ); gt; db_table、<li class="alt">$ this&gt; db_conn)){<span></span><span class="keyword"></span>$ this $ this-&gt; db_table; <span></span> </li>http://www.bkjia.com/PHPjc/486033.html<li><span>www.bkjia.com</span></li>true<li class="alt"> <span>http://www.bkjia.com/PHPjc/486033.html</span><span class="vars">技術記事</span><span> ?php /* *作成者 Molong*Time December 2, 2010 15:50:35 */ $db = new mysql( $db_host , $db_user , $db_password , $db_table , $db_conn , $pre , $coding ); { プライベート $db_host...</span><span class="vars"></span><span> </span><span class="vars"></span> </li> </ol>