Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2007
    Location
    Hoboken, NJ
    Posts
    96
    Plugin Contributions
    1

    Default db->Execute with while statement...

    I am attempting to convert an oscommerce module and got stuck on this function....

    Code:
       $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name");
          $attributes=array();
          while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
            $products_options_array = array();
            $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
            while ($products_options = tep_db_fetch_array($products_options_query)) {
    This is what I replaced it with after reading the Wiki...

    Code:
     $products_options_name = $db-Execute("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name");
          $attributes=array();
          while (!$products_options_name->EOF) {
            $products_options_array = array();
            $products_options = $db->Execute("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
            while (!$products_options->EOF) {


    The first sql statement builds the array and I can see that by doing a
    Code:
    print_r($products_options_name);
    . The second sql statement array will not build unless I hard code the value
    Code:
    (int)$products_options_name['products_options_id']
    . From what I can tell the $products_options_name_query array is not getting passed on to $products_options_name. Any guidance would be greatly appreciated.


    Cal

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: db->Execute with while statement...

    As per the wiki article: http://www.zen-cart.com/wiki/index.p...g_query_fields
    ... try:
    Code:
    $products_options_name->fields['products_options_id']
    .

    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.

  3. #3
    Join Date
    Dec 2007
    Location
    Hoboken, NJ
    Posts
    96
    Plugin Contributions
    1

    Default Re: db->Execute with while statement...

    Thanks DrByte. I somehow missed that :-)

 

 

Similar Threads

  1. v151 Help with a php statement
    By suportafaceri in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 6 Apr 2014, 09:43 AM
  2. v139h Update all exisiting products with Sales Tax with SQL Statement?
    By toussi in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 18 Jun 2012, 06:22 PM
  3. Amount of rows with $db->Execute?
    By joecooper in forum General Questions
    Replies: 3
    Last Post: 15 Feb 2012, 11:46 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR