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;
 }
Example #2
0
 public function addToJoinTable($propertiesList, $table)
 {
     if (isset($this->id)) {
         $datatypes = '';
         $params = [];
         $sql = 'INSERT INTO ' . $table . ' (fk_' . $table . '_' . get_class($this) . ', ';
         foreach (array_keys($propertiesList[0]) as $colName) {
             $sql .= $this->toCamelCase($colName) . ", ";
         }
         $sql = substr($sql, 0, -2) . ") VALUES ";
         foreach ($propertiesList as $key => $value) {
             $sql .= "(?, ";
             $datatypes .= 's';
             $params[] = $this->id;
             foreach ($value as $colValue) {
                 $sql .= "?, ";
                 $datatypes .= 's';
                 $params[] = $colValue;
             }
             $sql = substr($sql, 0, -2) . "), ";
         }
         $sql = substr($sql, 0, -2);
         #echo $sql;die;
         Model::buildAndRunPreparedStatement($sql, $datatypes, $params);
     }
 }
Example #3
0
 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);
 }