[[v5:addons:Index]]\\ ====== Unsupported Addons ====== These addon utilities are distributed as part of ADOdb, but are provided as-is, with no confirmation of compatibility with later versions of PHP or operating system, or of compatibility with a specific driver. Fixes and updates are always welcome. ----------------------- == Requires == tohtml.inc.php == Syntax == string rs2html ( object $recordset, optional string $tableStyles=false, optional array $columnHeaders=false, optional bool $htmlspecialchars=true, optional bool $echo = true ) ===== rs2html ===== This addon provides a method of displaying a recordset in an html table. In its simplest implementation, it can be used just by passing a recordset. This is an easy way to display a retrieved recordset for debugging purposes. ==== Parameters ==== === $recordset === A handle to an ADOdb recordset, provided by an ''execute()'' or a ''selectLimit()'' statement. === $tableStyles === Historically this parameter was used for items like 'border' and 'width' but can also be used for modern attributes such as 'class' and 'style'. Double quotes in the statement should be escaped. === $columnHeaders === If provided, the numeric array is used for column headers instead of the field names. It **must** contain index entries for all columns. === $htmlSpecialChars === By default, the PHP function htmlSpecialChars is applied to all values. This parameter disables this functionality. === $echo === By default, the output is echoed directly to the screen. If the value is set to false, the output is collected in a string and returned from the function. ==== Global Variables ==== THe following variables may be defined, and are globalized into the function ^Variable^Description^ |$gSQLMaxRows|The maximum number of rows displayed in the table. This does not affect the number of rows retrieved| |$gSQLBlockRows|The records returned are grouped into blocks of this number of records. Historically, this feature was used to improve rendering speed. | |$ADODB_ROUND| The number of decimal places that floating point numbers are rounded to| ==== Usage ==== /* * Connection to Access northwind database */ include 'adodb/adodb.inc.php'; include 'adodb/tohtml.inc.php'; $db = newAdoConnection('access'); $sql = 'select * from orders' $recordset = $db->execute($sql); $tableStyles = "class=\"rs2class\" style='border:1px dashed silver'"; rs2html($recordset,$tableStyles); -------------------------------------- ===== rs2csv & rs2tab==== == Requires == toexport.inc.php == Syntax == string rs2csv( obj $recordSet optional bool $addTitles=true ) string rs2tab( obj $recordSet optional bool $addTitles=true ) ==== Description ==== The function ''rs2csv()'' takes a recordset object as an argument and returns the data as a string containing a CSV format file. If selected, the first row contains the column names. The rs2tab function returns the data as tab separated data ==== Usage ==== /* * Connection to Northwind Database */ $sql = "SELECT * FROM orders"; $recordset = $db->execute($sql); $csv = rs2csv($recordset); --------------------------------------- String fields are not quoted or escaped per standard CSV format ------------------------------------------ ===== rs2csvfile & rs2tabfile==== == Requires == toexport.inc.php == Syntax == void rs2csvfile( obj $recordSet handle $filePointer optional bool $addTitles=true ) void rs2tabfile( obj $recordSet handle $filePointer optional bool $addTitles=true ) ==== Description ==== The function ''rs2csvfile()'' takes a recordset object as an argument and outputs the data to a CSV file indicated by the file pointer $filePointer . If selected, the first row contains the column names. The ''rs2tabfile()'' function returns the data as tab-separated. ==== Usage ==== /* * Connection to Northwind Database */ $filePointer = fopen('/tmp/products.csv','w'); $sql = "SELECT * FROM products"; $recordset = $db->execute($sql); $csv = rs2csv($recordset, $filePointer); ---------------------------------------------- String fields are not quoted or escaped per standard CSV format -------------------------------------------------------- ===== rs2csvout & rs2tabout==== == Requires == toexport.inc.php == Syntax == string rs2csvout( obj $recordSet optional bool $addTitles=true ) string rs2tabout( obj $recordSet optional bool $addTitles=true ) ==== Description ==== The function ''rs2csvout()'' takes a recordset object as an argument and sends the data as a string containing a CSV format file to the PHP STDOUT. If selected, the first row contains the column names. The function ''rs2tabout()''. Returns the data in tab-separated format. ==== Usage ==== /* * Connection to Northwind Database */ $sql = "SELECT * FROM products"; $recordset = $db->execute($sql); $csv = rs2tabout($recordset); ------------------------- String fields are not quoted or escaped per standard CSV format ------------------------------ ===== The xmlrpc library ====== This addon provides an interface between the adodb recordset and the php xmlrpc library. [[v5:addons:xmlrpc|More Information]] ----------------------------- ===== Paging & Scrolling with ADOdb Pager ===== == Requires == adodb-pager.inc.php The following code snippet creates a very simple pager like the sample one shown below, allowing you to navigate between pages of a recordset. {{:v5:addons:adodb_pager_sample_output.png|Sample output from ADODB_Pager}} include_once 'adodb/adodb.inc.php'; include_once 'adodb/adodb-pager.inc.php'; $db = ADONewConnection('mysqli'); $db->connect('localhost', 'user', 'password', 'adodb'); $sql = 'select * from adoxyz'; $pager = new ADODB_Pager($db, $sql); $pager->render(5); The number of rows to display at one time is controled by the //Render($rows)// method. If you do not pass any value to Render(), the Pager will default to 10 records per page. You can control the column titles by aliasing them in your SQL (supported by most databases): $sql = 'select id as "ID", firstname as "First Name", lastname as "Last Name", created as "Date Created" from adoxyz'; The ADODB_Pager code can be adapted by a programmer to improve the layout, e.g. replacing the text links by images, and the dull white background by more interesting colors. By default, special characters in the displayed data will be escaped to prevent execution of HTML code. If you wish to have them interpreted instead, before calling Render() you can set $pager->htmlSpecialChars = false; This is a **security risk**, unescaped HTML will leave you vulnerable to Cross-site scripting (XSS) attacks. Use with caution, and only with trusted data.