Changeset 41 for includes/databaseconection.php
- Timestamp:
- Jan 24, 2009, 7:49:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
includes/databaseconection.php
r40 r41 1 1 <?php 2 class Database3 { // BEGIN class Database4 // variables5 var $id_connection = 0;6 // var $LastResult;7 8 2 9 // constructor 10 function Database($addres,$user,$pass) //default: $Database = new Database('localhost','root',''); 11 { // BEGIN constructor 12 $this->id_connection = mysql_connect($addres,$user,$pass); 13 if (!$this->id_connection) 14 die('Spojení s MySQL databází se nezdařilo.'); 15 } // END constructor 3 class Database 4 { 5 var $id_connection = 0; 6 7 function Database($address = 'localhost', $user = 'root', $pass = '') 8 { 9 $this->id_connection = mysql_connect($address, $user, $pass); 10 if(!$this->id_connection) 11 die('Spojení s MySQL databází se nezdařilo.'); 12 } 16 13 17 18 { // BEGIN function SelectDatabase19 $return_selection = mysql_select_db($NameDatabase, $this->id_connection);20 if 21 die('Databázi pokusse nám nepodařilo vybrat.');22 } // END function SelectDatabase14 function SelectDatabase($NameDatabase) 15 { 16 $return_selection = mysql_select_db($NameDatabase, $this->id_connection); 17 if(!$return_selection) 18 die('Databázi '.$NameDatabase.' se nám nepodařilo vybrat.'); 19 } 23 20 24 function SQLCommand($Command) 25 { // BEGIN function SQLCommand 26 $ReturnCommand = mysql_query($Command,$this->id_connection); 27 if (!$ReturnCommand) { 21 function SQLCommand($Command) 22 { 23 $ReturnCommand = mysql_query($Command, $this->id_connection); 24 if(!$ReturnCommand) 25 { 28 26 die('Nepodařilo se aplikovat příkaz.'); 29 } else { 27 } else 28 { 30 29 return $ReturnCommand; 31 30 } 32 } // END function SQLCommand31 } 33 32 34 function ReadFromDatabase($SQL) // "SELECT * FROM User" 35 { // BEGIN function ReadFromDatabase 36 $return_result = mysql_query($sql,$id_spojeni); 37 if (!$return_result) { 33 function ReadFromDatabase($SQL) 34 { 35 $return_result = mysql_query($sql, $id_spojeni); 36 if (!$return_result) 37 { 38 38 die('Nepodařilo se nám načíst řádky z databáze.'); 39 } else { 39 } else 40 { 40 41 return $return_result; 41 42 } 42 } // END function ReadFromDatabase43 } 43 44 44 45 { // BEGIN function Disconnect45 function Disconnect() 46 { 46 47 mysql_close($this->id_connection); 47 } // END function Disconnect48 } // END class Database 48 } 49 } 49 50 50 51 ?>
Note:
See TracChangeset
for help on using the changeset viewer.