2024.8.23
Loading...
Searching...
No Matches
db_mysql.inc.php File Reference

Go to the source code of this file.

Functions

 raw_db_close_database ()
 
 raw_db_create_database ($database, $server="", $username="", $password="")
 
 raw_db_create_field ($tablename, $field, $type)
 
 raw_db_delete_field ($tablename, $field)
 
 raw_db_edit_field ($tablename, $field, $type)
 
 raw_db_escape_string ($str)
 
 raw_db_fetch_array ($result, $type=FETCH_BOTH)
 
 raw_db_free_result ($result)
 
 raw_db_list_database_tables ()
 
 raw_db_list_table_fields_def ($tablename, $type=false)
 
if(DB_WRAPVERSION !=DB_MYSQL_WRAPraw_db_open_database ($database, $server="", $username="", $password="")
 
 raw_db_query ($query)
 
 raw_db_rename_field ($tablename, $field, $newname, $type)
 
 raw_db_rename_table ($tablename, $newname)
 
 raw_db_table_exists ($tablename)
 
 raw_get_db_version ()
 

Variables

const DB_MYSQL_WRAP (PHP_VERSION >="5") if(!extension_loaded('mysql')) if(! @dl('php_mysql.dll')) "db_v2b"
 
const FETCH_ASSOC MYSQL_ASSOC
 
const FETCH_BOTH MYSQL_BOTH
 
const FETCH_NUM MYSQL_NUM
 

Function Documentation

◆ raw_db_close_database()

raw_db_close_database ( )

raw_db_close_database()

Returns
bool

Definition at line 127 of file db_mysql.inc.php.

128{
129 return mysql_close();
130}

Referenced by db_close_database().

+ Here is the caller graph for this function:

◆ raw_db_create_database()

raw_db_create_database ( $database,
$server = "",
$username = "",
$password = "" )

raw_db_create_database() Creates a database if it does not exist.

Parameters
$database
string$server
string$username
string$password
Returns
resource or FALSE

Definition at line 80 of file db_mysql.inc.php.

81{
82 global $curr_db;
83
84 $conn = mysql_connect($server, $username, $password);
85 if (!$conn) {
86 trigger_error(__FUNCTION__ . ": " . mysql_error());
87 return false;
88 } else {
89 if (!mysql_query("CREATE DATABASE IF NOT EXISTS " . $database))
90 die(mysql_error());
91 $curr_db = $database;
92 if (!mysql_select_db($database)) {
93 trigger_error(__FUNCTION__ . ": " . mysql_error());
94 return false;
95 }
96 }
97 return $conn;
98}

Referenced by db_create_database().

+ Here is the caller graph for this function:

◆ raw_db_create_field()

raw_db_create_field ( $tablename,
$field,
$type )

raw_db_create_field()

Parameters
$tablename
$field
$type
Returns
bool

Definition at line 201 of file db_mysql.inc.php.

202{
203 global $g_lasttable;
204
205 if (!$tablename)
206 $tablename = $g_lasttable;
207 $g_lasttable = $tablename;
208
209 $res = mysql_query("ALTER TABLE $tablename ADD $field $type");
210 return $res;
211}

Referenced by db_create_field().

+ Here is the caller graph for this function:

◆ raw_db_delete_field()

raw_db_delete_field ( $tablename,
$field )

raw_db_delete_field()

Parameters
$tablename
$field
Returns
bool

Definition at line 220 of file db_mysql.inc.php.

221{
222 global $g_lasttable;
223
224 if (!$tablename)
225 $tablename = $g_lasttable;
226 $g_lasttable = $tablename;
227
228 $res = mysql_query("ALTER TABLE $tablename DROP $field");
229 return $res;
230}

Referenced by db_delete_field().

+ Here is the caller graph for this function:

◆ raw_db_edit_field()

raw_db_edit_field ( $tablename,
$field,
$type )

raw_db_edit_field()

Parameters
$tablename
$field
$type
Returns
bool

Definition at line 261 of file db_mysql.inc.php.

262{
263 global $g_lasttable;
264
265 if (!$tablename)
266 $tablename = $g_lasttable;
267 $g_lasttable = $tablename;
268
269 $res = mysql_query("ALTER TABLE $tablename MODIFY $field $type");
270 return $res;
271}

Referenced by db_edit_field().

+ Here is the caller graph for this function:

◆ raw_db_escape_string()

raw_db_escape_string ( $str)

raw_db_escape_string()

Parameters
$str
Returns
escaped string

Definition at line 318 of file db_mysql.inc.php.

319{
320 return mysql_real_escape_string($str);
321}

Referenced by db_escape_string().

+ Here is the caller graph for this function:

◆ raw_db_fetch_array()

raw_db_fetch_array ( $result,
$type = FETCH_BOTH )

raw_db_fetch_array() get the value of SQL-query, row by row

Parameters
$result
unknown$type
Returns
array of row, FALSE if no more rows

Definition at line 296 of file db_mysql.inc.php.

297{
298 return mysql_fetch_array($result, $type);
299}
$result

References $result.

Referenced by db_fetch_array().

+ Here is the caller graph for this function:

◆ raw_db_free_result()

raw_db_free_result ( $result)

raw_db_free_result()

Parameters
$result
Returns
bool

Definition at line 307 of file db_mysql.inc.php.

308{
309 mysql_free_result($result);
310}

References $result.

Referenced by db_free_result().

+ Here is the caller graph for this function:

◆ raw_db_list_database_tables()

raw_db_list_database_tables ( )

raw_db_list_database_tables() Returns an array with the list of tables of the current database.

Returns
array or FALSE

Definition at line 106 of file db_mysql.inc.php.

107{
108 global $curr_db;
109
110 $hresult = mysql_query("SHOW TABLES FROM $curr_db");
111 if (!$hresult) {
112 // no Tables in $database
113 return false;
114 } else {
115 while ($row = mysql_fetch_array($hresult, MYSQL_NUM)) {
116 $tables[] = $row[0];
117 } // while
118 return $tables;
119 }
120}

Referenced by db_list_database_tables().

+ Here is the caller graph for this function:

◆ raw_db_list_table_fields_def()

raw_db_list_table_fields_def ( $tablename,
$type = false )

raw_db_list_table_fields_def() lists fieldnames or fieldattributes according type

Parameters
$tablename
boolean$type
Returns
array or FALSE

Definition at line 177 of file db_mysql.inc.php.

178{
179 $result = mysql_query("SHOW COLUMNS FROM $tablename");
180 if ($result === false) return false;
181 $coltype = array();
182 $colnames = array();
183 if (mysql_num_rows($result) > 0) {
184 while ($row = mysql_fetch_assoc($result)) {
185 $colnames[] = $row['Field'];
186 $coltype[] = $row['Type'];
187 } // while
188 }
189 if (mysql_free_result($result) == false) return false;
190 return ($type ? $coltype : $colnames);
191}

References $result.

Referenced by db_list_table_fields().

+ Here is the caller graph for this function:

◆ raw_db_open_database()

if(DB_WRAPVERSION !=DB_MYSQL_WRAP) raw_db_open_database ( $database,
$server = "",
$username = "",
$password = "" )

raw_db_open_database() Opens and connects an existing database.

Parameters
$database
string$server
string$username
string$password
Returns
resource or FALSE

Definition at line 52 of file db_mysql.inc.php.

53{
54 global $curr_db;
55
56 $conn = mysql_connect($server, $username, $password);
57 if (!$conn) {
58 trigger_error(__FUNCTION__ . ": " . mysql_error());
59 return false;
60 } else {
61 $curr_db = $database;
62 if (!mysql_select_db($database)) {
63 trigger_error(__FUNCTION__ . ": " . mysql_error());
64 return false;
65 }
66 }
67 return $conn;
68}

Referenced by db_open_database().

+ Here is the caller graph for this function:

◆ raw_db_query()

raw_db_query ( $query)

raw_db_query() queries the database with SQL

Parameters
string$query
Returns
resource on success for SELECT,SHOW,DESCRIBE ans EXPLAIN TRUE on success for UPDATE, DELETE, DROP etc FALSE on errors

Definition at line 282 of file db_mysql.inc.php.

283{
284 $res = mysql_query($query);
285 return $res;
286}

Referenced by db_create_record(), db_create_table(), db_delete_records(), db_delete_table(), db_edit_record(), db_get_data(), db_get_id(), db_get_next_free_id(), db_query(), and db_swap_records().

+ Here is the caller graph for this function:

◆ raw_db_rename_field()

raw_db_rename_field ( $tablename,
$field,
$newname,
$type )

raw_db_rename_field()

Parameters
$tablename
$field
$newname
$type
Returns
bool

Definition at line 241 of file db_mysql.inc.php.

242{
243 global $g_lasttable;
244
245 if (!$tablename)
246 $tablename = $g_lasttable;
247 $g_lasttable = $tablename;
248
249 $res = mysql_query("ALTER TABLE $tablename CHANGE $field $newname $type");
250 return $res;
251}

Referenced by db_rename_field().

+ Here is the caller graph for this function:

◆ raw_db_rename_table()

raw_db_rename_table ( $tablename,
$newname )

raw_db_rename_table()

Parameters
$tablename
$newname
Returns
bool

Definition at line 157 of file db_mysql.inc.php.

158{
159 global $g_lasttable;
160
161 if (!$tablename)
162 $tablename = $g_lasttable;
163
164 $g_lasttable = $newname;
165 $res = mysql_query("RENAME TABLE $tablename TO $newname");
166 return $res;
167}

Referenced by db_rename_table().

+ Here is the caller graph for this function:

◆ raw_db_table_exists()

raw_db_table_exists ( $tablename)

raw_db_table_exists()

Parameters
$tablename
Returns
bool

Definition at line 138 of file db_mysql.inc.php.

139{
140 global $g_current_db;
141
142 $sql = "SELECT 1 FROM $tablename LIMIT 0";
143 $res = mysql_query($sql);
144 if ($res) {
145 return true;
146 } ;
147 return false;
148}

Referenced by db_table_exists().

+ Here is the caller graph for this function:

◆ raw_get_db_version()

raw_get_db_version ( )

raw_get_db_version() Returns the version of the database library.

Returns
string

Definition at line 33 of file db_mysql.inc.php.

34{
35 return mysql_get_server_info();
36}
37
39 die(" db_common.inc.php has different version number than db_mysql.inc.php ");
40}
const DB_WRAPVERSION
const DB_MYSQL_WRAP(PHP_VERSION >="5") if(!extension_loaded('mysql')) if(! @dl('php_mysql.dll'))

Referenced by db_get_info().

+ Here is the caller graph for this function:

Variable Documentation

◆ DB_MYSQL_WRAP

const DB_MYSQL_WRAP(PHP_VERSION >="5") if(!extension_loaded( 'mysql')) if(! @dl( 'php_mysql.dll')) ( PHP_VERSION >="5" ) "db_v2b"

WINBINDER - The native Windows binding for PHP for PHP

Copyright � Hypervisual - see LICENSE.TXT for details Authors: Rubem Pechansky and Hans Rebel

Database wrapper functions for WinBinder (MySQL-specific) version 2b

Definition at line 21 of file db_mysql.inc.php.

◆ FETCH_ASSOC

const FETCH_ASSOC MYSQL_ASSOC

Definition at line 24 of file db_mysql.inc.php.

Referenced by db_swap_records().

◆ FETCH_BOTH

const FETCH_BOTH MYSQL_BOTH

Definition at line 22 of file db_mysql.inc.php.

◆ FETCH_NUM

const FETCH_NUM MYSQL_NUM

Definition at line 23 of file db_mysql.inc.php.

Referenced by db_create_record(), db_get_id(), and db_get_next_free_id().