diff --git a/reference/mysqli/functions/mysqli-real-escape-string.xml b/reference/mysqli/functions/mysqli-real-escape-string.xml
index 7dd1d5f042..4793cad79e 100644
--- a/reference/mysqli/functions/mysqli-real-escape-string.xml
+++ b/reference/mysqli/functions/mysqli-real-escape-string.xml
@@ -1,5 +1,5 @@
-
+
mysqli_real_escape_string
@@ -47,6 +47,86 @@
mysqli_character_set_name.
+
+ Example
+
+ Object oriented style
+
+query("CREATE TEMPORARY TABLE myCity LIKE City");
+
+$city = "'s Hertogenbosch";
+
+/* this query will fail, cause we didn't escape $city */
+if (!$mysqli->query("INSERT into myCity (Name) VALUES ('$city')")) {
+ printf("Error: %s\n", $mysqli->sqlstate);
+}
+
+$city = $mysqli->real_escape_string($city);
+
+/* this query with escaped $city will work */
+if ($mysqli->query("INSERT into myCity (Name) VALUES ('$city')")) {
+ printf("%d Row inserted.\n", $mysqli->affected_rows);
+}
+
+$mysqli->close();
+?>
+]]>
+
+
+
+ Procedural style
+
+
+]]>
+
+
+
+ The above examples would produce the following output:
+
+
+
+
+
+
mysqli_report
@@ -65,51 +65,27 @@
Object oriented style
query("DROP TABLE IF EXISTS report");
-$mysqli->query("CREATE TABLE report (a int, b int, index(a))");
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
-$mysqli->query("INSERT INTO report VALUES (1,1), (2,2), (1,3), (2,4), (6,5)");
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
-/* this should report syntax error */
-$mysqli->query("UPDAE report SET a=a+1 WHERE b=3");
+/* this query should report an error */
+$result = $mysqli->query("SELECT Name FROM Nonexistingtable WHERE population > 50000");
-/* this should report index warning */
-$mysqli->query("UPDATE report SET a=a+1 WHERE b=3");
+/* this query should report a warning */
+$result = $mysqli->query("SELECT Name FROM City WHERE population > 50000");
+$result->close();
$mysqli->close();
?>
-]]>
-
-
-
- Object oriented style
-
-
]]>
diff --git a/reference/mysqli/functions/mysqli-rollback.xml b/reference/mysqli/functions/mysqli-rollback.xml
index fb6b7f7355..ff3610517c 100644
--- a/reference/mysqli/functions/mysqli-rollback.xml
+++ b/reference/mysqli/functions/mysqli-rollback.xml
@@ -1,5 +1,5 @@
-
+
mysqli_rollback
@@ -39,63 +39,118 @@
- Examples
-
-
- Object oriented style
-
+ Example
+
+ Object oriented style
+
query("DROP TABLE IF EXISTS ta_sample");
-$mysqli->query("CREATE TABLE ta_sample (a int) TYPE=InnoDB");
-
-/* set autocommit to off */
+/* disable autocommit */
$mysqli->autocommit(FALSE);
-/* Insert some values */
-$mysqli->query("INSERT INTO ta_sample VALUES (1)");
-$mysqli->query("INSERT INTO ta_sample VALUES (1)");
+$mysqli->query("CREATE TABLE myCity LIKE City");
+$mysqli->query("ALTER TABLE myCity Type=InnoDB");
+$mysqli->query("INSERT INTO myCity SELECT * FROM City LIMIT 50");
-/* rollback transaction */
+/* commit insert */
+$mysqli->commit();
+
+/* delete all rows */
+$mysqli->query("DELETE FROM myCity");
+
+if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) {
+ $row = $result->fetch_row();
+ printf("%d rows in table myCity.\n", $row[0]);
+ /* Free result */
+ $result->close();
+}
+
+/* Rollback */
$mysqli->rollback();
-/* close connection */
+if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) {
+ $row = $result->fetch_row();
+ printf("%d rows in table myCity (after rollback).\n", $row[0]);
+ /* Free result */
+ $result->close();
+}
+
+/* Drop table myCity */
+$mysqli->query("DROP TABLE myCity");
+
$mysqli->close();
?>
]]>
-
-
-
- Procedural style
-
+
+
+
+ Procedural style
+
]]>
-
-
+
+
+
+ The above examples would produce the following output:
+
+
+
diff --git a/reference/mysqli/functions/mysqli-select-db.xml b/reference/mysqli/functions/mysqli-select-db.xml
index cdbe61c3fb..d54129a3d3 100644
--- a/reference/mysqli/functions/mysqli-select-db.xml
+++ b/reference/mysqli/functions/mysqli-select-db.xml
@@ -1,5 +1,5 @@
-
+
mysqli_select_db
@@ -39,6 +39,88 @@
mysqli_real_connect
+
+ Example
+
+ Object oriented style
+
+query("SELECT DATABASE()")) {
+ $row = $result->fetch_row();
+ printf("Default database is %s.\n", $row[0]);
+ $result->close();
+}
+
+/* change db to world db */
+$mysqli->select_db("world");
+
+/* return name of current default database */
+if ($result = $mysqli->query("SELECT DATABASE()")) {
+ $row = $result->fetch_row();
+ printf("Default database is %s.\n", $row[0]);
+ $result->close();
+}
+
+$mysqli->close();
+?>
+]]>
+
+
+
+ Procedural style
+
+
+]]>
+
+
+
+ The above examples would produce the following output:
+
+
+
+
+
+
mysqli_sqlstate
+ mysqli->sqlstate
Returns the SQLSTATE error from previous MySQL operation.
Description
-
- stringmysqli_sqlstate
- objectlink
-
+
+ stringmysqli_sqlstate
+ objectlink
+
+
+ Returns a string containing the SQLSTATE error code for the last error.
+ The error code consists of five characters. '00000' means no error.
+ The values are specified by ANSI SQL and ODBC. For a list of possible values, see
+ &url.mysql.docs.error;.
+
+
+
+ Note that not all MySQL errors are yet mapped to SQLSTATE's.
+ The value HY000 (general error) is used for unmapped errors.
+
+
+
+
+ Return values
+
+ Returns a string containing the SQLSTATE error code for the last error.
+ The error code consists of five characters. '00000' means no error.
+
+
+
+ See also
+
+ mysqli_errno,
+ mysqli_error
+
+
+
+ Example
+
+ Object oriented style
+
+query("CREATE TABLE City (ID INT, Name VARCHAR(30))")) {
+ printf("Error - SQLSTATE %s.\n", $mysqli->sqlstate);
+}
+
+$mysqli->close();
+?>
+]]>
+
+
+
+ Procedural style
+
+
+]]>
+
+
+
+ The above examples would produce the following output:
+
+
+
+