最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

关于 Zencart $db->Execute 的一些笔记

Zencart 整理 ajiang-tuzi 5433浏览

我一直不知道如何通过zencat 循环输出我想要的数据 于是我去查了下
发现这玩意竟然如此的简单
就像这个样子

								  
    $orders_products- = $db->Execute($orders_products_query);

    while (!$orders_products->EOF) {
     echo $orders_products->fields['products_id']."<br />";
      $orders_products->MoveNext();
    }

一下是完整代码实例

/**
 * Created by PhpStorm.
 * User:ajiang-tuzhi
 * QQ:1050653098@qq.com
 * WebSite:www.weicot.com
 * Date: 2015/11/17
 * Time: 11:54
 * Zencart 简单的 查询以及数据输出
 * Zencart 库存管理测试
 * 这只是个演示 不建议用它来加减产品数量 因为哦zencart的后台产品库存的管理已经足够强大了
 * 很多功能后台都有设置 比如促销规则 产品库存等
 */
$orders_products_query_data ="select orders_products_id, products_id, products_name,
                                 products_model, products_price, products_tax,
                                 products_quantity, final_price,
                                 onetime_charges,
                                 products_priced_by_attribute, product_is_free, products_discount_type,
                                 products_discount_type_from
                                  from " . TABLE_ORDERS_PRODUCTS . "
                                  where orders_id = '" . (int)$orderNo . "'
                                  order by orders_products_id";
								  
    $orders_products_data = $db->Execute($orders_products_query_data);

    while (!$orders_products_data->EOF) {
     $PID=$orders_products_data->fields['products_id'];//获得产品id
	 $Qit=$orders_products_data->fields['products_quantity'];//获得购买件数
	 $Pqit=$db->Execute('select products_quantity from products where products_id ='.$PID);

	 $Mqit=$Pqit->fields['products_quantity'];
	 
	  if($Mqit>=$Qit){
		  $QITS=$Mqit-$Qit;
		$RT=$db->Execute("update products set products_quantity=".$QITS." where products_id=".$PID);
	 }
      $orders_products_data->MoveNext();//指针下移 

参考

 public function checkLogSchema()
  {
    // adds 'logmessage' field of type mediumtext
    global $db;
    $sql = "show fields from " . TABLE_ADMIN_ACTIVITY_LOG;
    $result = $db->Execute($sql);
    $found_logmessage = false;
    while (!$result->EOF) {
      if  ($result->fields['Field'] == 'logmessage') {
        $found_logmessage = true;
      }
      $result->MoveNext();
    }
    if (!$found_logmessage)
    {
      $sql = "ALTER TABLE " . TABLE_ADMIN_ACTIVITY_LOG . " ADD COLUMN logmessage mediumtext NOT NULL default ''";
      $db->Execute($sql);
    }
    // add 'severity' field of type varchar(9)
    $sql = "show fields from " . TABLE_ADMIN_ACTIVITY_LOG;
    $result = $db->Execute($sql);
    while (!$result->EOF) {
      if  ($result->fields['Field'] == 'severity') {
        return true; // exists, so return with no error
      }
      $result->MoveNext();
    }

转载请注明:(●--●) Hello.My Weicot » 关于 Zencart $db->Execute 的一些笔记

蜀ICP备15020253号-1