Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

DB function proposal tep_db_fetch_all()


Recommended Posts

I've been building some new interfaces on my shop, and have realized that I would like to use mysqli_fetch_all, so I added it into my database.php.  It might be a useful function to have in osC.  Just a proposal.

  function tep_db_fetch_all($db_query) {
    return mysqli_fetch_all($db_query, MYSQLI_ASSOC);
  }

A little knowledge of php goes a long way.

Link to comment
Share on other sites

  • 4 years later...

still need to add check extension mysqlnd

  function tep_db_fetch_all($db_query) {
    // check if "mysqlnd" driver is used
    if (extension_loaded('mysqlnd') && function_exists('mysqli_fetch_all')) {
      return mysqli_fetch_all($db_query, MYSQLI_ASSOC);
    } else {
      $data = [];

      while ($row = tep_db_fetch_array($db_query)) {
        $data[] = $row;
      }

      return $data;
    }
  }

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...