public function findById($wishListId) { $where = []; $where['sql'] = 'WHERE fk_wish_list_product_version_wish_list = ?'; $where['datatypes'] = 'i'; $where['values'] = [$wishListId]; $join = []; $join['product_version'] = ['fk_product_version_base_product', 'base_product_id']; $join['wish_list_product_version'] = ['fk_wish_list_product_version_product_version', 'product_version_id']; $join['wish_list'] = ['fk_wish_list_product_version_wish_list', 'wish_list_id']; require_once '../app/models/Product.php'; $wishList = Product::findProducts($where, $join); if (count($wishList) == 0) { $sql = 'SELECT * FROM wish_list WHERE wish_list_id = ?'; $datatypes = 'i'; $params = [$wishListId]; $wishListInfo = Model::buildAndRunPreparedStatement($sql, $datatypes, $params); $wishListInfo = Model::createResultsArray($wishListInfo); $wishList['listInfo'] = $wishListInfo[0]; } return $wishList; }
public function findProductVersions($baseProductId) { $sql = "SELECT product_version_id, platform, product_price FROM product_version " . "JOIN base_product on fk_product_version_base_product = base_product_id " . "WHERE base_product_id = ?"; $datatypes = 'i'; $params = [$baseProductId]; $results = Model::buildAndRunPreparedStatement($sql, $datatypes, $params); return Model::createResultsArray($results); }