UserLibrary - MySQL interface

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

UserLibrary - MySQL interface

Post 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
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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.
-Beach
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Nice work !
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Didn't test it yet. But your example code looks just fantastic ! Thanks a lot
for sharing it :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Any ideas how I can hide my login and password?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post 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
-Beach
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

@linux users

does it works on linux (.lib not provided) ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post 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.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
JCV
Enthusiast
Enthusiast
Posts: 579
Joined: Fri Jun 30, 2006 4:30 pm
Location: Middle East

Post by JCV »

wow thats nice! thanks :wink:
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

Flype .. i love you ! :lol:

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


Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
Razon
New User
New User
Posts: 4
Joined: Sat May 19, 2007 1:50 pm
Location: Hungary

Post by Razon »

I can't access online MySQL database :cry: Why?
JCV
Enthusiast
Enthusiast
Posts: 579
Joined: Fri Jun 30, 2006 4:30 pm
Location: Middle East

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

[Registered PB User since 2006]
[PureBasic 5.7][SpiderBasic 2.2] [Win 10 64bit]
[Intel i7 990x 4.20 Ghz] [18GB DDR3]
Razon
New User
New User
Posts: 4
Joined: Sat May 19, 2007 1:50 pm
Location: Hungary

Post by Razon »

I think, it doesn't let me direct access it, only from the webpage. Do you know any MySQL server to use?
Razon
New User
New User
Posts: 4
Joined: Sat May 19, 2007 1:50 pm
Location: Hungary

Post by Razon »

Oh I found one: www.freemysql.net
Post Reply