Skip to content

Commit

Permalink
SC_Query::getSql() の呼び出しを setLimit() を含めたメソッドチェーンとする。
Browse files Browse the repository at this point in the history
  • Loading branch information
seasoftjapan committed Jan 9, 2025
1 parent 1a89e71 commit d5813ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions data/class/SC_Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ public function findProductIdsOrder(&$objQuery, $arrVal = [])
$o_col = $this->arrOrderData['col'];
$o_table = $this->arrOrderData['table'];
$o_order = $this->arrOrderData['order'];
$objQuery->setOrder("T2.$o_col $o_order");
$sub_sql = $objQuery->getSql($o_col, "$o_table AS T2", 'T2.product_id = alldtl.product_id AND T2.del_flg = 0');
$sub_sql = $objQuery->dbFactory->addLimitOffset($sub_sql, 1);
$sub_sql = $objQuery
->setOrder("T2.$o_col $o_order")
->setLimitOffset(1)
->getSql($o_col, "$o_table AS T2", 'T2.product_id = alldtl.product_id AND T2.del_flg = 0')
;

$objQuery->setOrder("($sub_sql) $o_order, product_id");
}
Expand Down
6 changes: 4 additions & 2 deletions data/class/api/operations/ItemSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ protected function getProductsList($searchCondition, $disp_number, $startno, $li
$from = "$dtb_product_categories T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
$where = 'T2.product_id = alldtl.product_id';
$objQuery->setOrder('T3.rank DESC, T2.rank DESC');
$sub_sql = $objQuery->getSql($col, $from, $where);
$sub_sql = $objQuery->dbFactory->addLimitOffset($sub_sql, 1);
$sub_sql = $objQuery
->setLimit(1)
->getSql($col, $from, $where)
;

Check warning on line 159 in data/class/api/operations/ItemSearch.php

View check run for this annotation

Codecov / codecov/patch

data/class/api/operations/ItemSearch.php#L156-L159

Added lines #L156 - L159 were not covered by tests

$objQuery->setOrder("($sub_sql) DESC ,product_id DESC");
break;
Expand Down
8 changes: 5 additions & 3 deletions data/class/pages/admin/LC_Page_Admin_Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ public function lfGetNewOrder()
{
$objQuery = SC_Query_Ex::getSingletonInstance();

$objQuery->setOrder('order_detail_id');
$sql_product_name = $objQuery->getSql('product_name', 'dtb_order_detail', 'order_id = dtb_order.order_id');
$sql_product_name = $objQuery->dbFactory->addLimitOffset($sql_product_name, 1);
$sql_product_name = $objQuery
->setOrder('order_detail_id')
->setLimit(1)
->getSql('product_name', 'dtb_order_detail', 'order_id = dtb_order.order_id')
;

$cols = <<< __EOS__
dtb_order.order_id,
Expand Down

0 comments on commit d5813ed

Please sign in to comment.