How to add an image to a table...

This is the place to post technical queries about SQL Yoga

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

How to add an image to a table...

Post by trevordevore » Fri Oct 11, 2013 1:36 pm

[This post is an archive from the old SQL Yoga forums]

I have a database table that includes a column of type "blob". This column will hold a small (90 x 90) image. Is this the way to go when needing to save an image? Or, should I just save a path to the image? If I can save the image to the database table, can you tell me how that might be done?

Thanks for your help, John
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: How to add an image to a table...

Post by trevordevore » Fri Oct 11, 2013 1:37 pm

[This post is an archive from old previous SQL Yoga forums]

Saving the image to the database is pretty straight forward as SQL Yoga will use the proper RevDB commands under the hood. If you create a record using a SQL Query object (as in this example) you would just put the binary data of the image into the array you use to create the record in the db.

Code: Select all

put URL("binfile:/Path/to/image.png") into theRowA["image_data"]
sqlquery_create "lessons", theRowA
Now, as to whether or not you should store the image in the database really depends. Personally I don't normally store images in a database but have them on disk. I find it is easier to update the image that way. Your needs may be different though.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “SQL Yoga”