in Deutsh
in French
in Polish

You Are At Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

mysqli_stmt_affected_rows

(PHP 5)

mysqli_stmt_affected_rows

(no version information, might be only in CVS)

mysqli_stmt->affected_rows -- Returns the total number of rows changed, deleted, or inserted by the last executed statement

Description

Procedural style :

int mysqli_stmt_affected_rows ( mysqli_stmt stmt )

Object oriented style (property):

class mysqli_stmt {

int affected_rows

}

Returns the number of rows affected by INSERT, UPDATE, or DELETE query.

This function only works with queries which update a table. In order to get the number of rows from a SELECT query, use mysqli_stmt_num_rows() instead.

Parameters

stmt

Procedural style only: A statement identifier returned by mysqli_stmt_init().

Return Values

An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records where updated for an UPDATE/DELETE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query has returned an error.

Note: If the number of affected rows is greater than maximal PHP int value, the number of affected rows will be returned as a string value.

Examples

Example 1. Object oriented style

<?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();
}

/* create temp table */
$mysqli->query("CREATE TEMPORARY TABLE myCountry LIKE Country");

$query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?";

/* prepare statement */
if ($stmt = $mysqli->prepare($query)) {

    
/* Bind variable for placeholder */
    
$code = 'A%';
    
$stmt->bind_param("s", $code);

    
/* execute statement */
    
$stmt->execute();

    
printf("rows inserted: %d\n", $stmt->affected_rows);

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

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

Example 2. Procedural style

<?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();
}

/* create temp table */
mysqli_query($link, "CREATE TEMPORARY TABLE myCountry LIKE Country");

$query = "INSERT INTO myCountry SELECT * FROM Country WHERE Code LIKE ?";

/* prepare statement */
if ($stmt = mysqli_prepare($link, $query)) {

    
/* Bind variable for placeholder */
    
$code = 'A%';
    
mysqli_stmt_bind_param($stmt, "s", $code);

    
/* execute statement */
    
mysqli_stmt_execute($stmt);

    
printf("rows inserted: %d\n", mysqli_stmt_affected_rows($stmt));

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

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

The above example will output:

rows inserted: 17

See Also

mysqli_stmt_num_rows()
mysqli_prepare()

Karma pedigree - Najlepsza dla twojego zwierzaka
fotograf ślubny lublin
raty
forma spółki
Wykaz informacyjny dodaj stronę

Another Useful functions:


ref.pdo-mysql | ref.pdo-mysql.connection | ref.mysqli | ref.mysql | function.mysqli-warning-count | function.mysqli-use-result | function.mysqli-thread-safe | function.mysqli-thread-id | function.mysqli-store-result | function.mysqli-stmt-store-result | function.mysqli-stmt-sqlstate | function.mysqli-stmt-send-long-data | function.mysqli-stmt-result-metadata | function.mysqli-stmt-reset | function.mysqli-stmt-prepare | function.mysqli-stmt-param-count | function.mysqli-stmt-num-rows | function.mysqli-stmt-insert-id | function.mysqli-stmt-init | function.mysqli-stmt-get-warnings | function.mysqli-stmt-free-result | function.mysqli-stmt-field-count | function.mysqli-stmt-fetch | function.mysqli-stmt-execute | function.mysqli-stmt-error | function.mysqli-stmt-errno | function.mysqli-stmt-data-seek | function.mysqli-stmt-close | function.mysqli-stmt-bind-result | function.mysqli-stmt-bind-param | function.mysqli-stmt-attr-set | function.mysqli-stmt-attr-get | function.mysqli-stmt-affected-rows | function.mysqli-stat | function.mysqli-ssl-set | function.mysqli-sqlstate | function.mysqli-slave-query | function.mysqli-set-opt | function.mysqli-set-local-infile-handler | function.mysqli-set-local-infile-default | function.mysqli-set-charset | function.mysqli-server-init | function.mysqli-server-end | function.mysqli-send-query | function.mysqli-send-long-data | function.mysqli-select-db | function.mysqli-rpl-query-type | function.mysqli-rpl-probe | function.mysqli-rpl-parse-enabled | function.mysqli-rollback | function.mysqli-report | function.mysqli-real-query | function.mysqli-real-escape-string | function.mysqli-real-connect | function.mysqli-query | function.mysqli-prepare | function.mysqli-ping | function.mysqli-param-count | function.mysqli-options | function.mysqli-num-rows | function.mysqli-num-fields | function.mysqli-next-result | function.mysqli-multi-query | function.mysqli-more-results | function.mysqli-master-query | function.mysqli-kill | function.mysqli-insert-id | function.mysqli-init | function.mysqli-info | function.mysqli-get-warnings | function.mysqli-get-server-version | function.mysqli-get-server-info | function.mysqli-get-proto-info | function.mysqli-get-metadata | function.mysqli-get-host-info | function.mysqli-get-client-version | function.mysqli-get-client-info | function.mysqli-get-charset | function.mysqli-free-result | function.mysqli-field-tell | function.mysqli-field-seek | function.mysqli-field-count | function.mysqli-fetch | function.mysqli-fetch-row | function.mysqli-fetch-object | function.mysqli-fetch-lengths | function.mysqli-fetch-fields | function.mysqli-fetch-field | function.mysqli-fetch-field-direct | function.mysqli-fetch-assoc | function.mysqli-fetch-array | function.mysqli-execute | function.mysqli-escape-string | function.mysqli-error | function.mysqli-errno | function.mysqli-enable-rpl-parse | function.mysqli-enable-reads-from-master | function.mysqli-embedded-server-start | function.mysqli-embedded-server-end | function.mysqli-dump-debug-info | function.mysqli-disable-rpl-parse | function.mysqli-disable-reads-from-master | function.mysqli-debug | function.mysqli-data-seek | function.mysqli-connect | function.mysqli-connect-error | function.mysqli-connect-errno | function.mysqli-commit | function.mysqli-close | function.mysqli-client-encoding | function.mysqli-character-set-name | function.mysqli-change-user | function.mysqli-bind-result | function.mysqli-bind-param | function.mysqli-autocommit | function.mysqli-affected-rows | function.mysql-unbuffered-query | function.mysql-thread-id | function.mysql-tablename | function.mysql-stat | function.mysql-select-db | function.mysql-result | function.mysql-real-escape-string | function.mysql-query | function.mysql-ping | function.mysql-pconnect | function.mysql-num-rows | function.mysql-num-fields | function.mysql-list-tables | function.mysql-list-processes | function.mysql-list-fields | function.mysql-list-dbs | function.mysql-insert-id | function.mysql-info | function.mysql-get-server-info | function.mysql-get-proto-info | function.mysql-get-host-info | function.mysql-get-client-info | function.mysql-free-result | function.mysql-field-type | function.mysql-field-table | function.mysql-field-seek | function.mysql-field-name | function.mysql-field-len | function.mysql-field-flags | function.mysql-fetch-row | function.mysql-fetch-object | function.mysql-fetch-lengths | function.mysql-fetch-field | function.mysql-fetch-assoc | function.mysql-fetch-array | function.mysql-escape-string | function.mysql-error | function.mysql-errno | function.mysql-drop-db | function.mysql-db-query | function.mysql-db-name | function.mysql-data-seek | function.mysql-create-db | function.mysql-connect | function.mysql-close | function.mysql-client-encoding | function.mysql-change-user | function.mysql-affected-rows |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.