|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
I am foolishly writing my own Database Abstraction Layer for both Access and MySQL.
MySQL is quite easy, as most my functions parallel those built into PHP. MS Access is a different story. Particularly a "num_rows" function to count the number of rows returned by a SQL query. Before you tell me to use ODBC, I'm not using it! I'm using a COM object instead so I can keep the database and the PHP together. I want to be able to connect to my Access DB even if I don't have access on the server to make an ODBC connection. So the simple and easy solution is out. My current solution works fine when the query returns 2 or more rows. Basically it runs through a while loop and increments a counter. The problem is what happens if the query returns one or no rows. Here's an exerpt from the code: PHP Code:
Anyone out there have any good ideas how to do this better? Anyone know the way to get the number of rows directly from the Jet Engine through PHP? (That's the ideal solution.) |
|
#2
|
|||
|
|||
|
I have also wrote a cross-db class. I would recommend sticking to the basics. You really only need about 5 functions that will work with any DB.
I really don't see the point of doing a count, It has to fetch all the rows and is inefficient, I would always do a select count(*)anyways. So what I believe to be the functions necessary are: 1. open - connect to db and return handle 2. execute - parse and execute query, return cursor 3. fetch - move cursor forward 4. getColumnResult - get value of column from cursor 5. close - close db |
|
#3
|
||||
|
||||
|
yeah, I'm working around the problem by doing a
PHP Code:
What I'm trying to work toward is full functionality comprable to the built-in MySQL functions. It's probably a pipe dream in this case. That and using a SELECT count() is more to write. Then again, it does run quicker. That's why I want a one-liner that's built into the Jet DB Engine. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > "num_rows" in MS Access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|