I wrote a DAL for MySQL/PHP. It has worked without
any problems whatsoever. I have a need to connect to
a MSSQL server to do some reports. I re-wrote the
DAL to fit the needs/syntax of MSSQL/Sybase.
However, I get errors whenever I atempt to do more
than a query statement.
The following php code:
<?
include ('msdb.php');
$stuff = new db("SELECT * FROM table");
echo $stuff->getNumRows();
?>
Produces the following error when I run it:
"Warning: 1 is not a Sybase result index
in /test/msdb.php on line 60"
Here is the code for msdb.php:
<?
Class Db
{
var $user='user';
var $host='host';
var $pword='password';
var $dbname='databasename';
var $dbconnect='';
var $SQL='';
var $selectd='';
function db($SQL="")
{
if ($SQL)
{
$this->SQL = $SQL;
$this->query();
}
}
function connect($host='', $user='', $pword='')
{
$this->dbconnect = sybase_connect($this->host,
$this->user, $this->pword);
}
function select()
{
sybase_select_db($this->dbname, $this-
function disconnect()
{
sybase_close($this->dbconnect);
}
function killsql()
{
$this->SQL = '';
}
function query()
{
$this->connect();
$this->select();
$this->selectd = sybase_query($this->SQL,
$this->dbconnect);
$this->disconnect();
}
function fetch()
{
return sybase_fetch_array($this->selectd);
}
function getNumRows()
{
if (!$this->selectd) return 0;
return sybase_num_rows($this->selectd);
}
}
?>
I know that Sybase/MSSQL support is functioning
properly because I am able to connect to the server,
and grab data by using both the mssql and sybase
commnads in php.
I would rather have the DAL functioning properly
because I have become quite accustomed to the command
syntax for it, and it's ease of use.
Can someone shed some light on this for me?
Thanx