i want the best php class to work with mysql

Reply

Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

i want the best php class to work with mysql

 
0
  #1
Sep 12th, 2009
i want the best php class to work with mysql
hi
i want the best and the simple php class to work with the mysql
thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: i want the best php class to work with mysql

 
0
  #2
Sep 12th, 2009
this should help you

  1. <?php
  2. /*
  3. *
  4. * MARCO VOEGELI 31.12.2005
  5. * www.voegeli.li
  6. *
  7. * This class provides one central database-connection for
  8. * al your php applications. Define only once your connection
  9. * settings and use it in all your applications.
  10. *
  11. *
  12. */
  13.  
  14.  
  15. class Database
  16. { // Class : begin
  17.  
  18. var $host; //Hostname, Server
  19. var $password; //Passwort MySQL
  20. var $user; //User MySQL
  21. var $database; //Datenbankname MySQL
  22. var $link;
  23. var $query;
  24. var $result;
  25. var $rows;
  26.  
  27. function Database()
  28. { // Method : begin
  29. //Konstruktor
  30.  
  31.  
  32.  
  33. // ********** DIESE WERTE ANPASSEN **************
  34. // ********** ADJUST THESE VALUES HERE **********
  35.  
  36. $this->host = "localhost"; // <<---------
  37. $this->password = "yourpassword"; // <<---------
  38. $this->user = "youruser"; // <<---------
  39. $this->database = "yourdatabase"; // <<---------
  40. $this->rows = 0;
  41.  
  42. // **********************************************
  43. // **********************************************
  44.  
  45.  
  46.  
  47. } // Method : end
  48.  
  49. function OpenLink()
  50. { // Method : begin
  51. $this->link = @mysql_connect($this->host,$this->user,$this->password) or die (print "Class Database: Error while connecting to DB (link)");
  52. } // Method : end
  53.  
  54. function SelectDB()
  55. { // Method : begin
  56.  
  57. @mysql_select_db($this->database,$this->link) or die (print "Class Database: Error while selecting DB");
  58.  
  59. } // Method : end
  60.  
  61. function CloseDB()
  62. { // Method : begin
  63. mysql_close();
  64. } // Method : end
  65.  
  66. function Query($query)
  67. { // Method : begin
  68. $this->OpenLink();
  69. $this->SelectDB();
  70. $this->query = $query;
  71. $this->result = mysql_query($query,$this->link) or die (print "Class Database: Error while executing Query");
  72.  
  73. // $rows=mysql_affected_rows();
  74.  
  75. if(ereg("SELECT",$query))
  76. {
  77. $this->rows = mysql_num_rows($this->result);
  78. }
  79.  
  80. $this->CloseDB();
  81. } // Method : end
  82.  
  83. } // Class : end
  84.  
  85. ?>
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

Re: i want the best php class to work with mysql

 
0
  #3
Sep 12th, 2009
thank you iam sure its great
but its too old
31.12.2005
please i want it new and famous
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: i want the best php class to work with mysql

 
0
  #4
Sep 12th, 2009
PHP 5 was released 2004, and i don't see any problem with the code that i have given above.

And what do you mean about new and famous?

then just use this

www.php.net/mysql
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

Re: i want the best php class to work with mysql

 
0
  #5
Sep 12th, 2009
thanks agian
you great man
but i want it not simple and maybe using cache and mysql only
to use it in very bigest project
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: i want the best php class to work with mysql

 
0
  #6
Sep 12th, 2009
sorry, but since you stated in the OP that you wanted it simple. Your description was vague.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

Re: i want the best php class to work with mysql

 
0
  #7
Sep 12th, 2009
Originally Posted by ivatanako View Post
sorry, but since you stated in the OP that you wanted it simple. Your description was vague.
I'm sorry for causing you trouble\
but i want A strong and quick and easy class because i will use it
in very big site
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

Re: i want the best php class to work with mysql

 
0
  #8
Sep 13th, 2009
any more ideas?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 793
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 109
darkagn's Avatar
darkagn darkagn is offline Offline
Master Poster

Re: i want the best php class to work with mysql

 
0
  #9
Sep 13th, 2009
The code that ivatanako has given you is probably as simple as you can get. It will allow you to connect to your database and run a query. You can extend it if you need, but I can't see how it could be simplified further as you need those steps to be able to do anything in mysql and php.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 19
Reputation: click here is an unknown quantity at this point 
Solved Threads: 0
click here click here is offline Offline
Banned

Re: i want the best php class to work with mysql

 
0
  #10
Sep 14th, 2009
Originally Posted by darkagn View Post
The code that ivatanako has given you is probably as simple as you can get. It will allow you to connect to your database and run a query. You can extend it if you need, but I can't see how it could be simplified further as you need those steps to be able to do anything in mysql and php.
thanks man iam sure you is great man because of this advice
but i want thinge make loops and fetches and all this i found one but not tried yet
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC