- Timestamp:
- 2008/08/21 00:02:54 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php
r17537 r17549 169 169 170 170 /** 171 * SQL の中の View の存在をチェックする.172 *173 * @access private174 * @param string $sql SQL 文175 * @return bool Viewが存在しない場合 false176 */177 function sfInArray($sql){178 $arrView = $this->viewToSubQuery();179 180 foreach($arrView as $key => $val){181 if (strcasecmp($sql, $val) == 0){182 $changesql = eregi_replace("($key)", "$val", $sql);183 $this->sfInArray($changesql);184 }185 }186 return false;187 }188 189 /**190 171 * View をインラインビューに変換する. 191 172 * … … 195 176 */ 196 177 function sfChangeView($sql){ 197 178 198 179 $arrViewTmp = $this->viewToSubQuery(); 199 200 // viewのwhereを変換180 181 // viewのwhereを変換 201 182 foreach($arrViewTmp as $key => $val){ 202 183 $arrViewTmp[$key] = strtr($arrViewTmp[$key], $this->getWhereConverter()); 203 184 } 204 205 // viewを変換185 186 // viewを変換 206 187 $changesql = strtr($sql, $arrViewTmp); 207 188 208 189 return $changesql; 209 190 } … … 258 239 */ 259 240 function viewToSubQuery() { 241 $sql['vw_products_allclass_detail'] =<<< __EOS__ 242 ( 243 SELECT 244 dtb_products.product_id, 245 dtb_products.name, 246 dtb_products.deliv_fee, 247 dtb_products.sale_limit, 248 dtb_products.sale_unlimited, 249 dtb_products.maker_id, 250 dtb_products.rank, 251 dtb_products.status, 252 dtb_products.product_flag, 253 dtb_products.point_rate, 254 dtb_products.comment1, 255 dtb_products.comment2, 256 dtb_products.comment3, 257 dtb_products.comment4, 258 dtb_products.comment5, 259 dtb_products.comment6, 260 dtb_products.note, 261 dtb_products.file1, 262 dtb_products.file2, 263 dtb_products.file3, 264 dtb_products.file4, 265 dtb_products.file5, 266 dtb_products.file6, 267 dtb_products.main_list_comment, 268 dtb_products.main_list_image, 269 dtb_products.main_comment, 270 dtb_products.main_image, 271 dtb_products.main_large_image, 272 dtb_products.sub_title1, 273 dtb_products.sub_comment1, 274 dtb_products.sub_image1, 275 dtb_products.sub_large_image1, 276 dtb_products.sub_title2, 277 dtb_products.sub_comment2, 278 dtb_products.sub_image2, 279 dtb_products.sub_large_image2, 280 dtb_products.sub_title3, 281 dtb_products.sub_comment3, 282 dtb_products.sub_image3, 283 dtb_products.sub_large_image3, 284 dtb_products.sub_title4, 285 dtb_products.sub_comment4, 286 dtb_products.sub_image4, 287 dtb_products.sub_large_image4, 288 dtb_products.sub_title5, 289 dtb_products.sub_comment5, 290 dtb_products.sub_image5, 291 dtb_products.sub_large_image5, 292 dtb_products.sub_title6, 293 dtb_products.sub_comment6, 294 dtb_products.sub_image6, 295 dtb_products.sub_large_image6, 296 dtb_products.del_flg, 297 dtb_products.creator_id, 298 dtb_products.create_date, 299 dtb_products.update_date, 300 dtb_products.deliv_date_id, 301 T4.product_code_min, 302 T4.product_code_max, 303 T4.price01_min, 304 T4.price01_max, 305 T4.price02_min, 306 T4.price02_max, 307 T4.stock_min, 308 T4.stock_max, 309 T4.stock_unlimited_min, 310 T4.stock_unlimited_max, 311 T4.class_count 312 FROM 313 dtb_products 314 LEFT JOIN 315 ( 316 SELECT 317 product_id, 318 MIN(product_code) AS product_code_min, 319 MAX(product_code) AS product_code_max, 320 MIN(price01) AS price01_min, 321 MAX(price01) AS price01_max, 322 MIN(price02) AS price02_min, 323 MAX(price02) AS price02_max, 324 MIN(stock) AS stock_min, 325 MAX(stock) AS stock_max, 326 MIN(stock_unlimited) AS stock_unlimited_min, 327 MAX(stock_unlimited) AS stock_unlimited_max, 328 COUNT(*) as class_count 329 FROM dtb_products_class 330 GROUP BY product_id 331 ) AS T4 332 ON dtb_products.product_id = T4.product_id 333 ) 334 __EOS__; 335 260 336 return array( 261 337 "vw_cross_class" => ' … … 350 426 ON T1.product_id = T2.product_id_sub) ', 351 427 352 "vw_products_allclass" => ' 353 (SELECT T1.product_id, 354 product_code_min, 355 product_code_max, 356 price01_min, 357 price01_max, 358 price02_min, 359 price02_max, 360 stock_min, 361 stock_max, 362 stock_unlimited_min, 363 stock_unlimited_max, 364 del_flg, 365 status, 366 name, 367 comment1, 368 comment2, 369 comment3, 370 main_list_comment, 371 main_image, 372 main_list_image, 373 product_flag, 374 deliv_date_id, 375 sale_limit, 376 point_rate, 377 sale_unlimited, 378 create_date, 379 deliv_fee, 380 update_date, 381 rank 382 ,(SELECT rank AS category_rank 383 FROM dtb_category AS T4 384 WHERE T1.category_id = T4.category_id) as category_rank 385 ,(SELECT category_id AS sub_category_id 386 FROM dtb_category T4 387 WHERE T1.category_id = T4.category_id) as category_id 388 FROM (SELECT T0.product_id, 389 T0.del_flg, 390 T0.status, 391 T0.name, 392 T0.comment1, 393 T0.comment2, 394 T0.comment3, 395 T0.main_list_comment, 396 T0.main_image, 397 T0.main_list_image, 398 T0.product_flag, 399 T0.deliv_date_id, 400 T0.sale_limit, 401 T0.point_rate, 402 T0.sale_unlimited, 403 T0.create_date, 404 T0.deliv_fee, 405 T00.category_id, 406 T0.rank, 407 T0.update_date 408 FROM dtb_products AS T0 409 LEFT JOIN dtb_product_categories AS T00 410 USING (product_id)) AS T1 411 RIGHT JOIN (SELECT product_id as product_id_sub, 412 MIN(product_code) AS product_code_min, 413 MAX(product_code) AS product_code_max, 414 MIN(price01) AS price01_min, 415 MAX(price01) AS price01_max, 416 MIN(price02) AS price02_min, 417 MAX(price02) AS price02_max, 418 MIN(stock) AS stock_min, 419 MAX(stock) AS stock_max, 420 MIN(stock_unlimited) AS stock_unlimited_min, 421 MAX(stock_unlimited) AS stock_unlimited_max 422 FROM dtb_products_class GROUP BY product_id) AS T2 423 ON T1.product_id = T2.product_id_sub 424 ) ', 425 426 "vw_products_allclass_detail" => ' 427 (SELECT product_id,price01_min,price01_max,price02_min,price02_max,stock_min,stock_max,stock_unlimited_min,stock_unlimited_max, 428 del_flg,status,name,comment1,comment2,comment3,deliv_fee,main_comment,main_image,main_large_image, 429 sub_title1,sub_comment1,sub_image1,sub_large_image1, 430 sub_title2,sub_comment2,sub_image2,sub_large_image2, 431 sub_title3,sub_comment3,sub_image3,sub_large_image3, 432 sub_title4,sub_comment4,sub_image4,sub_large_image4, 433 sub_title5,sub_comment5,sub_image5,sub_large_image5, 434 product_flag,deliv_date_id,sale_limit,point_rate,sale_unlimited,file1,file2,category_id 435 FROM ( SELECT * FROM (dtb_products AS T1 RIGHT JOIN 436 (SELECT 437 product_id AS product_id_sub, 438 MIN(price01) AS price01_min, 439 MAX(price01) AS price01_max, 440 MIN(price02) AS price02_min, 441 MAX(price02) AS price02_max, 442 MIN(stock) AS stock_min, 443 MAX(stock) AS stock_max, 444 MIN(stock_unlimited) AS stock_unlimited_min, 445 MAX(stock_unlimited) AS stock_unlimited_max 446 FROM dtb_products_class GROUP BY product_id) AS T2 447 ON T1.product_id = T2.product_id_sub ) ) AS T3 LEFT JOIN (SELECT rank AS category_rank, category_id AS sub_category_id FROM dtb_category) AS T4 448 ON T3.category_id = T4.sub_category_id) ', 428 "vw_products_allclass" => " 429 ( 430 SELECT 431 alldtl.*, 432 dtb_category.rank AS category_rank, 433 T2.category_id 434 FROM 435 {$sql['vw_products_allclass_detail']} AS alldtl 436 LEFT JOIN 437 dtb_product_categories AS T2 438 ON alldtl.product_id = T2.product_id 439 LEFT JOIN 440 dtb_category 441 ON T2.category_id = dtb_category.category_id 442 ) ", 443 444 "vw_products_allclass_detail" => $sql['vw_products_allclass_detail'], 449 445 450 446 "vw_product_class" => '
Note: See TracChangeset
for help on using the changeset viewer.