ooops, looks like you "can't apply generic programming" in C++ ;)
so... multipart mime chunked http replies have to have the mime headers at the start of a chunk.
a little easier to find out with bash & netcat instead of real c-coding...
That doesn't sound right.
no. I took the wrong conclusion.
it was the java crap xml parser that didn't like linebreaks in the soap xml part.
I'm trying to write a script, which I'll pastebin if someone tells me it will help, but yeah... Part of the script gets data from the URL as text I think ( I wrote it but that doesn't mean I understand how it works!) for the purpose of putting it into an sql query
URL can be
http://localhost/script.php?product=42, 53, 84, 100 (just like that with the spaces) and that turns the query into this
SELECT * from catalog_product_entity_media_gallery where entity_id in (42, 53, 84, 100)
That works perfectly for my purposes and it's method is naturl to the person who's going to be actually calling the script.
My problem is that later we drop all the rows that match this query and we need to recreate them. Specifically we need to create three rows for each entity_id and assign a different value to each, the value coming off of another URL arguement. The value will have arbitrary info added to it that should look like this (Say ?product=100&img=coffee)
I have to do this in another table as well but I just used UPDATE because in that table, there's an attribute_id that's different for each of the three records, and the records are guaranteed to exist in that table. In the catalog_product_entity_media_gallery table the records may or may not exist, so my logic was to delete existing records then make new ones.
Hopefully this makes some sense to someone out there :)
looks like an sql injection invitation to me.
http://agile.dzone.com/articles/survey-finds-developers-would rather do taxes than test their software ;-)
Jun 9 2010 8:43am from dothebart @uncnsrd
looks like an sql injection invitation to me.
That was my first thought too.
Here's what's going on:
The shopping cart software I installed for a client is using an SQL database for the product directory like most of them. One table has info about the products and rows for what image that product is using. That's fine, and I have that covered.
The other table is for the admin-side with what pictures are available as options for the product if you edit it. You can manually define the images and that will work fine but if you don't put the images in the second table if you edit the product the images will disappear because on the edit page "no image" will be selected and the only choice.
Each image is used for many products and the store needs 3 images per product. The way I did it was
image.jpg - Large file
image_.jpg - Small version of file
image_t.jpg - Thumbnail image
In the script if you call script.php?product=42, 58&img=coffee
...it will do UPDATE catalog_product_entity_varchar SET value\"/images".$img.".jpg\" WHERE entity_id in (".$product.") and attribute_id=493
$img is the img argument from URL and $product is the product argument from the URL. This query is actually run 3 times with different attribute_id. 493 is the large image attribute_id. 109 is the small, and 106 is the thumbnail.
This part of the script works because those rows are always going to be there even if the product hasn't ever had an image associated with it. It will just be no_selection in the value field.
The next table is the catalog_product_entity_media_gallery table where the images have to be listed as options. Here we need to first find all the entity_id matches and remove them because there may have been some other placeholder images, etc. to clean up.
Then I need to create rows that look like
(index) 70 42 /images/coffee.jpg
(index) 70 42 /images/coffee_.jpg
...etc. for each combination of product in the URL and each different variation of the filename given in the URL. The 42 there is an example entity_id/product number and the 70 is just an arbitrary ID that all records have. This is whhere I can't figure out how to do the script.
I guess I could take the string and turn it into an array somehow and make a for or while loop that does the rest but I am quite a bit unsure of how to go about that.
Here is ze code that I have so far: http://pastebin.com/WrWrVcrK
Any advice on how to finish is greatly appreciated.
So first you have to remove the existing matching entity ids from the second table...
delete from catalog_product_entity_media_gallery where entity_id in (select entity_id from catalog_product_entity_varchar)
Hopefully your database is smart enough to do subselects, I think even mysql does that nowadays.
Now you're saying when you get a web request you want to insert 3 rows? or is it more than that
Oh I see you already have the delete part, I think.
Okay from the script description you want to make rows in the media_gallery table for each product where entity id = product id?
I'm still confused I'd need to see the schema.
But anyway, there are two ways to insert rows into a table:
1) a bunch of insert statments in a loop, which is your better bet in this case
2) an insert into / select into, which allows you to batch insert a bunch of rows, but you already have to have some of the information your inserting in the database somewhere. You may be able to contrive that information with a subselect or two, but this is more complex than you need to be doing in this case, so I'd just like you said, make an array and loop inserts.
insert into catalog_product_entity_media_gallery (column, names, here) select foo, bar, baz, 70, entity_id, value from catalog_product_entity_varchar where entity_id in (...)
would probably be about right, depending on what "(index)" is and where it comes from.
another language backened by the java interpreter?
So, the Clojure language compiles down to Java bytecode?
I've always wondered why the .NET camp kept saying that one advantage of .NET over Java was that they had multiple languages that all compiled down to the same bytecode, and Java doesn't. Does this prove otherwise? What is it about CLR that supposedly makes it more "common" than JVM?
prove otherwise? What is it about CLR that supposedly makes it more
"common" than JVM?
Microsoft's marketing department.
There's no reason other languages can't compile down to java bytecode, just nobody's bothered (or maybe not) The better question is:why learn 3 languages when you only need to learn one, especially if the other two don't buy you anything since they compile down to the same bytecode anyway...
I think its the see-carpet crowd who started doing lexer for other languages; thoug we have several examples of this...
there was the contest between the perl and the python guys which one would first be able to execute source from the other language on its interpreter...
otos we have IronRuby, IronPython, C(++)/managed
Anyway ... what is it about CLR that makes it more common than JVM:
I had responded: "Microsoft's marketing department."
Then I went on to say something along the lines of: "What's the point of learning 3 languages that all compile to the same bytecode since there can't be much advantage to any of the languages over the others if they compile down to the same bytecode.
I think I also said something like: "Why learn three languages when you can learn one."
It also now occurs tome that it would be a neat way to transfer source between lanaguages.
I've seen java decompilers work so well, there's almost no difference between my source code and the decompile.
So Imagine you wrote decompilers for CLR for different languages. You could write in VB, compile it, then decompile it into fortran.
How cool would that be.
just found a new ff plugin via reviewboard:
shows json structures nicely unwrapped and indented.