Database Code

  Home arrow Database Code arrow Mimic ASPs GetRows functionality in PH...
DATABASE CODE

Mimic ASPs GetRows functionality in PHP
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2005-03-10

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This function emulates the ASP GetRows function. It creates a 2 dimensional
    array of the data set where the :

    1st dimension is the row number of the data
    2nd dimension are the data fields

    By : bastien

    ASP(VBScript), from time to time, has some neat features. One is a function called GetRows, which pertains to the Recordset object. Its purpose is to pull the entire recordset into a 2d array and close the connection to free resources. This type of functionality can be quite useful in a high load environment. So I thought it would duplicate the functionality with PHP. So here it is...

    <?
    function GetRows($handle)
    {
    /*
    This function emulates the ASP GetRows function. It creates a 2 dimensional
    array of the data set where the :

    1st dimension is the row number of the data
    2nd dimension are the data fields

    Returns a two dimensional array if there are record or false if no records
    come out of the query
    */

    if (mysql_num_rows($handle)>0){

    //initialize the array
    $RsArray1 = array();

    //loop thru the recordset
    while ($rows = mysql_fetch_array($handle))
    {
    $RsArray1[] = $rows;
    } //wend
    return $RsArray1;
    }else{
    //no records in recordset so return false
    return false;
    } //end if
    //close the connection
    mysql_close($handle);

    } //end function
    ?>

    Bastien
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Database Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    DATABASE CODE ARTICLES

    - Converting CSV Files to MySQL Insert Queries...
    - Examples and Tools for Database Design
    - Relationships, Entities and Database Design
    - Modeling and Designing Databases
    - Data extract to Excel
    - Oracle database class 0.76
    - The opposite of mysql_fetch_assoc
    - On line Thermal Transmitance Calculation
    - pjjTextBase
    - PHP Object Generator
    - FastMySQL
    - RC4PHP
    - SQL function with integrated sprintf()
    - DB Interaction Classes v1.1
    - deeMySQLParser


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap