Page 1 of 1

UserLibrary - MySQL interface

Posted: Mon Mar 26, 2007 7:18 pm
by Flype
Here is an object oriented include for MySQL5.


those who are familiar with php/mysql might appreciate this way of coding.

this is free - as always.


ABOUT HELP:
sorry no doc at the moment.
just look at the include file which is clear enough.
if somebody is courageous enough to make a doc it will be much appreciated as i do not have time for this.


NOTE:
please adjust in the file 'libmysql.pbi', at line 92 your path for the libmysql.lib.


ARCHIVE:
UserLib_PB40_libmysql.zip
Image


SAMPLE CODE:

Code: Select all

IncludeFile "libmysql.pbi"

db.IMYSQL = mysql("localhost", "root", "", "mysql")

If db
  
  If db\query("SELECT 'Hello' AS 'f1', 'World !' AS 'f2', NOW() as 'f3', 12345.6789")
    
    While db\row()
      
      Debug db\GetString("f1")
      Debug db\GetString("f2")
      
      Debug FormatDate("%dd.%mm.%yyyy", db\GetDate("f3"))
      
      Debug db\get_double(3)
      
    Wend
    
  Else
    
    Debug db\error()
    
  EndIf
  
  db\free()
  
EndIf
:P

Posted: Mon Mar 26, 2007 8:15 pm
by Beach
Man, those French coders are awesome. Good job Flype! You are right, it does work similarly to the way PHP/MySQL code construction works, and that is perfect for me.

Posted: Mon Mar 26, 2007 8:17 pm
by Fred
Nice work !

Posted: Mon Mar 26, 2007 8:28 pm
by benny
Didn't test it yet. But your example code looks just fantastic ! Thanks a lot
for sharing it :!:

Posted: Mon Mar 26, 2007 8:54 pm
by GeoTrail
Any ideas how I can hide my login and password?

Posted: Mon Mar 26, 2007 9:01 pm
by Beach
GeoTrail wrote:Any ideas how I can hide my login and password?
The connection to the MySQL server encrypts the password (I would think the username also but the docs do not say this...) Obviously, your code could be compromised. Maybe a quick MD5 (or similar) procedure would take care of that.

http://dev.mysql.com/doc/refman/5.0/en/ ... ttack.html

Posted: Mon Mar 26, 2007 9:35 pm
by Flype
@geotrail

i made a little function in the include :

Code: Select all

myDB.IMySQL = mysql_from_ini()
this way no user/pwd in your program.

the .ini file should look :

Code: Select all

[CONNECTION]
host = localhost
user = root
pass = 
base = mysql
port = 3306
opts = 0
as the include is totally open-source, you can improve this procedure (line 1105) if you need an encrypted one - but let us know...

Posted: Mon Mar 26, 2007 9:47 pm
by Flype
@linux users

does it works on linux (.lib not provided) ?

Posted: Mon Mar 26, 2007 10:14 pm
by GeoTrail
Thanks Flype.
My worry is that someone might get the username and password to the mysql database and they could take over control of it.

Posted: Tue Mar 27, 2007 2:28 am
by JCV
wow thats nice! thanks :wink:

Posted: Tue Mar 27, 2007 11:01 am
by Thalius
Flype .. i love you ! :lol:

.. i was gonna write something like this for a customer Project ... ;)


Thalius

Posted: Sat May 19, 2007 1:56 pm
by Razon
I can't access online MySQL database :cry: Why?

Posted: Sat May 19, 2007 2:33 pm
by JCV
Razon wrote:I can't access online MySQL database :cry: Why?
Check your host if you are allowed to directly access your mySQL online. Also check if there is an option where you can add your IP address to allow you to directly access it.

Posted: Sat May 19, 2007 3:45 pm
by Razon
I think, it doesn't let me direct access it, only from the webpage. Do you know any MySQL server to use?

Posted: Sat May 19, 2007 4:40 pm
by Razon
Oh I found one: www.freemysql.net