Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1025427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:55:36+00:00 2026-05-16T11:55:36+00:00

I’m trying to write a simple, thin and efficient database abstraction layer on top

  • 0

I’m trying to write a simple, thin and efficient database abstraction layer on top of the PHP MySQLi (procedural) and MSSQL libraries, to be used like this…

while ($a = db::go('db_name')->query('select * from foo')->row()) {
  print_r($a);
}

I have the class written, but am struggling somewhat with how best to loop through the results. The class will only need to handle select queries, and will have to handle some large result sets. Here’s a snippet of the ->row() method…

public function row() {
  return $this->{'get'.ucwords($this->details['type']).'Row'}();
}
private function getMysqliRow() {
  return @mysqli_fetch_assoc($this->result);
}
private function getMssqlRow() {
  return @mssql_fetch_assoc($this->result);
}

At the moment, the call is resulting in an infinite loop, and retrieving the same row each time because the internal pointer in the result set isn’t incremented in the same way as a while ($a = mssql_data_seek($result)) call would, which makes complete sense (a result set isn’t global, you should be able to handle more than one result set at a time!).

So, does anyone know of an elegant and efficient way around this? Or is the only solution to use the data seek functions (mysqli_data_seek() and mssql_data_seek()) and hold a pointer to the current position in the result set? If so, how efficient is this (I will be handling large result sets > 250000)? And how would the while loop handle reaching the end of the result set?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:55:37+00:00Added an answer on May 16, 2026 at 11:55 am

    Ignore this, it was me being silly! I hadn’t made the result resource a static member, so it was being re-retrieved on each call. Apologies!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.