Changeset 17263 for branches/comu-ver2/data/class/helper/SC_Helper_DB.php
- Timestamp:
- 2008/04/16 20:13:17 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/helper/SC_Helper_DB.php
r17071 r17263 1537 1537 } 1538 1538 1539 /** 1540 * メーカー商品数数の登録を行う. 1541 * 1542 * @param SC_Query $objQuery SC_Query インスタンス 1543 * @return void 1544 */ 1545 function sfMaker_Count($objQuery){ 1546 $sql = ""; 1547 1548 //テーブル内容の削除 1549 $objQuery->query("DELETE FROM dtb_maker_count"); 1550 1551 //各メーカーの商品数を数えて格納 1552 $sql = " INSERT INTO dtb_maker_count(maker_id, product_count, create_date) "; 1553 $sql .= " SELECT T1.maker_id, count(T2.maker_id), now() "; 1554 $sql .= " FROM dtb_maker AS T1 LEFT JOIN dtb_products AS T2"; 1555 $sql .= " ON T1.maker_id = T2.maker_id "; 1556 $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; 1557 $sql .= " GROUP BY T1.maker_id, T2.maker_id "; 1558 $objQuery->query($sql); 1559 } 1560 1561 /** 1562 * 選択中の商品のメーカーを取得する. 1563 * 1564 * @param integer $product_id プロダクトID 1565 * @param integer $maker_id メーカーID 1566 * @return array 選択中の商品のメーカーIDの配列 1567 * 1568 */ 1569 function sfGetMakerId($product_id, $maker_id = 0, $closed = false) { 1570 if ($closed) { 1571 $status = ""; 1572 } else { 1573 $status = "status = 1"; 1574 } 1575 1576 if(!$this->g_maker_on) { 1577 $this->g_maker_on = true; 1578 $maker_id = (int) $maker_id; 1579 $product_id = (int) $product_id; 1580 if(SC_Utils_Ex::sfIsInt($maker_id) && $this->sfIsRecord("dtb_maker","maker_id", $maker_id)) { 1581 $this->g_maker_id = array($maker_id); 1582 } else if (SC_Utils_Ex::sfIsInt($product_id) && $this->sfIsRecord("dtb_products","product_id", $product_id, $status)) { 1583 $objQuery = new SC_Query(); 1584 $where = "product_id = ?"; 1585 $maker_id = $objQuery->getCol("dtb_productes", "maker_id", "product_id = ?", array($product_id)); 1586 $this->g_maker_id = $maker_id; 1587 } else { 1588 // 不正な場合は、空の配列を返す。 1589 $this->g_maker_id = array(); 1590 } 1591 } 1592 return $this->g_maker_id; 1593 } 1594 1595 /** 1596 * メーカーの取得を行う. 1597 * 1598 * $products_check:true商品登録済みのものだけ取得する 1599 * 1600 * @param string $addwhere 追加する WHERE 句 1601 * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true 1602 * @return array カテゴリツリーの配列 1603 */ 1604 function sfGetMakerList($addwhere = "", $products_check = false) { 1605 $objQuery = new SC_Query(); 1606 $where = "del_flg = 0"; 1607 1608 if($addwhere != "") { 1609 $where.= " AND $addwhere"; 1610 } 1611 1612 $objQuery->setoption("ORDER BY rank DESC"); 1613 1614 if($products_check) { 1615 $col = "T1.maker_id, name"; 1616 $from = "dtb_maker AS T1 LEFT JOIN dtb_maker_count AS T2 ON T1.maker_id = T2.maker_id"; 1617 $where .= " AND product_count > 0"; 1618 } else { 1619 $col = "maker_id, name"; 1620 $from = "dtb_maker"; 1621 } 1622 1623 $arrRet = $objQuery->select($col, $from, $where); 1624 1625 $max = count($arrRet); 1626 for($cnt = 0; $cnt < $max; $cnt++) { 1627 $id = $arrRet[$cnt]['maker_id']; 1628 $name = $arrRet[$cnt]['name']; 1629 $arrList[$id].= $name; 1630 } 1631 return $arrList; 1632 } 1633 1634 1635 1539 1636 } 1540 1637 ?>
Note: See TracChangeset
for help on using the changeset viewer.