mysqli_stmt::$param_count

mysqli_stmt_param_count

(PHP 5, PHP 7)

mysqli_stmt::$param_count -- mysqli_stmt_param_countReturns the number of parameter for the given statement

说明

面向对象风格

过程化风格

mysqli_stmt_param_count ( mysqli_stmt $stmt ) : int

Returns the number of parameter markers present in the prepared statement.

参数

stmt

仅以过程化样式:由 mysqli_stmt_init() 返回的 statement 标识。

返回值

Returns an integer representing the number of parameters.

范例

Example #1 面向对象风格

<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

if (
$stmt $mysqli->prepare("SELECT Name FROM Country WHERE Name=? OR Code=?")) {

    
$marker $stmt->param_count;
    
printf("Statement has %d markers.\n"$marker);

    
/* close statement */
    
$stmt->close();
}

/* close connection */
$mysqli->close();
?>

Example #2 过程化风格

<?php
$link 
mysqli_connect("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

if (
$stmt mysqli_prepare($link"SELECT Name FROM Country WHERE Name=? OR Code=?")) {

    
$marker mysqli_stmt_param_count($stmt);
    
printf("Statement has %d markers.\n"$marker);

    
/* close statement */
    
mysqli_stmt_close($stmt);
}

/* close connection */
mysqli_close($link);
?>

以上例程会输出:

Statement has 2 markers.

参见

相关文章
php ibm db2 函数 returns the number of rows affected by an sql statementphp maxdb 函数 returns the number of parameter for the given statementphp maxdb 函数 returns the number of warnings from the last query for the given linkphp sqlite 函数 returns the number of rows that were changed by the most recent sql statementphp mysqli stmt returns the total number of rows changed deleted or inserted by the last executed statementphp mysqli stmt used to get the current value of a statement attributephp mysqli stmt returns the error code for the most recent statement callphp mysqli stmt returns a list of errors from the last statement executedphp mysqli stmt returns a string description for last statement errorphp mysqli stmt returns the number of field in the given statementphp mysqli stmt frees stored result memory for the given statement handlephp mysqli stmt gets a result set from a prepared statementphp mysqli stmt returns the number of parameter for the given statementphp mysqli stmt returns result set metadata from a prepared statementphp mysqli stmt returns sqlstate error from previous statement operationphp mysqli returns the number of columns for the most recent queryphp mysqli returns the number of warnings from the last query for the given linkphp mysqlnduhconnection initializes a statement and returns a resource for use with mysqli statement preparephp sqlite3stmt returns the number of parameters within the prepared statementphp sqlite3stmt returns whether a statement is definitely read only
关注编程学问公众号