Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

maxdb_rollback(3) [php man page]

MAXDB_ROLLBACK(3)							 1							 MAXDB_ROLLBACK(3)

maxdb_rollback - Rolls back current transaction

       Procedural style

SYNOPSIS
bool maxdb_rollback (resource $link) DESCRIPTION
Object oriented style bool maxdb::rollback (void ) Rollbacks the current transaction for the database specified by the $link parameter. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } /* disable autocommit */ $maxdb->autocommit(FALSE); $maxdb->query("CREATE TABLE temp.mycity LIKE hotel.city"); $maxdb->query("INSERT INTO temp.mycity SELECT * FROM hotel.city"); /* commit insert */ $maxdb->commit(); /* delete all rows */ $maxdb->query("DELETE FROM temp.mycity"); if ($result = $maxdb->query("SELECT COUNT(*) FROM temp.mycity")) { $row = $result->fetch_row(); printf("%d rows in table mycity. ", $row[0]); /* Free result */ $result->close(); } /* Rollback */ $maxdb->rollback(); if ($result = $maxdb->query("SELECT COUNT(*) FROM temp.mycity")) { $row = $result->fetch_row(); printf("%d rows in table mycity (after rollback). ", $row[0]); /* Free result */ $result->close(); } /* Drop table myCity */ $maxdb->query("DROP TABLE temp.mycity"); $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } /* disable autocommit */ maxdb_autocommit($link, FALSE); maxdb_query($link, "CREATE TABLE temp.mycity LIKE hotel.city"); maxdb_query($link, "INSERT INTO temp.mycity SELECT * FROM hotel.city"); /* commit insert */ maxdb_commit($link); /* delete all rows */ maxdb_query($link, "DELETE FROM temp.mycity"); if ($result = maxdb_query($link, "SELECT COUNT(*) FROM temp.mycity")) { $row = maxdb_fetch_row($result); printf("%d rows in table mycity. ", $row[0]); /* Free result */ maxdb_free_result($result); } /* Rollback */ maxdb_rollback($link); if ($result = maxdb_query($link, "SELECT COUNT(*) FROM temp.mycity")) { $row = maxdb_fetch_row($result); printf("%d rows in table mycity (after rollback). ", $row[0]); /* Free result */ maxdb_free_result($result); } /* Drop table myCity */ maxdb_query($link, "DROP TABLE temp.mycity"); maxdb_close($link); ?> The above example will output something similar to: 0 rows in table mycity. 25 rows in table mycity (after rollback). SEE ALSO
maxdb_commit(3), maxdb_autocommit(3). PHP Documentation Group MAXDB_ROLLBACK(3)

Check Out this Related Man Page

MAXDB_WARNING_COUNT(3)							 1						    MAXDB_WARNING_COUNT(3)

maxdb_warning_count - Returns the number of warnings from the last query for the given link

       Procedural style

SYNOPSIS
int maxdb_warning_count (resource $link) DESCRIPTION
Object oriented style int$maxdb->warning_count () maxdb_warning_count(3) returns the number of warnings from the last query in the connection represented by the $link parameter. RETURN VALUES
Number of warnings or zero if there are no warnings. EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $maxdb->query("CREATE TABLE temp.mycity LIKE hotel.city"); /* a remarkable city in Wales */ $query = "INSERT INTO temp.mycity (zip, name) VALUES('11111', 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')"; $maxdb->query($query); printf ("Number of warning: %d ", $maxdb->warning_count); /* close connection */ $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } maxdb_query($link, "CREATE TABLE temp.mycity LIKE hotel.city"); /* a remarkable long city name in Wales */ $query = "INSERT INTO temp.mycity (zip, name) VALUES('11111', 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')"; maxdb_query($link, $query); printf ("Number of warning: %d ", maxdb_warning_count($link)); /* close connection */ maxdb_close($link); ?> The above example will output something similar to: Warning: maxdb_query(): -8004 POS(62) Constant must be compatible with column type and length <...> Number of warning: 0 SEE ALSO
maxdb_errno(3), maxdb_error(3), maxdb_sqlstate(3). PHP Documentation Group MAXDB_WARNING_COUNT(3)
Man Page