Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- iterating through tables with blob parts
October 13, 2004, 9:08 pm
rate this thread
that will iterate through my databases, iterate through all the tables,
and show everything on one page in forms that allow me to change the
data when I hit the submit button. Blogs are displayed as links to
image.php?id=$id along with browse buttons so new images can be
uploaded. The idea is to make an idiot proof way for artists to change
their web databases without having to use phpadmin.
Its not that hard when all the tables have ids that are the same. I
simply find the highest id from the first table, then iterate through
the ids and call each table for every id.
$sql="select * from $table where id=$id";
Some of these art graphics are quite large, so I wanted to break them up
for easier downloading. The trouble started when I broke the blobs up
into 64k parts and gave each blob a master id.
id=1 id=1 masterid=1
id=2 id=4 masterid=2
This is how it was done at
However, it seems kind of crazy to me because the image ids have nothing
to do with the imagemeta ids; I can't just iterate through the ids and
assume that all the data in each id corresponds to data in other tables
with the same id.
So I tried it like this:
id=1 id=1 part=1
id=2 id=2 part=4
This seems crazy too, because you end up with multiple ids with the same
number in the image table.
Either way, it gets pretty complicated. Is there any preferred,
definitive way this should be done ?
Right now I'm working on doing it the first way (above). But here's the
complicate way I have to do it: first,I iterate through the masterids in
the first image table, learn which ids it holds and then iterate through
the other tables while checking to see if each table has a master id. If
it does, I use the master id to call up the image. if it doesn't I use
the ids I found in the first table to call up the metadata.
I can't help thinking there must be a better way. If nothing else, this
has taught me to think in mysqlese.
Re: iterating through tables with blob parts
writing all that inspired me to get my brain working. I think I figured
it out. I don't have to call the first table and check it. Instead, I
iterate through masterids and check each table for a masterid field. If
it doesn't have one, I use the current masterid as the id for that
table. If it does have a masterid, its an image and I use that master id
to access the blob.