products.php

来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 566 行 · 第 1/2 页

PHP
566
字号
        if ( $Qcheck->valueInt('total') < 1 ) {          $Qcat = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');          $Qcat->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);          $Qcat->bindInt(':products_id', $id);          $Qcat->bindInt(':categories_id', end($category_array));          $Qcat->setLogging($_SESSION['module'], $id);          $Qcat->execute();          if ( $Qcat->affectedRows() ) {            return true;          }        }      } elseif ( $type == 'duplicate' ) {        $Qproduct = $osC_Database->query('select products_quantity, products_price, products_date_available, products_weight, products_weight_class, products_tax_class_id, manufacturers_id from :table_products where products_id = :products_id');        $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);        $Qproduct->bindInt(':products_id', $id);        $Qproduct->execute();        if ( $Qproduct->numberOfRows() === 1 ) {          $error = false;          $osC_Database->startTransaction();          $Qnew = $osC_Database->query('insert into :table_products (products_quantity, products_price, products_date_added, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id) values (:products_quantity, :products_price, now(), :products_date_available, :products_weight, :products_weight_class, 0, :products_tax_class_id, :manufacturers_id)');          $Qnew->bindTable(':table_products', TABLE_PRODUCTS);          $Qnew->bindInt(':products_quantity', $Qproduct->valueInt('products_quantity'));          $Qnew->bindValue(':products_price', $Qproduct->value('products_price'));          if ( !osc_empty($Qproduct->value('products_date_available')) ) {            $Qnew->bindValue(':products_date_available', $Qproduct->value('products_date_available'));          } else {            $Qnew->bindRaw(':products_date_available', 'null');          }          $Qnew->bindValue(':products_weight', $Qproduct->value('products_weight'));          $Qnew->bindInt(':products_weight_class', $Qproduct->valueInt('products_weight_class'));          $Qnew->bindInt(':products_tax_class_id', $Qproduct->valueInt('products_tax_class_id'));          $Qnew->bindInt(':manufacturers_id', $Qproduct->valueInt('manufacturers_id'));          $Qnew->setLogging($_SESSION['module']);          $Qnew->execute();          if ( $Qnew->affectedRows() ) {            $new_product_id = $osC_Database->nextID();            $Qdesc = $osC_Database->query('select language_id, products_name, products_description, products_model, products_tags, products_url from :table_products_description where products_id = :products_id');            $Qdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);            $Qdesc->bindInt(':products_id', $id);            $Qdesc->execute();            while ($Qdesc->next()) {              $Qnewdesc = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_model, products_tags, products_url, products_viewed) values (:products_id, :language_id, :products_name, :products_description, :products_model, :products_tags, :products_url, 0)');              $Qnewdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);              $Qnewdesc->bindInt(':products_id', $new_product_id);              $Qnewdesc->bindInt(':language_id', $Qdesc->valueInt('language_id'));              $Qnewdesc->bindValue(':products_name', $Qdesc->value('products_name'));              $Qnewdesc->bindValue(':products_model', $Qdesc->value('products_model'));              $Qnewdesc->bindValue(':products_tags', $Qdesc->value('products_tags'));              $Qnewdesc->bindValue(':products_description', $Qdesc->value('products_description'));              $Qnewdesc->bindValue(':products_url', $Qdesc->value('products_url'));              $Qnewdesc->setLogging($_SESSION['module'], $new_product_id);              $Qnewdesc->execute();              if ($osC_Database->isError()) {                $error = true;                break;              }            }            if ( $error === false ) {              $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');              $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);              $Qp2c->bindInt(':products_id', $new_product_id);              $Qp2c->bindInt(':categories_id', end($category_array));              $Qp2c->setLogging($_SESSION['module'], $new_product_id);              $Qp2c->execute();              if ( $osC_Database->isError() ) {                $error = true;              }            }          } else {            $error = true;          }          if ( $error === false ) {            $osC_Database->commitTransaction();            osC_Cache::clear('categories');            osC_Cache::clear('category_tree');            osC_Cache::clear('also_purchased');            return true;          } else {            $osC_Database->rollbackTransaction();          }        }      }      return false;    }    function delete($id, $categories = null) {      global $osC_Database, $osC_Image;      $delete_product = true;      $error = false;      $osC_Database->startTransaction();      if ( is_array($categories) && !empty($categories) ) {        $Qpc = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id and categories_id in :categories_id');        $Qpc->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);        $Qpc->bindInt(':products_id', $id);        $Qpc->bindRaw(':categories_id', '("' . implode('", "', $categories) . '")');        $Qpc->setLogging($_SESSION['module'], $id);        $Qpc->execute();        if ( !$osC_Database->isError() ) {          $Qcheck = $osC_Database->query('select products_id from :table_products_to_categories where products_id = :products_id limit 1');          $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);          $Qcheck->bindInt(':products_id', $id);          $Qcheck->execute();          if ( $Qcheck->numberOfRows() > 0 ) {            $delete_product = false;          }        } else {          $error = true;        }      }      if ( ($error === false) && ($delete_product === true) ) {        $Qr = $osC_Database->query('delete from :table_reviews where products_id = :products_id');        $Qr->bindTable(':table_reviews', TABLE_REVIEWS);        $Qr->bindInt(':products_id', $id);        $Qr->setLogging($_SESSION['module'], $id);        $Qr->execute();        if ( $osC_Database->isError() ) {          $error = true;        }        if ( $error === false ) {          $Qcb = $osC_Database->query('delete from :table_customers_basket where products_id = :products_id or products_id like :products_id');          $Qcb->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);          $Qcb->bindInt(':products_id', $id);          $Qcb->bindValue(':products_id', (int)$id . '#%');          $Qcb->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qp2c = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');          $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);          $Qp2c->bindInt(':products_id', $id);          $Qp2c->setLogging($_SESSION['module'], $id);          $Qp2c->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qs = $osC_Database->query('delete from :table_specials where products_id = :products_id');          $Qs->bindTable(':table_specials', TABLE_SPECIALS);          $Qs->bindInt(':products_id', $id);          $Qs->setLogging($_SESSION['module'], $id);          $Qs->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qpa = $osC_Database->query('delete from :table_products_attributes where products_id = :products_id');          $Qpa->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);          $Qpa->bindInt(':products_id', $id);          $Qpa->setLogging($_SESSION['module'], $id);          $Qpa->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qpd = $osC_Database->query('delete from :table_products_description where products_id = :products_id');          $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);          $Qpd->bindInt(':products_id', $id);          $Qpd->setLogging($_SESSION['module'], $id);          $Qpd->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qp = $osC_Database->query('delete from :table_products where products_id = :products_id');          $Qp->bindTable(':table_products', TABLE_PRODUCTS);          $Qp->bindInt(':products_id', $id);          $Qp->setLogging($_SESSION['module'], $id);          $Qp->execute();          if ( $osC_Database->isError() ) {            $error = true;          }        }        if ( $error === false ) {          $Qim = $osC_Database->query('select id from :table_products_images where products_id = :products_id');          $Qim->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);          $Qim->bindInt(':products_id', $id);          $Qim->execute();          while ($Qim->next()) {            $osC_Image->delete($Qim->valueInt('id'));          }        }      }      if ( $error === false ) {        $osC_Database->commitTransaction();        osC_Cache::clear('categories');        osC_Cache::clear('category_tree');        osC_Cache::clear('also_purchased');        return true;      }      $osC_Database->rollbackTransaction();      return false;    }    function setDateAvailable($id, $data) {      global $osC_Database;      $Qproduct = $osC_Database->query('update :table_products set products_date_available = :products_date_available, products_last_modified = now() where products_id = :products_id');      $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);      if ( date('Y-m-d') < $data['date_available'] ) {        $Qproduct->bindValue(':products_date_available', $data['date_available']);      } else {        $Qproduct->bindRaw(':products_date_available', 'null');      }      $Qproduct->bindInt(':products_id', $id);      $Qproduct->setLogging($_SESSION['module'], $id);      $Qproduct->execute();      if ( !$osC_Database->isError() ) {        return true;      }      return false;    }    function getKeywordCount($keyword, $id = null) {      global $osC_Database;      $Qkeywords = $osC_Database->query('select count(*) as total from :table_products_description where products_keyword = :products_keyword');      if ( is_numeric($id) ) {        $Qkeywords->appendQuery('and products_id != :products_id');        $Qkeywords->bindInt(':products_id', $id);      }      $Qkeywords->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);      $Qkeywords->bindValue(':products_keyword', $keyword);      $Qkeywords->execute();      return $Qkeywords->valueInt('total');    }  }?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?