Heim  >  Artikel  >  Backend-Entwicklung  >  PHP与MYSQL交互函数表学习笔记_PHP教程

PHP与MYSQL交互函数表学习笔记_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:33:21750Durchsuche

最近一直在研究php(做为现在的主流开发语言)与MySQL(和PHP搭配之最佳组合),感觉php(做为现在的主流开发语言)与MySQL(和PHP搭配之最佳组合)交互的函数都是过程化的,当然也有MySQL(和PHP搭配之最佳组合)i扩展,面向对象,Java和C#写多了之后,再写php(做为现在的主流开发语言),有些不适应,感觉又回到了学C的年代。今天学习了一些函数,记录下来,以便日后忘记时,可以参考。

说 明 函 数 名 函 数 详 细 函 数 说 明
建立数据库连接 MySQL(和PHP搭配之最佳组合)_connect() resource MySQL(和PHP搭配之最佳组合)_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
示例:$conn = @MySQL(和PHP搭配之最佳组合)_connect("localhost", "username", "password") or dir("不能连接到MySQL(和PHP搭配之最佳组合) Server");
使用该连接必须显示的关闭连接
建立数据库连接 MySQL(和PHP搭配之最佳组合)_pconnect() resource MySQL(和PHP搭配之最佳组合)_pconnect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
示例:$conn = @MySQL(和PHP搭配之最佳组合)_pconnect("localhost", "username", "password") or dir("不能连接到MySQL(和PHP搭配之最佳组合) Server");
使用该连接函数不需要显示的关闭连接,它相当于使用了连接池
关闭数据库连接 MySQL(和PHP搭配之最佳组合)_close() $conn = @MySQL(和PHP搭配之最佳组合)_connect("localhost", "username", "password") or die("不能连接到MySQL(和PHP搭配之最佳组合) Server");
@MySQL(和PHP搭配之最佳组合)_select_db("MyDatabase") or die("不能选择这个数据库,或数据库不存在");
echo "你已经连接到MyDatabase数据库";
MySQL(和PHP搭配之最佳组合)_close();
 
选择数据库 MySQL(和PHP搭配之最佳组合)_select_db() boolean MySQL(和PHP搭配之最佳组合)_select_db(string db_name [, resource link_id])
$conn = @MySQL(和PHP搭配之最佳组合)_connect("localhost", "username", "password") or die("不能连接到MySQL(和PHP搭配之最佳组合) Server");
@MySQL(和PHP搭配之最佳组合)_select_db("MyDatabase") or die("不能选择这个数据库,或数据库不存在");
www.bkjia.comtruehttp://www.bkjia.com/PHPjc/508626.htmlTechArticle最近一直在研究php (做为现在的主流开发语言) 与MySQL (和PHP搭配之最佳组合) ,感觉php (做为现在的主流开发语言) 与MySQL (和PHP搭配之最佳组...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn