[Gambas-devel] MySQL class ready
Benoit Minisini
gambas at ...1...
Tue Apr 15 22:50:49 CEST 2008
On mardi 15 avril 2008, Benoit Minisini wrote:
> On mardi 15 avril 2008, David Villalobos Cambronero wrote:
> > Let me check, I remember that I qouted table names, and the arguments
> > too.
> >
> > David
>
> Table and field names should be quoted, with the DB.Quote() function, as
> soon as they include reserved characters.
>
> But SQL requests have to be quoted too, with the DB.Subst(), Exec(),
> Find()... methods.
>
> I plan to try to make gb.db.mysql a true component, so that your class
> becomes its Gambas part. But first, you must solve the quoting problem. And
> for sure, I will have other remark in the future. :-)
>
> Regards,
Here is some remarks. I know, I'm fast...
You have to specify the connection used by your MySQL class.
But you can do a better design by reimplementing the DB and the Connection
class so that they have a property named MySQL that returns a dummy object
that will have all the methods of the MySQL class.
Look:
-------------------------------------------------------
' _MySQL.class
' The "_" is needed, so that the user don't see it!
Export
Property Connection As Connection
... All methods of the old MySQL class
-------------------------------------------------------
' Connection.class
Export
Property Read MySQL As _MySQL
Private Sub MySQL_Read() AS _MySQL
_MySQL.Connection = Me
Return _MySQL
End
-------------------------------------------------------
' DB.class
Export
Property Read MySQL As _MySQL
Private Sub MySQL_Read() AS _MySQL
_MySQL.Connection = DB.Current
Return _MySQL
End
-------------------------------------------------------
Am I clear?
This way, the user will just have to do things like:
DB.MySQL.CreateDatabase()
MyConnection.MySQL.DropTables()
Otherwise, I think the interface of your table creation methods, and so on,
could be better too, but I have no idea at the moment. You can search
yourself! :-) Maybe copying the interface of DB and Connection, so that the
user does not have too much to learn again?
Regards,
--
Benoit Minisini
More information about the Devel
mailing list