php mysqli类的演示例子
分享一个php使用mysqli类的例子,并附有mysqli类中的方法说明,很全面的,有需要的朋友参考下吧。
php调用mysqli类的例子,代码如下: <? set_time_limit(0); $mysql_cfg["host"]="localhost"; //主机 $mysql_cfg["port"] = 6033; //端口 $mysql_cfg["user"] = "root"; //用户名 $mysql_cfg["pass"]= "pass11";//密码 $mysql_cfg["db"]='test'; //数据库 $db = new mysqli($mysql_cfg["host"], $mysql_cfg["user"], $mysql_cfg["pass"],$mysql_cfg["db"],$mysql_cfg["port"]); $db->set_charset("utf8"); $query = "SELECT * from part"; if ($result = $db->query($query)) { while ($row = $result->fetch_assoc()) { printf ("%s (%s)\n", $row['id'], $row['cn_name']); } $result->close(); } $db->close(); //mysqli类的实例 ?> Copy after login mysqli类中的方法,说明: mysqli_affected_rows -返回一个MySQL操作受影响的行数 mysqli_autocommit -开启或关闭 autocommit 数据库修改 mysqli_bind_param -别名mysqli_stmt_bind_param ( ) mysqli_bind_result -别名mysqli_stmt_bind_result ( ) mysqli_change_user -更改指定数据库连接的用户 mysqli_character_set_name -返回数据库连接的默认字符集 mysqli_client_encoding -别名mysqli_character_set_name ( ) mysqli_close -关闭当前打开数据库连接 mysqli_commit -当前事物 mysqli_connect_errno -返回最后一次操作的错误代码 mysqli_connect_error -返回最后一次操作的错误字符串描述 mysqli_connect -打开一个新的连接到MySQL服务器 mysqli_data_seek -在当前记录结果集中任意移动行指针 mysqli_debug -调试 mysqli_disable_reads_from_master -禁用读取主对像 mysqli_disable_rpl_parse -禁用RPL解析 mysqli_dump_debug_info -转储调试信息的日志 mysqli_embedded_connect -打开一个连接到嵌入式MySQL服务器 mysqli_enable_reads_from_master -启用内容由主 mysqli_enable_rpl_parse -启用RPL解析 mysqli_errno -返回错误代码最近函数调用 mysqli_error -返回一个字符串描述过去的错误 mysqli_escape_string -别名mysqli_real_escape_string ( ) mysqli_execute -别名mysqli_stmt_execute ( ) mysqli_fetch_array -从结果集中取得一行作为关联,数字数组,或两者兼施 mysqli_fetch_assoc -从结果集中取得一行作为关联数组 mysqli_fetch_field_direct -获取元数据的一个单一的领域 mysqli_fetch_field -返回明年领域中的结果集 mysqli_fetch_fields -返回一个数组对象代表领域的结果集 mysqli_fetch_lengths -返回长度列的当前行的结果集 mysqli_fetch_object -返回当前行的结果集作为一个对象 mysqli_fetch_row -取得结果集中取得一行作为枚举数组 mysqli_fetch -别名mysqli_stmt_fetch ( ) mysqli_field_count -返回的列数最近查询 mysqli_field_seek -设为结果指针到指定的外地抵消 mysqli_field_tell -获取当前外地抵消的结果指针 mysqli_free_result -释放内存与结果 mysqli_get_client_info -返回MySQL客户端版本作为一个字符串 mysqli_get_client_version -取得MySQL客户端信息 mysqli_get_host_info -返回一个字符串代表的连接类型使用 mysqli_get_metadata -别名mysqli_stmt_result_metadata ( ) mysqli_get_proto_info -返回版本的MySQL使用协议 mysqli_get_server_info -返回版本的MySQL服务器 mysqli_get_server_version -返回版本的MySQL服务器作为一个整数 mysqli_info -检索信息,最近执行的查询 mysqli_init -初始化MySQLi并返回一个资源使用mysqli_real_connect ( ) mysqli_insert_id -返回自动生成的编号使用最后查询 mysqli_kill -要求服务器要杀死一个MySQL线程 mysqli_master_query -强制执行查询总在主/从设置 mysqli_more_results -检查是否有任何更多的查询结果来自一个多查询 mysqli_multi_query -执行查询数据库 mysqli_next_result -准备明年的结果multi_query mysqli_num_fields -获取的若干领域中的结果 mysqli_num_rows -获取的行数的结果 mysqli_options -设置选项 mysqli_param_count -别名mysqli_stmt_param_count ( ) mysqli_ping -的Ping一个服务器连接,或尝试重新连接,如果已下降 mysqli_prepare -准备一个SQL语句的执行 mysqli_query -执行查询数据库 mysqli_real_connect -打开一个连接到MySQL服务器 mysqli_real_escape_string -转义特殊字符的字符串,用于SQL语句,并考虑到当前的字符集的连接 mysqli_real_query -执行一个SQL查询 mysqli_report -启用或禁用内部报告功能 mysqli_rollback -回滚当前事务 mysqli_rpl_parse_enabled -检查是否启用RPL解析 mysqli_rpl_probe - RPL探针 mysqli_rpl_query_type -返回RPL查询类型 mysqli_select_db -选择的默认数据库数据库查询 mysqli_send_long_data -别名mysqli_stmt_send_long_data ( ) mysqli_send_query -发送查询并返回 mysqli_server_end -关机嵌入式服务器 mysqli_server_init -初始化嵌入式服务器 mysqli_set_charset -集的默认客户端字符集 mysqli_set_opt -别名mysqli_options ( ) mysqli_sqlstate -返回SQLSTATE错误从一个MySQL操作 mysqli_ssl_set -用于建立安全连接使用SSL mysqli_stat -获取当前的系统状态 mysqli_stmt_affected_rows -返回总数列改变,删除或插入的最后执行的声明 mysqli_stmt_bind_param -绑定变量一份声明作为参数 mysqli_stmt_bind_result -绑定变量的一份声明中存储的结果 mysqli_stmt_close -关闭一份声明 mysqli_stmt_data_seek -寻找一个任意行声明的结果集 mysqli_stmt_errno -返回错误代码的最新声明呼吁 mysqli_stmt_error -返回一个字符串描述最后声明错误 mysqli_stmt_execute -执行一个准备查询 mysqli_stmt_fetch -获取结果一份准备好的声明中纳入约束变量 mysqli_stmt_free_result -免储存记忆的结果给予处理的声明 mysqli_stmt_init -初始化了言,并返回一个对象,用于mysqli_stmt_prepare mysqli_stmt_num_rows -返回的行数报表结果集 mysqli_stmt_param_count -返回一些参数给定的声明 mysqli_stmt_prepare -准备一个SQL语句的执行 mysqli_stmt_reset -重置一份声明 mysqli_stmt_result_metadata -返回结果集元数据的一份书面声明 mysqli_stmt_send_long_data -发送数据块 mysqli_stmt_sqlstate -返回SQLSTATE错误行动从以往的声明 mysqli_stmt_store_result -转让的结果集由一份声明 mysqli_store_result -转让的结果集的最后查询 mysqli_thread_id -返回线程ID为当前连接 mysqli_thread_safe -返回是否线程安全考虑或不 mysqli_use_result -开创检索结果集 mysqli_warning_count -返回一些警告过去查询提供链接 |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

In PHPOOP, self:: refers to the current class, parent:: refers to the parent class, static:: is used for late static binding. 1.self:: is used for static method and constant calls, but does not support late static binding. 2.parent:: is used for subclasses to call parent class methods, and private methods cannot be accessed. 3.static:: supports late static binding, suitable for inheritance and polymorphism, but may affect the readability of the code.

PHP handles file uploads through the $\_FILES variable. The methods to ensure security include: 1. Check upload errors, 2. Verify file type and size, 3. Prevent file overwriting, 4. Move files to a permanent storage location.
