phpmyadmin problem
Moderator: General Moderators
-
street_spirit
- Forum Newbie
- Posts: 11
- Joined: Tue Apr 28, 2009 11:43 am
Re: phpmyadmin problem
From what I can see that displays multiple images just not sure I get the link of how it works out which images go with which products if you get me? Sorry drawing a real blind spot on all of this stuff.
Re: phpmyadmin problem
The original table structure allowed each product to have only one image. Because the product and its image had a one-to-one relationship, it was acceptable to treat the image as an attribute of the product (as a field in the product table).
You wanted each product to have one or more images. If the number of images is unknown, the image must become a separate entity and have its own table. This is because, in a relational database, the number of rows|records|tuples expands but the number of columns|fields|attributes remains the same.
In the tbl_product table, each product is identified by a unique number (pd_id). This number also appears in the tbl_product_image table so that many images can be related to a single product.
In PHP, where a product image was previously treated as a single string...
...it must now be treated as an array of strings.
To make debugging easier, open library/product-functions.php and replace
with
Edit: This post was recovered from search engine cache.
You wanted each product to have one or more images. If the number of images is unknown, the image must become a separate entity and have its own table. This is because, in a relational database, the number of rows|records|tuples expands but the number of columns|fields|attributes remains the same.
In the tbl_product table, each product is identified by a unique number (pd_id). This number also appears in the tbl_product_image table so that many images can be related to a single product.
In PHP, where a product image was previously treated as a single string...
Code: Select all
Array
(
[pd_name] => Example Product
[pd_description] => This is an example product.
[pd_price] => 0.12
[pd_qty] => 1
[pd_image] => /plaincart/images/product/94cd0cb73dc8bae134bbad9664d841f1.jpg
[cart_url] => cart.php?action=add&p=22
)Code: Select all
Array
(
[pd_name] => Example Product
[pd_description] => This is an example product.
[pd_price] => 0.12
[pd_qty] => 1
[pd_image] => Array
(
[0] => /plaincart/images/product/94cd0cb73dc8bae134bbad9664d841f1.jpg
[1] => /plaincart/images/product/94cd0cb73dc8bae134bbad9664d841f1.jpg
)
[cart_url] => cart.php?action=add&p=22
)Code: Select all
return $row;Code: Select all
file_put_contents('debug-log-getProductDetail.txt', print_r($row, 1));
return $row;