MYSQL Client Flags
| From: | John Manko | Date: | Sat, 19 Jul 2003 19:44:22 +0000 |
| Subject: | MYSQL Client Flags | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155917@lists.php.net to get a copy of this message | ||
I was interested in how to determine the number of rows matched on an update, even if they weren't updated. The reason for this was mysql_affected_rows() returns the number of rows affected, which my not be the number of rows matched by the query (see the manual). So, I came accross a post in the comment section of the online documentation that says the following:
---------------------------------------------------------------------------
from mysql_affected_rows()
"As of PHP 4.3.0 (I assume, I only tried with 4.3.2), you can make mysql_affected_rows() return the number of rows matched, even if none are updated. You do this by setting the CLIENT_FOUND_ROWS flag in mysql_connect(). For some reason, not all the flags are defined in PHP, but you can use the decimal equivalent, which for CLIENT_FOUND_ROWS is 2."
$db= mysql_connect("localhost", "user", "pass", false, 2);
mysql_select_db("mydb", $db);"
-----------------------------------------------------------------------
from mysql_connect()
|"I presume that mysql_connect() just passes through to the C MySQL API, which provides these constants:
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
#define CLIENT_COMPRESS 32 /* Can use compression protocol */
#define CLIENT_ODBC 64 /* Odbc client */
#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
#define CLIENT_CHANGE_USER 512 /* Support the mysql_change_user() */
#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
#define CLIENT_SSL 2048 /* Switch to SSL after handshake */ #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */"| ------------------------------------------------------------------------------ So, I started searching, an I found a few other flags(below). My question: Is this list complete, does php have defined flags for these (or do I have to define descriptive variables for the corrasponding numbers), and is this pretty much the extent of the information I will find on the php end of things? CLIENT_MULTI_QUERIES Tell the server that the client may send multi-row-queries (separated with `;'). If this flag is not set, multi-row-queries are disabled. New in 4.1. CLIENT_MULTI_RESULTS Tell the server that the client can handle multiple-result sets from multi-queries or stored procedures. This is automatically set if CLIENT_MULTI_QUERIES is set. New in 4.1.