cvs: phpdoc /en/functions mysql.xml

From: Date: Mon, 06 Nov 2000 23:38:14 +0000
Subject: cvs: phpdoc /en/functions mysql.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969332810@lists.php.net to get a copy of this message
jmoore Mon Nov 6 15:38:14 2000 EDT Modified files: /phpdoc/en/functions mysql.xml Log: Changing numrows() to num_rows()

Index: phpdoc/en/functions/mysql.xml diff -u phpdoc/en/functions/mysql.xml:1.29 phpdoc/en/functions/mysql.xml:1.30 --- phpdoc/en/functions/mysql.xml:1.29 Wed Nov 1 22:34:03 2000 +++ phpdoc/en/functions/mysql.xml Mon Nov 6 15:38:14 2000 @@ -3,17 +3,26 @@ <titleabbrev>MySQL</titleabbrev> <partintro> <simpara> - These functions allow you to access MySQL database servers. In - order to have these functions available, you must compile php + These functions allow you to access MySQL database +servers. In + order to have these functions available, you must +compile php with mysql support by using the - <option role="configure">--with-mysql</option> option. If you - use this option without specifying the path to mysql, php will - use the built-in mysql client libraries. Users who run other - applications that use mysql (for example, running php3 and php4 - as concurrent apache modules, or auth-mysql) should always + <option role="configure">--with-mysql</option> option. +If you + use this option without specifying the path to mysql, +php will + use the built-in mysql client libraries. Users who run +other + applications that use mysql (for example, running php3 +and php4 + as concurrent apache modules, or auth-mysql) should +always specify the path to mysql: - <option role="configure">--with-mysql=/path/to/mysql</option>. - This will force php to use the client libraries installed by + <option +role="configure">--with-mysql=/path/to/mysql</option>. + This will force php to use the client libraries +installed by mysql, avoiding any conflicts. </simpara> <simpara> @@ -30,14 +39,16 @@ <refentry id="function.mysql-affected-rows"> <refnamediv> <refname>mysql_affected_rows</refname> - <refpurpose>Get number of affected rows in previous MySQL + <refpurpose>Get number of affected rows in previous +MySQL operation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_affected_rows</function></funcdef> + <funcdef>int +<function>mysql_affected_rows</function></funcdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -46,20 +57,29 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_affected_rows</function> returns the number of - rows affected by the last INSERT, UPDATE or DELETE query on the - server associated with the specified link identifier. If the - link identifier isn't specified, the last opened link is assumed. + <function>mysql_affected_rows</function> returns the +number of + rows affected by the last INSERT, UPDATE or DELETE +query on the + server associated with the specified link identifier. +If the + link identifier isn't specified, the last opened link +is assumed. </para> <para> - If the last query was a DELETE query with no WHERE clause, all - of the records will have been deleted from the table but this + If the last query was a DELETE query with no WHERE +clause, all + of the records will have been deleted from the table +but this function will return zero. </para> <para> - This command is not effective for SELECT statements, only on - statements which modify records. To retrieve the number of rows - returned from a SELECT, use <function>mysql_num_rows</function>. + This command is not effective for SELECT statements, +only on + statements which modify records. To retrieve the number +of rows + returned from a SELECT, use +<function>mysql_num_rows</function>. </para> </refsect1> </refentry> @@ -75,10 +95,13 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_change_user</function></funcdef> - <paramdef>string <parameter>user</parameter></paramdef> - <paramdef>string <parameter>password</parameter></paramdef> + <funcdef>int +<function>mysql_change_user</function></funcdef> <paramdef>string +<parameter>user</parameter></paramdef> + <paramdef>string +<parameter>password</parameter></paramdef> + <paramdef>string <parameter> <optional>database</optional> </parameter> @@ -91,13 +114,18 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_change_user</function> changes the logged in user - of the current active connection, or the connection given by the + <function>mysql_change_user</function> changes the +logged in user + of the current active connection, or the connection +given by the optional parameter link_identifier. If a database is - specified, this will default or current database after the user - has been changed. If the new user and password authorization fails, + specified, this will default or current database after +the user + has been changed. If the new user and password +authorization fails, the current connected user stays active.</para> - <note><para>This function was introduced in PHP 3.0.13 and + <note><para>This function was introduced in PHP 3.0.13 +and requires MySQL 3.23.3 or higher. </para></note> </refsect1> @@ -112,10 +140,12 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_close</function></funcdef> + <funcdef>int +<function>mysql_close</function></funcdef> <paramdef>int <parameter> - <optional>link_identifier</optional> + <optional>link_identifier</optional> + </parameter> </paramdef> </funcprototype> @@ -123,19 +153,25 @@ <para> Returns: true on success, false on error. </para> - <para> <function>mysql_close</function> closes the connection to - the MySQL server that's associated with the specified link - identifier. If <parameter>link_identifier</parameter> isn't + <para> <function>mysql_close</function> closes the +connection to + the MySQL server that's associated with the specified +link + identifier. If <parameter>link_identifier</parameter> +isn't specified, the last opened link is used. </para> <para> - Using <function>mysql_close</function> isn't usually necessary, - as non-persistent open links are automatically closed at the end + Using <function>mysql_close</function> isn't usually +necessary, + as non-persistent open links are automatically closed +at the end of the script's execution. </para> <note> <para> - <function>mysql_close</function> will not close persistent links + <function>mysql_close</function> will not close +persistent links created by <function>mysql_pconnect</function>. </para> </note> @@ -160,13 +196,15 @@ <refentry id="function.mysql-connect"> <refnamediv> <refname>mysql_connect</refname> - <refpurpose>Open a connection to a MySQL Server</refpurpose> + <refpurpose>Open a connection to a MySQL +Server</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_connect</function></funcdef> + <funcdef>int +<function>mysql_connect</function></funcdef> <paramdef>string <parameter> <optional>hostname @@ -188,20 +226,26 @@ </funcprototype> </funcsynopsis> <para> - Returns a positive MySQL link identifier on success, or an error + Returns a positive MySQL link identifier on success, or +an error message on failure. </para> <para> - <function>mysql_connect</function> establishes a connection - to a MySQL server. The following defaults are assumed for - missing optional parameters: <parameter>host:port</parameter> = - 'localhost:3306', <parameter>username</parameter> = name of the + <function>mysql_connect</function> establishes a +connection + to a MySQL server. The following defaults are assumed +for + missing optional parameters: +<parameter>host:port</parameter> = + 'localhost:3306', <parameter>username</parameter> = +name of the user that owns the server process and <parameter>password</parameter> = empty password. </para> <para> The hostname string can also include a port - number. eg. &quot;hostname:port&quot; or a path to a socket + number. eg. &quot;hostname:port&quot; or a path to a +socket eg. &quot;:/path/to/socket&quot; for the localhost. <note> <para> @@ -212,20 +256,26 @@ PHP 3.0.10. </para> <para> - You can suppress the error message on failure by prepending '@' + You can suppress the error message on failure by +prepending '@' to the function name. </para> </note> </para> <para> - If a second call is made to <function>mysql_connect</function> - with the same arguments, no new link will be established, but - instead, the link identifier of the already opened link will be + If a second call is made to +<function>mysql_connect</function> + with the same arguments, no new link will be +established, but + instead, the link identifier of the already opened link +will be returned. </para> <para> - The link to the server will be closed as soon as the execution of - the script ends, unless it's closed earlier by explicitly calling + The link to the server will be closed as soon as the +execution of + the script ends, unless it's closed earlier by +explicitly calling <function>mysql_close</function>. </para> <example> @@ -255,8 +305,10 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_create_db</function></funcdef> - <paramdef>string <parameter>database name</parameter></paramdef> + <funcdef>int +<function>mysql_create_db</function></funcdef> + <paramdef>string <parameter>database +name</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -265,8 +317,10 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_create_db</function> attempts to create a new - database on the server associated with the specified link + <function>mysql_create_db</function> attempts to create +a new + database on the server associated with the specified +link identifier. </para> <example> @@ -278,13 +332,15 @@ if (mysql_create_db ("my_db")) { print ("Database created successfully\n"); } else { - printf ("Error creating database: %s\n", mysql_error ()); + printf ("Error creating database: %s\n", mysql_error +()); } ?> </programlisting> </example> <para> - For downwards compatibility <function>mysql_createdb</function> + For downwards compatibility +<function>mysql_createdb</function> can also be used. </para> <para> @@ -302,19 +358,26 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_data_seek</function></funcdef> - <paramdef>int <parameter>result_identifier</parameter></paramdef> - <paramdef>int <parameter>row_number</parameter></paramdef> + <funcdef>int +<function>mysql_data_seek</function></funcdef> + <paramdef>int +<parameter>result_identifier</parameter></paramdef> + <paramdef>int +<parameter>row_number</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns: true on success, false on failure. </para> <para> - <function>mysql_data_seek</function> moves the internal row - pointer of the MySQL result associated with the specified result - identifier to point to the specified row number. The next call - to <function>mysql_fetch_row</function> would return that row. + <function>mysql_data_seek</function> moves the internal +row + pointer of the MySQL result associated with the +specified result + identifier to point to the specified row number. The +next call + to <function>mysql_fetch_row</function> would return +that row. </para> <para> <parameter>Row_number</parameter> starts at 0. @@ -345,7 +408,8 @@ if(!($row = mysql_fetch_object ($result))) continue; - printf ("%s %s&lt;BR>\n", $row->last_name, $row->first_name); + printf ("%s %s&lt;BR>\n", $row->last_name, +$row->first_name); } mysql_free_result ($result); @@ -364,7 +428,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_db_name</function></funcdef> + <funcdef>int +<function>mysql_db_name</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter>row</parameter></paramdef> <paramdef>mixed @@ -375,22 +440,26 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_db_name</function> takes as its first parameter + <function>mysql_db_name</function> takes as its first +parameter the result pointer from a call to <function>mysql_list_dbs</function>. The - <parameter>row</parameter> parameter is an index into the result + <parameter>row</parameter> parameter is an index into +the result set. </para> <para> If an error occurs, FALSE is returned. Use <function>mysql_errno</function> and - <function>mysql_error</function> to determine the nature of the + <function>mysql_error</function> to determine the +nature of the error. </para> <example> - <title><function>Mysql_db_name</function> example</title> + <title><function>Mysql_db_name</function> +example</title> <programlisting role="php"> &lt;?php error_reporting(E_ALL); @@ -399,7 +468,7 @@ $db_list = mysql_list_dbs(); $i = 0; -$cnt = mysql_numrows($db_list); +$cnt = mysql_num_rows($db_list); while ($i < $cnt) { echo mysql_db_name($db_list, $i) . "\n"; $i++; @@ -409,7 +478,8 @@ </example> <para> - For backward compatibility, <function>mysql_dbname</function> is + For backward compatibility, +<function>mysql_dbname</function> is also accepted. This is deprecated, however. </para> @@ -425,9 +495,12 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_db_query</function></funcdef> - <paramdef>string <parameter>database</parameter></paramdef> - <paramdef>string <parameter>query</parameter></paramdef> + <funcdef>int +<function>mysql_db_query</function></funcdef> + <paramdef>string +<parameter>database</parameter></paramdef> + <paramdef>string +<parameter>query</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -436,15 +509,21 @@ </funcprototype> </funcsynopsis> <para> - Returns: A positive MySQL result identifier to the query result, + Returns: A positive MySQL result identifier to the +query result, or false on error. </para> <para> - <function>mysql_db_query</function> selects a database and - executes a query on it. If the optional link identifier isn't - specified, the function will try to find an open link to the - MySQL server and if no such link is found it'll try to create one - as if <function>mysql_connect</function> was called with no + <function>mysql_db_query</function> selects a database +and + executes a query on it. If the optional link +identifier isn't + specified, the function will try to find an open link +to the + MySQL server and if no such link is found it'll try to +create one + as if <function>mysql_connect</function> was called +with no arguments </para> <para> @@ -452,7 +531,8 @@ </para> <para> For downwards - compatibility <function>mysql</function> can also be used. + compatibility <function>mysql</function> can also be +used. </para> </refsect1> </refentry> @@ -466,8 +546,10 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_drop_db</function></funcdef> - <paramdef>string <parameter>database_name</parameter></paramdef> + <funcdef>int +<function>mysql_drop_db</function></funcdef> + <paramdef>string +<parameter>database_name</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -479,13 +561,17 @@ Returns: true on success, false on failure. </para> <para> - <function>mysql_drop_db</function> attempts to drop (remove) an - entire database from the server associated with the specified + <function>mysql_drop_db</function> attempts to drop +(remove) an + entire database from the server associated with the +specified link identifier. </para> <para> - See also: <function>mysql_create_db</function>. For downward - compatibility <function>mysql_dropdb</function> can also be used. + See also: <function>mysql_create_db</function>. For +downward + compatibility <function>mysql_dropdb</function> can +also be used. </para> </refsect1> </refentry> @@ -493,14 +579,16 @@ <refentry id="function.mysql-errno"> <refnamediv> <refname>mysql_errno</refname> - <refpurpose>Returns the numerical value of the error message from previous + <refpurpose>Returns the numerical value of the error +message from previous MySQL operation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_errno</function></funcdef> + <funcdef>int +<function>mysql_errno</function></funcdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -509,17 +597,24 @@ </funcprototype> </funcsynopsis> <para> - Returns the error number from the last mySQL function, or + Returns the error number from the last mySQL function, +or <literal>0</literal> (zero) if no error occurred. </para> <para> - Errors coming back from the mySQL database backend no longer - issue warnings. Instead, use <function>mysql_errno</function> to - retrieve the error code. Note that this function only returns the - error code from the most recently executed mySQL function (not + Errors coming back from the mySQL database backend no +longer + issue warnings. Instead, use +<function>mysql_errno</function> to + retrieve the error code. Note that this function only +returns the + error code from the most recently executed mySQL +function (not including <function>mysql_error</function> and - <function>mysql_errno</function>), so if you want to use it, - make sure you check the value before calling another mySQL + <function>mysql_errno</function>), so if you want to +use it, + make sure you check the value before calling another +mySQL function. <informalexample> <programlisting role="php"> @@ -543,14 +638,16 @@ <refentry id="function.mysql-error"> <refnamediv> <refname>mysql_error</refname> - <refpurpose>Returns the text of the error message from previous + <refpurpose>Returns the text of the error message from +previous MySQL operation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_error</function></funcdef> + <funcdef>string +<function>mysql_error</function></funcdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -560,16 +657,23 @@ </funcsynopsis> <para> Returns the error text from the last mySQL function, or - <literal>''</literal> (the empty string) if no error occurred. + <literal>''</literal> (the empty string) if no error +occurred. </para> <para> - Errors coming back from the mySQL database backend no longer - issue warnings. Instead, use <function>mysql_error</function> to - retrieve the error text. Note that this function only returns the - error text from the most recently executed mySQL function (not + Errors coming back from the mySQL database backend no +longer + issue warnings. Instead, use +<function>mysql_error</function> to + retrieve the error text. Note that this function only +returns the + error text from the most recently executed mySQL +function (not including <function>mysql_error</function> and - <function>mysql_errno</function>), so if you want to use it, make - sure you check the value before calling another mySQL function. + <function>mysql_errno</function>), so if you want to +use it, make + sure you check the value before calling another mySQL +function. <informalexample> <programlisting role="php"> &lt;?php @@ -593,14 +697,16 @@ <refnamediv> <refname>mysql_fetch_array</refname> <refpurpose> - Fetch a result row as an associative array, a numeric array, or both. + Fetch a result row as an associative array, a numeric +array, or both. </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>array <function>mysql_fetch_array</function></funcdef> + <funcdef>array +<function>mysql_fetch_array</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter> @@ -610,18 +716,26 @@ </funcprototype> </funcsynopsis> <para> - Returns an array that corresponds to the fetched row, or false + Returns an array that corresponds to the fetched row, +or false if there are no more rows.</para> - <para> - <function>mysql_fetch_array</function> is an extended version of - <function>mysql_fetch_row</function>. In addition to storing the - data in the numeric indices of the result array, it also stores - the data in associative indices, using the field names as keys. - </para> <para> - If two or more columns of the result have the same field names, - the last column will take precedence. To access the other column(s) - of the same name, you must the numeric index of the column or + <function>mysql_fetch_array</function> is an extended +version of + <function>mysql_fetch_row</function>. In addition to +storing the + data in the numeric indices of the result array, it +also stores + the data in associative indices, using the field names +as keys. + </para> + <para> + If two or more columns of the result have the same +field names, + the last column will take precedence. To access the +other column(s) + of the same name, you must the numeric index of the +column or make an alias for the column. <informalexample> <programlisting> @@ -631,26 +745,32 @@ </para> <para> An important thing to note is that using - <function>mysql_fetch_array</function> is NOT significantly - slower than using <function>mysql_fetch_row</function>, while it + <function>mysql_fetch_array</function> is NOT +significantly + slower than using <function>mysql_fetch_row</function>, +while it provides a significant added value. </para> <para> - The optional second argument <parameter>result_type</parameter> - in <function>mysql_fetch_array</function> is a constant and can + The optional second argument +<parameter>result_type</parameter> + in <function>mysql_fetch_array</function> is a constant +and can take the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. (This feature was added in PHP 3.0.7) </para> <para> For further details, see also - <function>mysql_fetch_row</function> and <function>mysql_fetch_assoc</function>. + <function>mysql_fetch_row</function> and +<function>mysql_fetch_assoc</function>. </para> <example> <title><function>Mysql_fetch_array</function></title> <programlisting role="php"> &lt;?php mysql_connect ($host, $user, $password); -$result = mysql_db_query ("database","select user_id, fullname from table"); +$result = mysql_db_query ("database","select user_id, +fullname from table"); while ($row = mysql_fetch_array ($result)) { echo "user_id: ".$row["user_id"]."&lt;br>\n"; echo "user_id: ".$row[0]."&lt;br>\n"; @@ -675,36 +795,49 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>array <function>mysql_fetch_assoc</function></funcdef> + <funcdef>array +<function>mysql_fetch_assoc</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns an associative array that corresponds to the fetched row, + Returns an associative array that corresponds to the +fetched row, or false if there are no more rows.</para> <para> - <function>mysql_fetch_assoc</function> is eqivilant to calling - <function>mysql_fetch_array</function> with MYSQL_ASSOC for the - optional second parameter. It only returns an associative array. - This is the way <function>mysql_fetch_array</function> originally + <function>mysql_fetch_assoc</function> is eqivilant to +calling + <function>mysql_fetch_array</function> with MYSQL_ASSOC +for the + optional second parameter. It only returns an +associative array. + This is the way <function>mysql_fetch_array</function> +originally worked. If you need the numeric indices as well as the - associative, use <function>mysql_fetch_array</function>. + associative, use +<function>mysql_fetch_array</function>. </para> <para> - If two or more columns of the result have the same field names, - the last column will take precedence. To access the other column(s) - of the same name, you must use <function>mysql_fetch_array</function> and + If two or more columns of the result have the same +field names, + the last column will take precedence. To access the +other column(s) + of the same name, you must use +<function>mysql_fetch_array</function> and have it return the numeric indices as well. </para> <para> An important thing to note is that using - <function>mysql_fetch_assoc</function> is NOT significantly - slower than using <function>mysql_fetch_row</function>, while it + <function>mysql_fetch_assoc</function> is NOT +significantly + slower than using <function>mysql_fetch_row</function>, +while it provides a significant added value. </para> <para> For further details, see also - <function>mysql_fetch_row</function> and <function>mysql_fetch_array</function>. + <function>mysql_fetch_row</function> and +<function>mysql_fetch_array</function>. </para> <example> <title><function>Mysql_fetch_assoc</function></title> @@ -727,14 +860,16 @@ <refnamediv> <refname>mysql_fetch_field</refname> <refpurpose> - Get column information from a result and return as an object + Get column information from a result and return as an +object </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>object <function>mysql_fetch_field</function></funcdef> + <funcdef>object +<function>mysql_fetch_field</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter> @@ -747,10 +882,14 @@ Returns an object containing field information. </para> <para> - <function>mysql_fetch_field</function> can be used in order to - obtain information about fields in a certain query result. If - the field offset isn't specified, the next field that wasn't yet - retrieved by <function>mysql_fetch_field</function> is retrieved. + <function>mysql_fetch_field</function> can be used in +order to + obtain information about fields in a certain query +result. If + the field offset isn't specified, the next field that +wasn't yet + retrieved by <function>mysql_fetch_field</function> is +retrieved. </para> <para> The properties of the object are: @@ -870,21 +1009,26 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>array <function>mysql_fetch_lengths</function></funcdef> + <funcdef>array +<function>mysql_fetch_lengths</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns: An array that corresponds to the lengths of each field - in the last row fetched by <function>mysql_fetch_row</function>, + Returns: An array that corresponds to the lengths of +each field + in the last row fetched by +<function>mysql_fetch_row</function>, or false on error. </para> <para> - <function>mysql_fetch_lengths</function> stores the lengths of + <function>mysql_fetch_lengths</function> stores the +lengths of each result column in the last row returned by <function>mysql_fetch_row</function>, <function>mysql_fetch_array</function>, and - <function>mysql_fetch_object</function> in an array, starting at + <function>mysql_fetch_object</function> in an array, +starting at offset 0. </para> <para> @@ -902,7 +1046,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>object <function>mysql_fetch_object</function></funcdef> + <funcdef>object +<function>mysql_fetch_object</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter> @@ -912,32 +1057,41 @@ </funcprototype> </funcsynopsis> <para> - Returns an object with properties that correspond to the fetched + Returns an object with properties that correspond to +the fetched row, or false if there are no more rows. </para> <para> <function>mysql_fetch_object</function> is similar to - <function>mysql_fetch_array</function>, with one difference - an - object is returned, instead of an array. Indirectly, that means - that you can only access the data by the field names, and not by + <function>mysql_fetch_array</function>, with one +difference - an + object is returned, instead of an array. Indirectly, +that means + that you can only access the data by the field names, +and not by their offsets (numbers are illegal property names). </para> <para> - The optional argument <parameter>result_type</parameter> is a - constant and can take the following values: MYSQL_ASSOC, + The optional argument +<parameter>result_type</parameter> is a + constant and can take the following values: +MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. </para> <para> Speed-wise, the function is identical to - <function>mysql_fetch_array</function>, and almost as quick as + <function>mysql_fetch_array</function>, and almost as +quick as <function>mysql_fetch_row</function> (the difference is insignificant). <example> - <title><function>mysql_fetch_object</function> example</title> + <title><function>mysql_fetch_object</function> +example</title> <programlisting role="php"> &lt;?php mysql_connect ($host, $user, $password); -$result = mysql_db_query ("database", "select * from table"); +$result = mysql_db_query ("database", "select * from +table"); while ($row = mysql_fetch_object ($result)) { echo $row->user_id; echo $row->fullname; @@ -957,29 +1111,37 @@ <refentry id="function.mysql-fetch-row"> <refnamediv> <refname>mysql_fetch_row</refname> - <refpurpose>Get a result row as an enumerated array</refpurpose> + <refpurpose>Get a result row as an enumerated +array</refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>array <function>mysql_fetch_row</function></funcdef> + <funcdef>array +<function>mysql_fetch_row</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns: An array that corresponds to the fetched row, or false + Returns: An array that corresponds to the fetched row, +or false if there are no more rows. </para> <para> - <function>mysql_fetch_row</function> fetches one row of data from - the result associated with the specified result identifier. The - row is returned as an array. Each result column is stored in an + <function>mysql_fetch_row</function> fetches one row of +data from + the result associated with the specified result +identifier. The + row is returned as an array. Each result column is +stored in an array offset, starting at offset 0. </para> <para> - Subsequent call to <function>mysql_fetch_row</function> would - return the next row in the result set, or false if there are no + Subsequent call to <function>mysql_fetch_row</function> +would + return the next row in the result set, or false if +there are no more rows. </para> <para> @@ -996,31 +1158,41 @@ <refnamediv> <refname>mysql_field_flags</refname> <refpurpose> - Get the flags associated with the specified field in a result + Get the flags associated with the specified field in a +result </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_field_flags</function></funcdef> + <funcdef>string +<function>mysql_field_flags</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_offset</parameter></paramdef> + <paramdef>int +<parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_field_flags</function> returns the field flags of - the specified field. The flags are reported as a single word - per flag separated by a single space, so that you can split the + <function>mysql_field_flags</function> returns the +field flags of + the specified field. The flags are reported as a single +word + per flag separated by a single space, so that you can +split the returned value using <function>explode</function>. </para> - <para>The following flags are reported, if your version of MySQL - is current enough to support them: "not_null", "primary_key", - "unique_key", "multiple_key", "blob", "unsigned", "zerofill", + <para>The following flags are reported, if your version +of MySQL + is current enough to support them: "not_null", +"primary_key", + "unique_key", "multiple_key", "blob", "unsigned", +"zerofill", "binary", "enum", "auto_increment", "timestamp". </para> <para> - For downward compatibility <function>mysql_fieldflags</function> + For downward compatibility +<function>mysql_fieldflags</function> can also be used. </para> </refsect1> @@ -1037,15 +1209,20 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_field_name</function></funcdef> + <funcdef>string +<function>mysql_field_name</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_index</parameter></paramdef> + <paramdef>int +<parameter>field_index</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_field_name</function> returns the name of the - specified field index. <parameter>result</parameter> must be a - valid result identifier and <parameter>field_index</parameter> is + <function>mysql_field_name</function> returns the name +of the + specified field index. <parameter>result</parameter> +must be a + valid result identifier and +<parameter>field_index</parameter> is the numerical offset of the field. </para> <note> @@ -1053,20 +1230,23 @@ <parameter>field_index</parameter> starts at 0. </para> <para> - e.g. The index of the third field would actually be 2, the index + e.g. The index of the third field would actually be 2, +the index of the fourth field would be 3 and so on. </para> </note> <para> <example> - <title><function>mysql_field_name</function> example</title> + <title><function>mysql_field_name</function> +example</title> <programlisting role="php"> // The users table consists of three fields: // user_id // username // password. -$res = mysql_db_query("users", "select * from users", $link); +$res = mysql_db_query("users", "select * from users", +$link); echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); @@ -1083,7 +1263,8 @@ </informalexample> </para> <para> - For downwards compatibility <function>mysql_fieldname</function> + For downwards compatibility +<function>mysql_fieldname</function> can also be used. </para> </refsect1> @@ -1100,17 +1281,21 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_field_len</function></funcdef> + <funcdef>int +<function>mysql_field_len</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_offset</parameter></paramdef> + <paramdef>int +<parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_field_len</function> returns the length of the + <function>mysql_field_len</function> returns the length +of the specified field. </para> <para> - For downward compatibility <function>mysql_fieldlen</function> + For downward compatibility +<function>mysql_fieldlen</function> can also be used. </para> </refsect1> @@ -1127,14 +1312,18 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_field_seek</function></funcdef> + <funcdef>int +<function>mysql_field_seek</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_offset</parameter></paramdef> + <paramdef>int +<parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Seeks to the specified field offset. If the next call to - <function>mysql_fetch_field</function> doesn't include a field + Seeks to the specified field offset. If the next call +to + <function>mysql_fetch_field</function> doesn't include +a field offset, the field offset specified in <function>mysql_field_seek</function> will be returned. </para> @@ -1155,17 +1344,21 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_field_table</function></funcdef> + <funcdef>string +<function>mysql_field_table</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_offset</parameter></paramdef> + <paramdef>int +<parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns the name of the table that the specifed field is + Returns the name of the table that the specifed field +is in. </para> <para> - For downward compatibility <function>mysql_fieldtable</function> + For downward compatibility +<function>mysql_fieldtable</function> can also be used. </para> </refsect1> @@ -1182,16 +1375,21 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_field_type</function></funcdef> + <funcdef>string +<function>mysql_field_type</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> - <paramdef>int <parameter>field_offset</parameter></paramdef> + <paramdef>int +<parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>mysql_field_type</function> is similar to the - <function>mysql_field_name</function> function. The arguments are - identical, but the field type is returned instead. The field type - will be one of "int", "real", "string", "blob", and others as + <function>mysql_field_name</function> function. The +arguments are + identical, but the field type is returned instead. The +field type + will be one of "int", "real", "string", "blob", and +others as detailed in the <ulink url="&url.mysql.docs;">MySQL documentation</ulink>. <example> @@ -1206,7 +1404,8 @@ $rows = mysql_num_rows ($result); $i = 0; $table = mysql_field_table ($result, $i); -echo "Your '".$table."' table has ".$fields." fields and ".$rows." records &lt;BR>"; +echo "Your '".$table."' table has ".$fields." fields and +".$rows." records &lt;BR>"; echo "The table has the following fields &lt;BR>"; while ($i &lt; $fields) { $type = mysql_field_type ($result, $i); @@ -1223,7 +1422,8 @@ </example> </para> <para> - For downward compatibility <function>mysql_fieldtype</function> + For downward compatibility +<function>mysql_fieldtype</function> can also be used. </para> </refsect1> @@ -1238,22 +1438,30 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_free_result</function></funcdef> + <funcdef>int +<function>mysql_free_result</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> - <para> - <function>mysql_free_result</function> will free all memory - associated with the result identifier <parameter>result</parameter>. - </para> <para> - <function>mysql_free_result</function> only needs to be called if - you are concerned about how much memory is being used for queries - that return large result sets. All associated result memory is - automatically freed at the end of the script's execution. + <function>mysql_free_result</function> will free all +memory + associated with the result identifier +<parameter>result</parameter>. + </para> + <para> + <function>mysql_free_result</function> only needs to be +called if + you are concerned about how much memory is being used +for queries + that return large result sets. All associated result +memory is + automatically freed at the end of the script's +execution. </para> <para> - For downward compatibility <function>mysql_freeresult</function> + For downward compatibility +<function>mysql_freeresult</function> can also be used. </para> </refsect1> @@ -1270,7 +1478,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_insert_id</function></funcdef> + <funcdef>int +<function>mysql_insert_id</function></funcdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -1279,34 +1488,45 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_insert_id</function> returns the ID generated for - an AUTO_INCREMENT column by the previous INSERT query using the + <function>mysql_insert_id</function> returns the ID +generated for + an AUTO_INCREMENT column by the previous INSERT query +using the given <parameter>link_identifier</parameter>. If - <parameter>link_identifier</parameter> isn't specified, the last + <parameter>link_identifier</parameter> isn't specified, +the last opened link is assumed. </para> <para> - <function>mysql_insert_id</function> returns 0 if the previous - query does not generate an AUTO_INCREMENT value. If you need to - save the value for later, be sure to call mysql_insert_id() + <function>mysql_insert_id</function> returns 0 if the +previous + query does not generate an AUTO_INCREMENT value. If you +need to + save the value for later, be sure to call +mysql_insert_id() immediately after the query that generates the value. </para> <note> <para> The value of the MySQL SQL function - <literal>LAST_INSERT_ID()</literal> always contains the most - recently generated AUTO_INCREMENT value, and is not reset + <literal>LAST_INSERT_ID()</literal> always contains +the most + recently generated AUTO_INCREMENT value, and is not +reset between queries. </para> </note> <warning> <para> - <function>mysql_insert_id</function> converts the return type of + <function>mysql_insert_id</function> converts the +return type of the native MySQL C API function <literal>mysql_insert_id()</literal> to a type of - <literal>long</literal>. If your AUTO_INCREMENT column has + <literal>long</literal>. If your AUTO_INCREMENT +column has a column type of BIGINT, the value returned by - <function>mysql_insert_id</function> will be incorrect. + <function>mysql_insert_id</function> will be +incorrect. Instead, use the internal MySQL SQL function <literal>LAST_INSERT_ID()</literal>. </para> @@ -1325,7 +1545,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_list_dbs</function></funcdef> + <funcdef>int +<function>mysql_list_dbs</function></funcdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -1334,14 +1555,18 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_list_dbs</function> will return a result pointer - containing the databases available from the current mysql - daemon. Use the <function>mysql_tablename</function> function to + <function>mysql_list_dbs</function> will return a +result pointer + containing the databases available from the current +mysql + daemon. Use the <function>mysql_tablename</function> +function to traverse this result pointer. </para> <para> <example> - <title><function>mysql_list_dbs</function> example</title> + <title><function>mysql_list_dbs</function> +example</title> <programlisting role="php"> $link = mysql_connect('localhost', 'myname', 'secret'); $db_list = mysql_list_dbs($link); @@ -1366,11 +1591,13 @@ <note> <para> The above code would just as easily work with - <function>mysql_fetch_row</function> or other similar functions. + <function>mysql_fetch_row</function> or other similar +functions. </para> </note> <para> - For downward compatibility <function>mysql_listdbs</function> can + For downward compatibility +<function>mysql_listdbs</function> can also be used. </para> </refsect1> @@ -1385,9 +1612,12 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_list_fields</function></funcdef> - <paramdef>string <parameter>database_name</parameter></paramdef> - <paramdef>string <parameter>table_name</parameter></paramdef> + <funcdef>int +<function>mysql_list_fields</function></funcdef> + <paramdef>string +<parameter>database_name</parameter></paramdef> + <paramdef>string +<parameter>table_name</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -1396,24 +1626,32 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_list_fields</function> retrieves information - about the given tablename. Arguments are the database name and - the table name. A result pointer is returned which can be used + <function>mysql_list_fields</function> retrieves +information + about the given tablename. Arguments are the database +name and + the table name. A result pointer is returned which can +be used with <function>mysql_field_flags</function>, <function>mysql_field_len</function>, <function>mysql_field_name</function>, and <function>mysql_field_type</function>. </para> <para> - A result identifier is a positive integer. The function returns - -1 if a error occurs. A string describing the error will be - placed in <literal>$phperrmsg</literal>, and unless the function - was called as <literal>@mysql()</literal> then this error string + A result identifier is a positive integer. The function +returns + -1 if a error occurs. A string describing the error +will be + placed in <literal>$phperrmsg</literal>, and unless the +function + was called as <literal>@mysql()</literal> then this +error string will also be printed out. </para> <para> <example> - <title><function>mysql_list_fields</function> example</title> + <title><function>mysql_list_fields</function> +example</title> <programlisting role="php"> $link = mysql_connect('localhost', 'myname', 'secret'); @@ -1438,7 +1676,8 @@ </informalexample> </para> <para> - For downward compatibility <function>mysql_listfields</function> + For downward compatibility +<function>mysql_listfields</function> can also be used. </para> </refsect1> @@ -1453,8 +1692,10 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_list_tables</function></funcdef> - <paramdef>string <parameter>database</parameter></paramdef> + <funcdef>int +<function>mysql_list_tables</function></funcdef> + <paramdef>string +<parameter>database</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -1463,14 +1704,17 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_list_tables</function> takes a database name and + <function>mysql_list_tables</function> takes a database +name and returns a result pointer much like the <function>mysql_db_query</function> function. The - <function>mysql_tablename</function> function should be used to + <function>mysql_tablename</function> function should be +used to extract the actual table names from the result pointer. </para> <para> - For downward compatibility <function>mysql_listtables</function> + For downward compatibility +<function>mysql_listtables</function> can also be used. </para> </refsect1> @@ -1485,12 +1729,14 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_num_fields</function></funcdef> + <funcdef>int +<function>mysql_num_fields</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_num_fields</function> returns the number of + <function>mysql_num_fields</function> returns the +number of fields in a result set. </para> <para> @@ -1500,7 +1746,8 @@ <function>mysql_fetch_field</function>, <function>mysql_num_rows</function>.</para> <para> - For downward compatibility <function>mysql_numfields</function> + For downward compatibility +<function>mysql_numfields</function> can also be used. </para> </refsect1> @@ -1515,14 +1762,18 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_num_rows</function></funcdef> + <funcdef>int +<function>mysql_num_rows</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_num_rows</function> returns the number of rows in - a result set. This command is only valid for SELECT statements. - To retrieve the number of rows returned from a INSERT, UPDATE or + <function>mysql_num_rows</function> returns the number +of rows in + a result set. This command is only valid for SELECT +statements. + To retrieve the number of rows returned from a INSERT, +UPDATE or DELETE, use <function>mysql_affected_rows</function>. <example> <title> @@ -1532,10 +1783,13 @@ </title> <programlisting role="php"> &lt;?php -$conn = mysql_connect("hostaddress", "username", "password"); -mysql_select_db("database",$conn); // needed if you have m,ultiple db's -$Resultfornummembers = mysql_query("SELECT * FROM Accounts",$conn); -$NumMembers = mysql_numrows($Resultfornummembers); +$conn = mysql_connect("hostaddress", "username", +"password"); +mysql_select_db("database",$conn); // needed if you have +m,ultiple db's +$Resultfornummembers = mysql_query("SELECT * FROM +Accounts",$conn); +$NumMembers = mysql_num_rows($Resultfornummembers); echo "$NumMembers Members"; ?> </programlisting> @@ -1548,7 +1802,8 @@ <function>mysql_fetch_row</function>. </para> <para> - For downward compatibility <function>mysql_numrows</function> can + For downward compatibility +<function>mysql_numrows</function> can also be used. </para> </refsect1> @@ -1565,7 +1820,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_pconnect</function></funcdef> + <funcdef>int +<function>mysql_pconnect</function></funcdef> <paramdef>string <parameter> <optional>hostname @@ -1583,46 +1839,61 @@ </funcprototype> </funcsynopsis> <para> - Returns: A positive MySQL persistent link identifier on success, + Returns: A positive MySQL persistent link identifier on +success, or false on error. </para> <para> - <function>mysql_pconnect</function> establishes a connection - to a MySQL server. The following defaults are assumed for - missing optional parameters: <parameter>host:port</parameter> = - 'localhost:3306', <parameter>username</parameter> = name of the + <function>mysql_pconnect</function> establishes a +connection + to a MySQL server. The following defaults are assumed +for + missing optional parameters: +<parameter>host:port</parameter> = + 'localhost:3306', <parameter>username</parameter> = +name of the user that owns the server process and <parameter>password</parameter> = empty password. </para> <para> The hostname string can also include a port - number. eg. &quot;hostname:port&quot; or a path to a socket + number. eg. &quot;hostname:port&quot; or a path to a +socket eg. &quot;:/path/to/socket&quot; for the localhost. <note> <para> Support for &quot;:port&quot; wass added in 3.0B4. </para> <para> - Support for the &quot;:/path/to/socket&quot; was added in + Support for the &quot;:/path/to/socket&quot; was +added in 3.0.10. </para> </note> </para> <para> <function>mysql_pconnect</function> acts very much like - <function>mysql_connect</function> with two major differences. + <function>mysql_connect</function> with two major +differences. </para> <para> - First, when connecting, the function would first try to find a - (persistent) link that's already open with the same host, - username and password. If one is found, an identifier for it + First, when connecting, the function would first try to +find a + (persistent) link that's already open with the same +host, + username and password. If one is found, an identifier +for it will be returned instead of opening a new connection. </para> <para> - Second, the connection to the SQL server will not be closed when - the execution of the script ends. Instead, the link will remain - open for future use (<function>mysql_close</function> will not - close links established by <function>mysql_pconnect</function>). + Second, the connection to the SQL server will not be +closed when + the execution of the script ends. Instead, the link +will remain + open for future use (<function>mysql_close</function> +will not + close links established by +<function>mysql_pconnect</function>). </para> <para> This type of links is therefore called 'persistent'. @@ -1639,20 +1910,29 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_query</function></funcdef> - <paramdef>string <parameter>query</parameter></paramdef> + <funcdef>int +<function>mysql_query</function></funcdef> + <paramdef>string +<parameter>query</parameter></paramdef> <paramdef>int - <parameter><optional>link_identifier</optional></parameter> + +<parameter><optional>link_identifier</optional></para +meter> </paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_query</function> sends a query to the currently - active database on the server that's associated with the + <function>mysql_query</function> sends a query to the +currently + active database on the server that's associated with +the specified link identifier. If - <parameter>link_identifier</parameter> isn't specified, the last - opened link is assumed. If no link is open, the function tries - to establish a link as if <function>mysql_connect</function> was + <parameter>link_identifier</parameter> isn't specified, +the last + opened link is assumed. If no link is open, the +function tries + to establish a link as if +<function>mysql_connect</function> was called with no arguments, and use it. </para> <note> @@ -1661,16 +1941,22 @@ </para> </note> <para> - <function>mysql_query</function> returns TRUE (non-zero) or FALSE - to indicate whether or not the query succeeded. A return value - of TRUE means that the query was legal and could be executed by - the server. It does not indicate anything about the number of - rows affected or returned. It is perfectly possible for a query + <function>mysql_query</function> returns TRUE +(non-zero) or FALSE + to indicate whether or not the query succeeded. A +return value + of TRUE means that the query was legal and could be +executed by + the server. It does not indicate anything about the +number of + rows affected or returned. It is perfectly possible for +a query to succeed but affect no rows or return no rows. </para> <para> The following query is syntactically invalid, so - <function>mysql_query</function> fails and returns FALSE: + <function>mysql_query</function> fails and returns +FALSE: <example> <title><function>mysql_query</function></title> <programlisting role="php"> @@ -1684,7 +1970,8 @@ <para> The following query is semantically invalid if <literal>my_col</literal> is not a column in the table - <literal>my_tbl</literal>, so <function>mysql_query</function> + <literal>my_tbl</literal>, so +<function>mysql_query</function> fails and returns FALSE: <example> <title><function>mysql_query</function></title> @@ -1697,25 +1984,35 @@ </example> </para> <para> - <function>mysql_query</function> will also fail and return FALSE - if you don't have permission to access the table(s) referenced by + <function>mysql_query</function> will also fail and +return FALSE + if you don't have permission to access the table(s) +referenced by the query. </para> <para> Assuming the query succeeds, you can call - <function>mysql_num_rows</function> to find out how many rows + <function>mysql_num_rows</function> to find out how +many rows were returned for a SELECT statment or - <function>mysql_affected_rows</function> to find out how many - rows were affected by a DELETE, INSERT, REPLACE, or UPDATE + <function>mysql_affected_rows</function> to find out +how many + rows were affected by a DELETE, INSERT, REPLACE, or +UPDATE statement. </para> <para> - For SELECT statements, <function>mysql_query</function> returns a + For SELECT statements, <function>mysql_query</function> +returns a new result identifier that you can pass to - <function>mysql_result</function>. When you are done with the - result set, you can free the resources associated with it by - calling <function>mysql_free_result</function>. Although, the - memory will automatically be freed at the end of the script's + <function>mysql_result</function>. When you are done +with the + result set, you can free the resources associated with +it by + calling <function>mysql_free_result</function>. +Although, the + memory will automatically be freed at the end of the +script's execution. </para> <para> @@ -1738,7 +2035,8 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>mixed <function>mysql_result</function></funcdef> + <funcdef>mixed +<function>mysql_result</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter>row</parameter></paramdef> <paramdef>mixed @@ -1749,25 +2047,37 @@ </funcprototype> </funcsynopsis> <para> - <function>mysql_result</function> returns the contents of one - cell from a MySQL result set. The field argument can be the - field's offset, or the field's name, or the field's table dot - field's name (fieldname.tablename). If the column name has been - aliased ('select foo as bar from...'), use the alias instead of + <function>mysql_result</function> returns the contents +of one + cell from a MySQL result set. The field argument can +be the + field's offset, or the field's name, or the field's +table dot + field's name (fieldname.tablename). If the column name +has been + aliased ('select foo as bar from...'), use the alias +instead of the column name. </para> <para> - When working on large result sets, you should consider using one - of the functions that fetch an entire row (specified below). As - these functions return the contents of multiple cells in one + When working on large result sets, you should consider +using one + of the functions that fetch an entire row (specified +below). As + these functions return the contents of multiple cells +in one function call, they're MUCH quicker than - <function>mysql_result</function>. Also, note that specifying a - numeric offset for the field argument is much quicker than + <function>mysql_result</function>. Also, note that +specifying a + numeric offset for the field argument is much quicker +than specifying a fieldname or tablename.fieldname argument. </para> <para> - Calls to <function>mysql_result</function> should not be mixed - with calls to other functions that deal with the result set. + Calls to <function>mysql_result</function> should not +be mixed + with calls to other functions that deal with the result +set. </para> <para> Recommended high-performance alternatives: @@ -1787,8 +2097,10 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>mysql_select_db</function></funcdef> - <paramdef>string <parameter>database_name</parameter></paramdef> + <funcdef>int +<function>mysql_select_db</function></funcdef> + <paramdef>string +<parameter>database_name</parameter></paramdef> <paramdef>int <parameter> <optional>link_identifier</optional> @@ -1800,15 +2112,21 @@ Returns: true on success, false on error. </para> <para> - <function>mysql_select_db</function> sets the current active - database on the server that's associated with the specified link - identifier. If no link identifier is specified, the last opened - link is assumed. If no link is open, the function will try to - establish a link as if <function>mysql_connect</function> was + <function>mysql_select_db</function> sets the current +active + database on the server that's associated with the +specified link + identifier. If no link identifier is specified, the +last opened + link is assumed. If no link is open, the function will +try to + establish a link as if +<function>mysql_connect</function> was called, and use it. </para> <para> - Every subsequent call to <function>mysql_query</function> will be + Every subsequent call to +<function>mysql_query</function> will be made on the active database. </para> <para> See also: @@ -1817,7 +2135,8 @@ <function>mysql_query</function>. </para> <para> - For downward compatibility <function>mysql_selectdb</function> + For downward compatibility +<function>mysql_selectdb</function> can also be used. </para> </refsect1> @@ -1832,19 +2151,25 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>mysql_tablename</function></funcdef> + <funcdef>string +<function>mysql_tablename</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> <paramdef>int <parameter>i</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - <function>mysql_tablename</function> takes a result pointer - returned by the <function>mysql_list_tables</function> function - as well as an integer index and returns the name of a table. The - <function>mysql_num_rows</function> function may be used to + <function>mysql_tablename</function> takes a result +pointer + returned by the <function>mysql_list_tables</function> +function + as well as an integer index and returns the name of a +table. The + <function>mysql_num_rows</function> function may be +used to determine the number of tables in the result pointer. <example> - <title><function>Mysql_tablename</function> Example</title> + <title><function>Mysql_tablename</function> +Example</title> <programlisting role="php"> &lt;?php mysql_connect ("localhost:3306");
« previous php.doc (#969332810) next »