Hello,

To have more than one result set per connection you should use prepared
statements. Using maxdb_stmt_bind_result() for binding parameters to the
statement's result set, you have one result set per statement.

An example can be found at
http://www.php.net/manual/en/function.maxdb-stmt-bind-result.php

Did you fix the library incompatibility errors? 

Regards,

Thomas Simenec
SAP Labs Berlin

-----Original Message-----
From: Sean Mollet [mailto:[EMAIL PROTECTED] 
Sent: Mittwoch, 5. Oktober 2005 20:31
To: [email protected]
Subject: New PHP Interface - Problems

I've been using SapDB/MaxDB with php in a production system for about 3 
years now. I recently decided to explore upgrading to Max 7.6 and PHP 5.
I'm not terribly pleased with the changes in the interface. After 
reading the docs, it appears as though the new interface is much faster.

However, it doesn't function the same way as the old one.

Php has always had trouble because of an almost complete lack of 
database abstraction. I liked the old system because it still used the 
odbc contructs and was somewhat abstracted natively. I've been unable to

build php5 using the --with-sapdb option due to some library 
incompatibility errors. I'm in the process of sorting that out and will 
inform this list when I do manage to build it that way.

In an effort to explore the new system, I wrote a quick shim that calls 
the various maxdb_ functions in lieu of their odbc_ counterparts. 
However, the changes to the _fetch_row function and the lack of a 
_result function have been real stumbling blocks. My application 
consists of 140Mb of php scripts. They all use the _fetch_row and 
_result the way that the odbc contructs do. After writing my shim 
however, I found out that the current incantation only allows one result

set per connection. This is a terrible design flaw. For all of the 
supposed performance gains it offers, I sincerely think that this 
flagrant waste of connections will totally negate them in any real 
application.

Getting back to point, I'm including my shim code because I'm hoping 
someone can think of a better or cleaner way to do this. The only way I 
could come up with to be able to pass result sets without rewriting my 
logic was to replace the connection and result links with classes that 
contained the necesary connect/free function calls, as well as the real 
connection and result links, and the result row after a fetch call is
made.

I sincerely appreciate any input on this. I'm going to try this shim on 
my development installation and hopefully produce some benchmarks. If 
the new interface really is as fast as they say it is, I suspect there 
are gains to be had even with the added overhead.

Sean Mollet
Vision Logistics Group
SapDB user since '01

class maxdb_connect_struct {
       public $database;
       public $node;
       public $username;
       public $password;
         public function __construct($host,$user,$pass,$dbname){
       $this->database=$dbname;
               $this->node=$host;
               $this->username=$user;
               $this->password=$pass;
           }
       }

class maxdb_odbc_struct {
       public $result_query;
       public $result_link;
       public $result_row;
       public $connection;
       public $fetched=0;
       public function __construct($database,$query){
       $this->connection = 
maxdb_connect($database->node,$database->username,$database->password,$d
atabase->database); 

       $this->result_query=$query;
       $this->result_link = maxdb_query($this->connection,$query);
               if(!$this->result_link){
                   print "Error occured in query :".$this->result_query;
                   }
           }
       public function __destruct(){
       if($this->result_link){
            maxdb_free_result($this->result_link);
             }
           }
       }

function odbc_connect($dbname,$user,$pass,$host='127.0.0.1')
{
$link = new maxdb_connect_struct($host,$user,$pass,$dbname);
return $link;
}

function odbc_exec($database,$query)
{
$result = new maxdb_odbc_struct($database,$query);
return $result;
}

function odbc_fetch_row(&$result)
{
$result->fetched=1;
if($result->result_link){
    $result->result_row=maxdb_fetch_row($result->result_link);
    }
else{
    return FALSE;
    }
if($result->result_row<>false){
    return TRUE;
    }
else{
    return FALSE;
    }
}

function odbc_result($result,$fieldid)
{
if($result->fetched==0){
   odbc_fetch_row($result);
   }
return $result->result_row[$fieldid-1];

}

-- 
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to