WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Database and Recordset classes fo SyBASE Usage is obvious.
Categories : Sybase, Databases, PHP Classes, PHP Update Picture
Razvan Stanescu
Date : Jan 17th 1999
Grade : 3 of 5 (graded 2 times)
Viewed : 10050
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Razvan Stanescu
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php

//
// Author: Razvan STANESCU <pappy@gecad.ro>
//
// You may use this code as long as you leave this note
//

//
// Usage example
//
// require("sybase.php3");
//
// $sybdb = new CSybDb("SYBASE", "http_user", "http_pass", "http_db");
// $sybrs = new CSybRs("select * from http_log", $sybdb);
//
// $sybrs->display(); // ... or do anything else
//
// $sybrs->destroy();
// $sybdb->destroy();
//

class CSybDb
{
var $sybdb;

function CSybDb($server, $user, $pass, $dbname = "")
{
$this->sybdb = sybase_connect($server, $user, $pass);
if( $this->valid() && $dbname != "" ) {
if( !sybase_select_db($dbname, $this->sybdb) ) {
destroy();
}
}
}
function destroy()
{
if( $this->valid() ) {
sybase_close($this->sybdb);
}
$this->sybdb = 0;
}
function valid()
{
return $this->sybdb != 0;
}
};

class CSybRs
{
var $recs;
var $rows;
var $cols;
var $crow;
var $rarr;
var $fail;

function CSybRs($query, $sybdb)
{
$this->recs = 0;
$this->rows = 0;
$this->cols = 0;
$this->fail = 1;
$this->crow = 0;

if( !$sybdb->valid() ) return;

$this->recs = sybase_query($query, $sybdb->sybdb);
if( !$this->recs ) return;

$this->rows = sybase_num_rows($this->recs);
$this->cols = sybase_num_fields($this->recs);

$this->fail = 0;
}

function destroy()
{
if( !$this->recs ) return;
// sybase_freeresult($this->recs);
$this->recs = 0;
}

function valid()
{
return !$this->fail && $this->recs != 0;
}

function seek($nrow)
{
if( !$this->valid() ) return 0;
if( $this->bof() && $this->eof() ) return 0;

if( sybase_data_seek($this->recs, $nrow) ) {
$this->crow = $nrow;
$this->rarr = sybase_fetch_array($this->recs);
if( $this->rarr ) {
return 1;
}
}
$this->fail = 1;
return 0;
}

function eof()
{
return $this->crow == $this->rows;
}

function bof()
{
return $this->crow < 0;
}

function first()
{
$this->crow = 0;
if( !$this->seek($this->crow) ) {
// mark as bof
$this->crow = -1;
}
}

function prev()
{
if( $this->bof() ) return;
$this->crow--;
if( $this->bof() ) return;

if( !$this->seek($this->crow) ) {
// mark as bof
$this->crow = -1;
}
}


function next()
{
if( $this->eof() ) return;
$this->crow++;
if( $this->eof() ) return;

$this->rarr = sybase_fetch_array($this->recs);
if( !$this->rarr ) {
// mark as eof
$this->crow = $this->rows;
}
}

function last()
{
$this->crow = $this->rows - 1;
if( !$this->seek($this->crow) ) {
// mark as eof
$this->crow = $this->rows;
}
}

function valueof($col)
{
if( !$this->valid() ) return;
return $this->rarr[$col];
}

function showheader($col, $fmt = "")
{
$fld = sybase_fetch_field($this->recs, $col);
printf( "\t<th %s>%s</th>\n", $fmt, is_string($col) ? $col : $fld->name);
}

function showvalue($col, $fmt = "", $def = "")
{
$v = $this->valueof($col);
printf( "\t<td %s>%s</td>\n", $fmt, $v == "" ? $def : $v);
}

function display()
{
if( !$this->valid() ) return;

printf( "<table cellspacing=1 cellpadding=1 border=1>\n");

printf( "<tr>\n");
for( $c = 0; $c < $this->cols; $c++ ) {
$this->showheader($c);
}
printf( "</tr>\n");

$this->first();
while( !$this->eof() ) {
printf( "<tr>\n");
for( $c = 0; $c < $this->cols; $c++ ) {
$this->showvalue($c);
}

printf( "</tr>\n");
$this->next();
}
printf( "</table>\n");
}
};

?>



MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
This class splits the results of the query into multiple pages like what the search engine does.
Categories : PHP Classes, PHP, MySQL, Databases
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
ADODB Database Wrapper Abstraction Library for PHP: MySQL, MSSQL, Oracle, Interbase,ODBC, Microsoft Access and FoxPro.
Categories : PHP Classes, Databases, PHP, General SQL, ODBC
Ajax PHP Tree (Left and Right) with MySQL
Categories : PHP, Databases, MySQL, AJAX, PHP Classes
YellowPages Content Grabber (PHP5 +)
Categories : PHP, PHP Classes, Regexps, Databases, MySQL
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
MySQL database class
Categories : PHP, MySQL, Databases, PHP Classes
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
Mssql database Manager
Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes
Recordset Class like ADO Recordset (plus DataBase Splitting feature) using ODBC functions
Categories : PHP Classes, ODBC, Databases, PHP
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
Use this class to connect your database transparently...
Categories : PHP Classes, Databases, PHP
Sort the results from a SELECT query (any number of columns) into an array automatically.
Categories : PHP, PHP Classes, Arrays, Databases, MySQL
 Morgan Heijdeman wrote :127
If you change &lt; into &lt;= in function bof() it doesn`t 
complain about empty tables.