This topic is locked

BLOB Bug?

2/24/2009 10:46:32 AM
PHPRunner General questions
D
Denton author

Hi.

I wrote a query joining a few tables. In the second table I pulled five (different) text fields without a problem (ie. 2ndtable.field1). I then changed my query to pull a blob field (2ndtable.blobfield). I tried this query in SQLYog and it worked fine, pulling the five different images, but in phprunner I get five identical image. Is this a bug?

Denton

Alexey admin 2/27/2009

Hi,
I wasn't able to reproduce this bug.

Please publish your project on the Demo Account (the last tab in PHPRunner) and send a URL to it to support@xlinesoft.com

Sergey Kornilov admin 2/27/2009

I guess I know what's happening here. If you join two tables that related as Master-Details, i.e. one order and five details, primary key value will be the same for all five records. That's why imager always pull the first image.
To resolve this use second (joined) table as a main one and choose primary key from that table.

D
Denton author 3/3/2009

I guess I know what's happening here. If you join two tables that related as Master-Details, i.e. one order and five details, primary key value will be the same for all five records. That's why imager always pull the first image.

To resolve this use second (joined) table as a main one and choose primary key from that table.


I'm afraid I don't understand you, Admin. As I said, the same quesry works in SQLYog. I'm opening a ticket and uploading the project now.
Denton

Sergey Kornilov admin 3/3/2009

Denton,
Demo Account won't help here. This is a database design issue.
It works okay if you simply select data from the table. PHPRunner works the same way as SQLYog here. However to display image on the web page as a real image (as opposed to displaying binary data as text) you need yo use an additional PHP file (imager.php) that needs to know which record to pull. Since you use JOIN query primary fey value is the same for all five records. That's why you always see first record image.
To fix this you either need to use suggested workaround (using joined table as a main one) or switch to file-based images.

D
Denton author 3/13/2009

Denton,

Demo Account won't help here. This is a database design issue.
It works okay if you simply select data from the table. PHPRunner works the same way as SQLYog here. However to display image on the web page as a real image (as opposed to displaying binary data as text) you need yo use an additional PHP file (imager.php) that needs to know which record to pull. Since you use JOIN query primary fey value is the same for all five records. That's why you always see first record image.
To fix this you either need to use suggested workaround (using joined table as a main one) or switch to file-based images.


I am still struggling to get my head around this -

Simplified, I have two columns in the joined table (2), one is text, the other is an image.

eg.
text ~~~ image

a ~~~ blob 1

b ~~~ blob 2

c ~~~ blob 3

d ~~~ blob 4
By changing the query slightly, I can pull the text fields OK, but I cannot pull the different images
ie.

select

table2.text

FROM table1

INNER JOIN table2 ON table1.ID = table2.ID
works OK but,
select

table2.blob

FROM table1

INNER JOIN table2 ON table1.ID = table2.ID

does not work
As I already said, both queries work perfect in SQLYog but NOT in PhP Runner. I am not just talking about the web pages, but when I click the "result" tab in PhPR I get "GIF89a(" in the image column for every field, but the correct "a" "b" "c" "d" in the text column. So, something is not working right.
Regarding your workarounds, i didn't understand about using "second (joined) table as a main one"
nor
"use an additional PHP file (imager.php)"
I also tried looking at the "files-based" images (in Visual Editor > view as) but I'm afraid it asked me to select a field that stores filename of database file which might as well have been written in Greek.
Denton

Sergey Kornilov admin 3/13/2009

Denton,
SQL results displays your data 'as is'. You won't see any images there. Images are displayed as binary data. 'GIF89a' is standard GIF file header.
If you don't understand the solution below contact support team directly supplying your order number. I'll be glad to setup this for you.