phpBBHacks.com, the place for phpBB users

Bookmark and Share

phpBB Database Layer

Postby Thoul » September 26th 2003, 4:39 am

sql_fetchfield
sql_fetchfield( string|field, [ int|number [, resource|query_id ] ] )

Code: Select all
// Get username from the 21st row
$field = $db->sql_fetchfield('username', 21, $result);
// Get username in the current row
$field = $db->sql_fetchfield('username');


Returns the content of one field (or table column) from one row in a SQL result set. The parameter field should be the name of the field to be returned. number should be the number of the row from which to return the field. If number is -1 (the default value), the current row will be used. See the special note for information on the query_id parameter.

Using sql_fetchrow to retrieve an entire row instead of a single field is recommended. sql_fetchrow will often be faster and in some cases sql_fetchfield actually calls sql_fetchrow or does the same work anyway. Also, on Oracle databases, the field will be returned entirely in uppercase.

See Also: mssql_result, mssql_fetch_array, mysql_result, OCIExecute, OCIFetch, OCIResult, pg_fetch_array
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Postby Thoul » September 26th 2003, 4:40 am

sql_rowseek
sql_rowseek( int|row_number [, resource|query_id ])

Code: Select all
$db->sql_rowseek($offset, $result);


Used to move the internal row pointer of the result associated with query_id to the indicated row number. The next call to sql_fetchrow would return the row to which the internal pointer is moved.

The function will return TRUE unless the row pointer can not be moved to the indicated row, in which case FALSE is returned. See the special note for information on the query_id parameter for another case in which FALSE could be returned.

See Also: mssql_data_seek, mysql_data_seek, OCIExecute, OCIFetch
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Postby Thoul » September 26th 2003, 4:42 am

sql_nextid
sql_nextid( [ resource|query_id ] )

Code: Select all
$id_number = $db->sql_nextid();


Returns the id number automatically generated when the previous INSERT query was executed. In MySQL, this is the value of an AUTO_INCREMENT column. sql_nextid should be used after the INSERT query and before any other queries are executed.

See the special note for information on the query_id parameter. Using this parameter is not recommended for this function. It will not be used by the MS Access, MS SQL, MS SQL (ODBC) or MySQL database layers.

Oracle users may encounter errors due to this function being defined twice. If this occurs, the errors may be solved by deleting one copy of the function.

See Also: mysql_insert_id, OCIParse, OCIExecute, OCIFetchInto, pg_exec, pg_fetch_array
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Postby Thoul » September 26th 2003, 4:44 am

sql_freeresult
sql_freeresult( [ resource|query_id ] )

Code: Select all
$db->sql_freeresult();
$db->sql_freeresult($result);


This function is used to free all memory associated with an SQL query. See the special note for information on the query_id parameter.

sql_freeresult should be used if you are worried about the memory being used for a query. All memory is freed when a script finishes executing, but sql_freeresult is helpful when dealing with queries that return large result sets.

See Also: odbc_free_result, mssql_free_result, mysql_free_result, OCIFreeStatement, pg_freeresult
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Postby Thoul » September 26th 2003, 4:46 am

sql_error
sql_error( [ resource|query_id ] )

Code: Select all
$error = $db->sql_error();
$error = $db->sql_error($result);


Returns an associative array containing information about the last SQL error encountered. This array typically has the following elements:

  • code - An error code generated by the database software. Disabled on MS Access and MS SQL. Always -1 on PostgreSQL.
  • message - The error message returned by the database software. Always "Error" on MS Access.


The function always returns an empty string on the ODBC database layer. See the special note for information on the query_id parameter.

See Also: odbc_error, odbc_errormsg, mssql_get_last_message, mysql_error, mysql_errno, OCIError, pg_errormessage
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Previous

Return to phpBB 2: Technical Reference

Who is online

Users browsing this forum: No registered users and 0 guests