Frequently Used MySQL Library Functions
This chapter develops applications using the following PHP calls:
-
resource
mysql_pconnect([string
host[:port]
],
[string
username
],
[string
password
])
Used to establish a connection to the MySQL DBMS. Upon success, the function returns a connection resource handle that can be used to access databases through subsequent function calls. It returns
false
on failure.
The function has three optional parameters. The first is the
host
name of the DBMS and an optional
port
number; a default port of 3306 for
MySQL is assumed if the port is omitted. The
host
parameter is usually set to
localhost
when the MySQL DBMS and the web server
are running on the same machine.
The username
and
password
are MySQL DBMS username and
password credentials. These are the same username and password used
to access the DBMS though the command-line monitor
mysql
.
-
int mysql_select_db (string
database
, [resource
connection
])
Use the specified
database
through theconnection
. The connection is a resource handle returned frommysql_pconnect( )
. The second parameter is optional but always recommended in practice. The function returnstrue
on success andfalse
on failure.-
resource mysql_query(string SQL, [resource
connection
])
Run an SQL statement through a MySQL DBMS
connection
. The second parameter is optional but always recommended in practice. On success, the function returns a query result resource that can be used to fetch data. The function returnsfalse ...
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.