Skip to Content.
Sympa Menu

freetds - Re: [freetds] SQLRowCount problem with freeTDS+unixODBC+PHP with MSSQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] SQLRowCount problem with freeTDS+unixODBC+PHP with MSSQL
  • Date: Fri, 16 Dec 2005 22:31:01 -0500

Roger "Peña" Escobio wrote:
> as soon as I sent the messages I had another question
> about this topic:
>
> --- "Lowden, James K" <LowdenJK AT bernstein.com> wrote:
>
> > > From: Roger "Pe�a" Escobio
> > > Sent: Friday, December 16, 2005 3:44 PM
> > >
> > > I can't retrive the correct RowCount after a
> > 'select' query, nor
> > > do I can call another query, but if I run across
> > all the result
> > > (either with odbc_fetch_row() of odbc_result_all()
> > ) I can get the
> > > _right_ RowCount and execute another SQL query
> >
> > http://www.freetds.org/faq.html#pending
> >
> > These issues are both related to the fact that the
> > rows are transmitted as the server fetches them.
> > Until the last row is fetched, the rowcount is not
> > known.
> >
> > > another problem is that the "row pointer", the one
> > that allow to
> > > retrive a particular row from the result, do not
> > work at all :-(
>
> if you are right, why the same PHP application run ok,
> without any complain, in a Windows plataform ? with
> other ODBC driver (I have to check which one)
> php still should re-use the same connection, is it?
> so my no-knowledge say that it have to do with the
> driver also
>
> another question that I have is why I can retrive an
> specific row from the result of a query? the 2nd
> argument of the function odbc_fetch_row() do work at
> all :-(
> bool odbc_fetch_row ( resource result_id [, int
> row_number] )
>
> is this a problem with freetds or an up-layer
> (unixODBC, php) problem?

Frediano is the real expert on our ODBC driver. I'm working from my
understanding of its state and what I know about the TDS protocol.

I think the reason this works in the Windows driver is that Microsoft's
driver supports "bookmarks". The driver retrieves all rows into a set,
and lets the application pick one. That technique is known as a "client
side cursor". To support anything except a "forward-only" cursor (not
very interesting: just fetch rows from the server) the driver fetches
*all* the rows. That done, it learns the rowcount and can easily let the
application choose row N from the set.

FreeTDS doesn't do any of that. AFAIK, it doesn't support any kind of
client-side cursor. (There is row buffering in db-lib, but it's much
simpler and not much used.)

PHP's code I've never looked at very much. I can tell you PHP has the
opportunity to query the driver to discover its feature set, and thereby
the chance to support certain features (or not). Without completely
re-implementing cursors itself, though, it can't provide features not
present in the driver. When an application requests a service that
depends on a feature not supported by the driver, PHP's reasonable course
is to return an error: "Sorry, it doesn't work like that." Different
drivers differ, YMMV.

Anyone wishing and willing to add cursors to the driver is welcome to send
a patch and join the project. We're a pretty friendly bunch; it's been
literally years since I bit anyone.

HTH. :-)

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page