Guest User

Untitled

a guest
Dec 10th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. SELECT
  2. ProductName, ProductImages, ProductDescription,
  3. ProductPrice, ProductAddDate, cSchema_Name, cValueValue
  4. FROM
  5. Product p INNER JOIN CharacteristicsValue cv
  6. ON p.ID_product = cv.cValueProduct_FK
  7. INNER JOIN CharacteristicsSchema cs
  8. ON cv.cValueSchema_FK = cs.ID_cSchema
  9. WHERE
  10. ProductUrl = ?
  11. AND cv.cValueSchema_FK = cs.ID_cSchema
  12. AND cs.cSchema_Category_FK = p.ProductCategory_FK");
  13.  
  14. "SELECT ProductName, ProductImages, ProductDescription,
  15. ProductPrice, ProductAddDate, ID_product, ProductCategory_FK
  16. FROM Product
  17. WHERE ProductUrl = ?"
  18.  
  19. "SELECT cSchema_Name, cValueValue
  20. FROM CharacteristicsValue cv
  21. JOIN CharacteristicsSchema cs ON cv.ID_cValue = cs.ID_cSchema
  22. WHERE cv.cValueProduct_FK = ? AND cs.cSchema_Category_FK = ?"
  23.  
  24. $stmt = $tmp_conn->prepare("SELECT ProductName, ProductImages, ProductDescription,
  25. ProductPrice, ProductAddDate, ID_product, ProductCategory_FK
  26. FROM Product
  27. WHERE ProductUrl = ?");
  28. $stmt->bind_param('s', $url);
  29. $stmt->execute();
  30. $result = $stmt->get_result();
  31. while ($row = $result->fetch_assoc()) {
  32. array_push($data, $row);
  33. }
  34. $result->free_result();
  35.  
  36. $id_prod = $data[0]['ID_product'];
  37. $id_category = $data[0]['ProductCategory_FK'];
  38.  
  39. $stmt = $tmp_conn->prepare("SELECT cSchema_Name, cValueValue
  40. FROM CharacteristicsValue cv
  41. INNER JOIN CharacteristicsSchema cs ON cv.ID_cValue = cs.ID_cSchema
  42. WHERE cv.cValueProduct_FK = ? AND cs.cSchema_Category_FK = ?");
  43. $stmt->bind_param('ii', $id_prod, $id_category);
  44. $stmt->execute();
  45. $result = $stmt->get_result();
  46. while ($row = $result->fetch_assoc()) {
  47. array_push($data, $row);
  48. }
  49. $result->free_result();
  50.  
  51. SELECT
  52. ID_product, ProductName, ProductImages, ProductDescription,
  53. ProductPrice, ProductAddDate, cSchema_Name, cValueValue
  54. FROM
  55. Product p INNER JOIN CharacteristicsValue cv
  56. ON p.ID_product = cv.cValueProduct_FK
  57. INNER JOIN CharacteristicsSchema cs
  58. ON cv.cValueSchema_FK = cs.ID_cSchema
  59. WHERE
  60. ProductUrl = ?
  61. AND cv.cValueSchema_FK = cs.ID_cSchema
  62. AND cs.cSchema_Category_FK = p.ProductCategory_FK")
  63. GROUP BY `ID_product`;
Add Comment
Please, Sign In to add comment