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 imap 函数 this function returns the uid for the given message sequence numberphp maxdb 函数 returns the total number of rows changed deleted or inserted by the last executed statementphp maxdb 函数 returns the number of parameter for the given statementphp mysqli stmt returns the total number of rows changed deleted or inserted by the last executed statementphp mysqli stmt seeks to an arbitrary row in statement result setphp 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 returns the number of parameter for the given statementphp mysqli stmt prepare an sql statement for executionphp mysqli stmt resets a prepared 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 warnings from the last query for the given linkphp sqlite3 returns the number of database rows that were changed or inserted or deleted by the most recent sql statementphp sqlite3stmt binds a parameter to a statement variablephp sqlite3stmt binds the value of a parameter to a statement variablephp sqlite3stmt returns the number of parameters within the prepared statement
关注编程学问公众号