switch to room list switch to menu My folders
Go to page: First ... 57 58 59 60 [61] 62 63 64 65 ... Last
[#] Wed May 26 2010 15:33:47 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

no. I took the wrong conclusion.

it was the java crap xml parser that didn't like linebreaks in the soap xml part.

[#] Wed Jun 09 2010 07:51:54 EDT from the8088er @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I seek the gentle guidance of someone with SQL fu.

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)

100 coffee.jpg
100 coffee_.jpg
100 coffee_t.jpg

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 :)

[#] Wed Jun 09 2010 08:43:31 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

looks like an sql injection invitation to me.

[#] Wed Jun 09 2010 09:04:03 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]  rather do taxes than test their software ;-)

[#] Wed Jun 09 2010 14:58:53 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Jun 9 2010 8:43am from dothebart @uncnsrd
looks like an sql injection invitation to me.

That was my first thought too.

[#] Wed Jun 09 2010 14:59:59 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

but as for your actual question, I don't understand it.

[#] Wed Jun 09 2010 19:34:23 EDT from the8088er @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

An SQL injection invintation it may be but it's a one or two or three time use script for our internal use only.

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 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:

Any advice on how to finish is greatly appreciated.

[#] Wed Jun 09 2010 21:56:00 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I think I get at least some of it.
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.

[#] Thu Jun 10 2010 02:35:42 EDT from tbrownaw @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Something like

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.

[#] Thu Jun 10 2010 08:22:19 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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?

[#] Thu Jun 10 2010 09:11:28 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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...

[#] Thu Jun 10 2010 09:32:35 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

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...

theres jython...

otos we have IronRuby, IronPython, C(++)/managed

[#] Thu Jun 10 2010 15:14:52 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I had a nice long winded message after that quote too. Looks like quoting web messages with non ascii characters in them are getting truncated.
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.

[#] Thu Jun 10 2010 15:27:45 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


[#] Sat Jun 12 2010 04:40:47 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

just found a new ff plugin via reviewboard:

shows json structures nicely unwrapped and indented.

[#] Sun Jun 13 2010 21:05:43 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I guess it was only a matter of time:

[#] Sun Jun 13 2010 22:03:54 EDT from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

just what java needs, a precompiler.

[#] Sun Jun 13 2010 22:09:15 EDT from Animal @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Go to page: First ... 57 58 59 60 [61] 62 63 64 65 ... Last