Source for file ado_test.php
Documentation is available at ado_test.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Alexios Fakos (alex@fakos.de) |
// +----------------------------------------------------------------------+
// This is my test script, feel free to use it.
// due tableinfo() ADODB.Field properties depends on provider. some values are not supported
// therefore you get warnings PropGet() failed...
'dbsyntax' => "access", // or mssql or odbc
'username' => "Admin", // or sa
'database' => "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Programs\\Microsoft Office\\Office\\Samples\\Nordwind.mdb;Persist Security Info=False"
// 'database' => "Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=Northwind;"
$conn = DB ::connect ($dsn, TRUE );
// select your fetchmode to test (DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT)19.04.2002
$conn->setFetchMode (DB_FETCHMODE_ASSOC );
$sql = "SELECT TOP 10 * FROM Customers";
$rs = $conn->query ($sql);
while ($row = $rs->fetchRow ()) {
$sql = "SELECT TOP 5 * FROM Employees";
$rs = $conn->query ($sql);
while ($rs->fetchInto ($row)) {
$sql = "SELECT TOP 10 * FROM Orders";
$rs = $conn->query ($sql);
while ($row = $rs->FetchRow ()) {
// next examples taken from http://vulcanonet.com/soft/?pack=pear_tut#ss3.3.5
$sql = "SELECT * FROM Employees";
$to = $from + $res_per_page;
$fetchmode = DB_FETCHMODE_ASSOC; //(DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT)
$rs = $conn->query ($sql);
foreach (range($from, $to) as $rownum) {
if (!$row = $rs->fetchRow ($fetchmode, $rownum)) {
$sql = "SELECT TOP 5 * FROM Suppliers";
$rs = $conn->getOne ($sql);
$row = $conn->getRow ($sql);
$sql = "SELECT TOP 10 CompanyName FROM Suppliers";
$row = $conn->getCol ($sql);
$sql = "SELECT TOP 5 * FROM Suppliers";
echo "<b>getAssoc</b>\n";
$rs = $conn->getAssoc ($sql);
$rs = $conn->getAll ($sql);
printH2("Infos from query result");
$rs = $conn->query ($sql);
$sql = "DELETE FROM _test"; // use your own table:)
$rs = $conn->query($sql);
echo 'I have deleted ' . $conn->affectedRows() . ' rows';
$rs = $conn->nextId ("alex_3");
$rs = $conn->nextId ("alex_3");
// $rs->free(); no need after sequence stuff
echo "<br/>\n<hr/>\n<br/>";
echo "<b>" . $counter++ . "</b>";
echo "<h2>" . $caption . "</h2>";
Documentation generated on Mon, 11 Mar 2019 15:29:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|