Results 1 to 10 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Fetch next row from database query

    Not reliably before v155.

    Why exactly are you wanting to rewind to start?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  2. #2
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    463
    Plugin Contributions
    0

    Default Re: Fetch next row from database query

    A little bit messed up - will start thinking straight after aligning with ZenCart db-procedures.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Fetch next row from database query

    The syntax is definitely much easier after upgrading to v155:

    Code:
    $sql = "foo";
    $result = $db->Execute($sql);
    
    foreach ($result as $row) {
    
      echo $row['fieldname'];
    
    }
    And also supports proper Iterator and Countable actions such as reset(), count(), as well as Move(0) and more.

    ... but you need at least v1.5.5 to have these available.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    463
    Plugin Contributions
    0

    Default Re: Fetch next row from database query

    Ok, Thanks.

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,879
    Plugin Contributions
    96

    Default Re: Fetch next row from database query

    Quote Originally Posted by DrByte View Post
    Not reliably before v155.

    Why exactly are you wanting to rewind to start?
    Really? I've been using the following construct for a couple of years now to "rewind" a previously-processed query back to the beginning:
    Code:
    $result = $db->Execute (<some sql query>);
    while (!$result->EOF) {
        ...
        $result->MoveNext ();
    }
    ...
    // -----
    // "Rewind" the query to re-process ...
    //
    $result->Move (0);
    $result->MoveNext ();
    while (!$result->EOF) {
        ...
        $result->MoveNext ();
    }

  6. #6
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Fetch next row from database query

    As suggested here, "reliability" (backwards compatibility to before ZC 1.5.5) can be obtained by testing for the method rewind as suggested by DrByte:
    Code:
    $result->Move(0);
    if (!method_exists($result, 'rewind')) {
      $result->MoveNext();
    }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v154 How to Get Count from Last Delete Query - Row Affected?
    By kwright in forum General Questions
    Replies: 3
    Last Post: 21 Feb 2016, 06:16 PM
  2. Fetch user email address from database
    By hoehnt in forum General Questions
    Replies: 6
    Last Post: 21 Dec 2009, 08:45 PM
  3. Fetch blocks of text from other URLs?
    By sjk1000 in forum General Questions
    Replies: 8
    Last Post: 3 Oct 2008, 04:05 AM
  4. ZenCart database setup error -12263 and Could not fetch schema tables
    By Xulayman in forum Installing on a Windows Server
    Replies: 4
    Last Post: 21 Aug 2007, 07:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg