[Gambas-user] Retrieving picture from Database Mysql

timothy timothy.marshal-nichols at ...247...
Tue Apr 10 10:01:39 CEST 2007


> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> bounces at lists.sourceforge.net] On Behalf Of Steven Lobbezoo
> Sent: Monday, 09 April 2007 08:27 AM
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] Retrieving picture from Database Mysql
> 
> But, You should watch it :
> Gambas does NOT recognise blob fields correctly.
> You need to define a "Large Blob" in Mysql, not a medium ore small or
> varchar
> unlimited. All these other formats are interpreted (I suppose in the
name
> of
> compatibility) as char and not transferred (You will only get the
first
> four
> characters (8 Bytes)) correctly.
> I consider this leveling at a common lowest dominator a very bad
thing,
> since
> it prives you from all kind of features in MySql, but anyway.... I
suppose
> it's the french way (THey do that in politics too). ;-))

I do not think comments like this really help anyone.

> That why I use db.Exec all the time, pity!
> 
> Steven
> 
> 
> 

Attached is a example that I think illustrates the bug in the BLOB type
database field.
  
This example will create the database for you if it does not exist.
(This will also help if you know the structure of the database when
debugging.)

The Select(), Add() and Delete() methods work fine. The problem is with
the Update() method. For some reason this method removes the data in the
thumb field of the database. In this method I only update the
description:

PUBLIC SUB Update(Row AS Integer, Description AS String)
  ResultPictures.MoveTo(Row)
  ResultPictures["description"] = Conv(Description, Desktop.Charset,
databaseConnection.Charset)
  ResultPictures.Update()
CATCH
  Error.Raise("<b>Update database record error</b><hr>Error:<br>" &
DConv(Error.Text))
END

But with DB.Debug = TRUE we can see that the SQL created sets 'thumb' =
NULL

sqlite: 0x80fd968: UPDATE 'pictures' SET 'id' = 5, 'thumb' = NULL,
'image' = X'89504...

though the 'image' blob field is correct. Here I have used a SQLite 3
database but the same happens in a MySQL database. I have not tries it
with a PostgressSQL database, but my guess is that it is the same.


Hope this helps

8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PictureDatabase-0.0.1.tar.gz
Type: application/x-gzip
Size: 13539 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20070410/cc457f41/attachment.bin>


More information about the User mailing list