Tải bản đầy đủ (.pdf) (5 trang)

PHP Developer''''s Dictionary- P91 doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (364.85 KB, 5 trang )

PHP Developer’s Dictionary
IT-SC book
450
offset
in the result
set. Possible return values include
int
,
real
,
blob
, and
string
, as well as the others defined in the MySQL documentation.
mysql_field_flags()
Syntax

string mysql_field_flags (int result, int field_offset)


Description
The
mysql_field_flags()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns the field flags for field specified by the
field_offset
in the result
set. The flags are returned as a single-spaced string
that can be further manipulated using the
explode()
function. The following flags


can be reported
not_null
,
primary_key
,
unique_key
,
multiple_key
,
blob
,
unsigned
,
zerofill
,
binary
,
enum
,
auto_increment
, and
timestamp
. For backward
compatibility,
mysql_fieldflags()
can be used.
mysql_field_len()
Syntax

int mysql_field_len (int result, int field_offset)



Description
The
mysql_field_len()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns the length the field specified by the
field_offset parameter in the result set.
mysql_free_result()
Syntax

int mysql_free_result (int result)


Description
The
mysql_free_result()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, frees all memory associated with the result set. This
PHP Developer’s Dictionary
IT-SC book
451
function is not typically used because a result set is freed automatically when the
script completes its processing.
mysql_insert_id()
Syntax

int mysql_insert_id ([int link_identifier])



Description
The
mysql_insert_id()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns the ID that was automatically generated for
an
AUTO_INCREMENT
column on the previous insert statement performed on the
link_identifier
connection. If the connection is not specified, the previous link is
assumed. The return value will be
0
if no value was generated for the last statement.
Note that the last ID generated can be retrieved using the internal MySQL function
LAST_INSERT_ID()
. If the column type is bigint, you must use the internal MySQL
function instead of this function.
mysql_list_fields()
Syntax

int mysql_list_fields (string database_name,
string table_name [, int link_identifier ])


Description
The
mysql_list_fields()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns a pointer to information about the given
table_name

in the database_name
using the link_identifier
. The resulting list
can be examined using
mysql_field_flags()
,
mysql_field_len()
,
mysql_field_name()
, and
mysql_field_type()
. The return value is a positive
number representing the result identifier or FALSE if an error occurs. For backward
compatibility,
mysql_listfields()
is also supported.
mysql_list_dbs()
Syntax

int_mysql_list_dbs ([int link_identifier])

PHP Developer’s Dictionary
IT-SC book
452

Description
The mysql_list_dbs() function, which is available from PHP 3.0 to PHP 3.0.16 along
with PHP 4.0 and higher, returns a pointer to a list of the currently available
databases on the MySQL daemon. Use the
mysql_tablename()

function to traverse
the list.
mysql_list_tables()
Syntax

int mysql_list_tables (string database, [, int link_identifier])


Description
The mysql_list_tables() function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns a pointer to a list of tables for the
database
.
The
mysql_tablename()
function should be used to traverse the list.
mysql_num_fields()
Syntax

int myssql_num_fields (int result)


Description
The
mysql_num_fields()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, returns the number of fields in the result set. For
backward compatibility,
mysql_numfields()
is also supported.

mysql_num_rows()
Syntax

int mysql_num_rows (int result)


Description
PHP Developer’s Dictionary
IT-SC book
453
The
mysql_num_rows()
function, which is available from PHP 3.0 to PHP 3.0.16 along
with PHP 4.0 and higher, returns the number of rows in a result set. This is valid only
for select statements. If you need to determine the number of rows affected by an
insert, update, or delete statement, you should use the mysql_affected_rows()
function. For backward compatibility, the
mysql_numrows()
function is also
supported.
mysql_pconnect()
Syntax

int mysql_pconnect ([string hostname [:port] [:/path/to/socket]
[, string username [, string password]]])


Description
The
mysql_pconnect()

function, which is available from PHP 3.0 to PHP 3.0.16 along
with PHP 4.0 and higher, is used to establish a persistent connection to a MySQL
server. The default host:port is
localhost:3306
, the default username is the name
of the user that owns the server process, and the default password
is the empty
string. The hostname parameter can also include a port or path to socket. If a
persistent connection already exists, it will be returned instead and the connection is
not closed on completion of a script's processing.
mysql_query()
Syntax

int mysql_query (string query [, int link_identifier])


Description
The
mysql_query()
function, which is available from PHP 3.0 to PHP 3.0.16 along
with PHP 4.0 and higher, sends the query to the server referenced by the
link_identifier . If a link isn't specified, the last opened link is used. If no link is
available, an attempt to establish one is made as though
mysql_connect()
were
called with no arguments. Note that the query
string should not end with a
semicolon. The return value is TRUE for success and FALSE otherwise, although a
TRUE return value doesn't guarantee that the query affected any rows of data or
returned a result set.

mysql_result()
Syntax
PHP Developer’s Dictionary
IT-SC book
454

mixed mysql_result (int result, int row [, mixed field])


Description
The
mysql_result()
function, which is available from PHP 3.0 to PHP 3.0.16 along
with PHP 4.0 and higher, returns the contents of a cell in the result set located at
the row
and optional field
position. The field
parameter can be the name, offset,
or table name dot fieldname (
tablename
.
fieldname
). If the select statement used
aliases, use those names instead of the column names. If obtaining multiple cells for
one row, it is often quicker to fetch the entire row. Also, better performance can be
achieved by using the offsets instead of the names.
mysql_select_db()
Syntax

int mysql_select_db (string database_name [, int link_identifier])



Description
The
mysql_select_db()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, selects the current active database for the server
referenced by the link_identifier
parameter, and if no link is specified, the last
opened link is used. If no link exists, the function tries to establish one. For
backward compatibility, the mysql_selectdb() function is supported.
mysql_tablename()
Syntax

string mysql_tablename int result, int i)


Description
The
mysql_tablename()
function, which is available from PHP 3.0 to PHP 3.0.16
along with PHP 4.0 and higher, traverses the list returned from the
mysql_list_
tables()
function and returns the name of the table. The parameter
i
is used as an
index into the list.
ODBC

×