Ejemplo n.º 1
0
 /**
  * @param int $id
  * @return array
  */
 public static function getOrder($id)
 {
     $sql = "SELECT\n              order_id,\n              order_amount,\n              order_date,\n              order_user_id,\n              user_name,\n              op_quantity,\n              product_id,\n              product_name\n            FROM\n              orders\n              LEFT JOIN\n              users ON order_user_id = user_id\n              LEFT JOIN\n              ordered_products ON op_order_id = order_id\n              LEFT JOIN\n              products ON op_product_id = product_id\n               WHERE order_id = " . $id;
     return DbFunctions::sql($sql);
 }
Ejemplo n.º 2
0
 /**
  * @return mixed
  */
 public function save()
 {
     $productSQL = "'" . $this->name . "'";
     DbFunctions::insert("INSERT INTO products (product_name)  VALUES (" . $productSQL . ")");
     $this->id = DbFunctions::sql("SELECT product_id FROM products\n                                  WHERE product_name = '" . $this->name . "'\n                                  ORDER BY product_id DESC", 1)['product_id'];
     $descriptionSQL = $this->id . ", '" . $this->description . "', " . $this->price . ", " . $this->quantity . ", NULL";
     DbFunctions::insert("INSERT INTO products_description VALUES (" . $descriptionSQL . ")");
 }