Hi -
There are a bunch of PEAR tutorials around... most of them geared toward MySQL, however, and the syntax is just different enough that they don't work properly with MSSQL 8.
This one isn't bad, but has to be modified a bit:
http://codewalkers.com/tutorials/18/2.html
Here's a small script that works for me. It just loops through the database displaying whatever it finds:
<?
$limit = 5;
require_once 'DB.php';
$db_engine = 'mssql';
$db_user = 'sa';
$db_pass = '';
$db_host = 'localhost';
$db_name = 'databasepure';
$dsn = "$db_engine://$db_user:$db_pass@$db_host/$db_name";
$db = DB::connect($dsn);
if (DB::isError($db)) {
die ($db->getMessage());
}
if(isset($GET['start'])): $start = $GET['start']; else: $start = 0; endif;
$sql = "SELECT * FROM users ORDER BY username";
$result = $db->query($sql);
if (DB::isError($result)) {
die ($result->getMessage());
}
foreach (range($start, $start + $limit - 1) as $rownum) {
if (!$row = $result->fetchrow(DB_FETCHMODE_ASSOC, $rownum)) {
break;
}
echo $row['stuff'] . "<BR>\n";
}
$result->free();
$numrows = $db->getOne('SELECT count(*) FROM mystuff');
$db->disconnect();
if($start > 0) {
echo "<a href=\"".$SERVER['PHP_SELF']."?start=".($start - $limit)."\">Back</a><BR>\n";
}
if (($start + $limit) < $numrows) {
echo "<a href=\"".$SERVER['PHP_SELF']."?start=".($start + $limit)."\">Next</a><BR>\n";
}
?>