Skip to content

Commit

Permalink
more changes to db functions
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@108 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Kenzaburo Ito committed Dec 24, 2000
1 parent 7e1ec3c commit 6ccab5f
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 47 deletions.
7 changes: 5 additions & 2 deletions ChangeLog
Expand Up @@ -32,12 +32,15 @@ To Do:
* Added reopen bug dialog
* Added $g_bug_reopen_page and removed $g_bug_reopen
* Added bug_reopen_page.php3 and removed bug_reopen.php3
* Added resolve bug dialog
* Added $g_bug_resolve_page and bug_resolve_page.php3
* Modified the appearance of the advanced view and update
* Split the account pref modifications into two spearate files:
* Split the account pref modifications into two separate files:
account_prefs_update.php3 and account_prefs_reset.php3
* Removed db_mysql_error()
*
* Renamed db_mysql_connect() to db_connect()
* Renamed db_mysql_query() to db_query()
* Added several db_ functions in preparation for database abstraction

12.20.2000 - 0.12.0

Expand Down
2 changes: 1 addition & 1 deletion account_page.php3
Expand Up @@ -22,7 +22,7 @@
$query = "SELECT *
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
if ( $row ) {
extract( $row, EXTR_PREFIX_ALL, "u" );
Expand Down
6 changes: 3 additions & 3 deletions account_prefs_page.php3
Expand Up @@ -24,7 +24,7 @@
$query = "SELECT *
FROM $g_mantis_user_pref_table
WHERE user_id='$u_id'";
$result = db_mysql_query($query);
$result = db_query($query);

## OOPS, No entry in the database yet. Lets make one
if ( mysql_num_rows( $result )==0 ) {
Expand All @@ -36,13 +36,13 @@
VALUES
(null, '$u_id',
'$g_default_advanced_report', '$g_default_advanced_view')";
$result = db_mysql_query($query);
$result = db_query($query);

### Rerun select query
$query = "SELECT *
FROM $g_mantis_user_pref_table
WHERE user_id='$u_id'";
$result = db_mysql_query($query);
$result = db_query($query);
}

### prefix data with u_
Expand Down
2 changes: 1 addition & 1 deletion account_profile_edit_page.php3
Expand Up @@ -30,7 +30,7 @@
$query = "SELECT *
FROM $g_mantis_user_profile_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
if ( $row ) {
extract( $row, EXTR_PREFIX_ALL, "v" );
Expand Down
4 changes: 2 additions & 2 deletions bug_update_advanced_page.php3
Expand Up @@ -20,14 +20,14 @@
$query = "SELECT *
FROM $g_mantis_bug_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v" );

$query = "SELECT *
FROM $g_mantis_bug_text_table
WHERE id='$v_bug_text_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v2" );

Expand Down
4 changes: 2 additions & 2 deletions bug_update_page.php3
Expand Up @@ -20,14 +20,14 @@
$query = "SELECT *
FROM $g_mantis_bug_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v" );

$query = "SELECT *
FROM $g_mantis_bug_text_table
WHERE id='$v_bug_text_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v2" );

Expand Down
4 changes: 2 additions & 2 deletions bugnote_inc.php
Expand Up @@ -15,7 +15,7 @@
FROM $g_mantis_bugnote_table
WHERE bug_id='$f_id'
ORDER BY date_submitted $g_bugnote_order";
$result = db_mysql_query($query);
$result = db_query($query);
$num_notes = mysql_num_rows($result);
?>

Expand Down Expand Up @@ -50,7 +50,7 @@
$query = "SELECT note
FROM $g_mantis_bugnote_text_table
WHERE id='$v3_bugnote_text_id'";
$result2 = db_mysql_query($query);
$result2 = db_query($query);
$v3_note = mysql_result( $result2, 0);
?>
<tr height=5 bgcolor=<? echo $g_white_color ?>>
Expand Down
32 changes: 14 additions & 18 deletions core_API.php
Expand Up @@ -16,7 +16,7 @@
###########################################################################

###########################################################################
# MySQL
# Database : MYSQL for now
###########################################################################
### --------------------
# connect to database
Expand All @@ -29,7 +29,7 @@ function db_connect($p_hostname="localhost", $p_username="root",
$t_result = mysql_select_db( $p_database );
}
### --------------------
# connect to database
# persistent connect to database
function db_pconnect($p_hostname="localhost", $p_username="root",
$p_password="", $p_database="mantis",
$p_port=3306 ) {
Expand All @@ -42,7 +42,7 @@ function db_pconnect($p_hostname="localhost", $p_username="root",
# execute query, requires connection to be opened,
# goes to error page if error occurs
# Use this when you don't want to handler an error yourself
function db_mysql_query( $p_query ) {
function db_query( $p_query ) {
global $g_mysql_error_page;

$t_result = mysql_query( $p_query );
Expand All @@ -59,10 +59,6 @@ function db_select_db( $p_db_name ) {
mysql_select_db( $p_db_name );
}
### --------------------
function db_query( $p_query ) {
return mysql_query( $p_query );
}
### --------------------
function db_num_rows( $p_result ) {
return mysql_num_rows( $p_result );
}
Expand Down Expand Up @@ -147,7 +143,7 @@ function print_login_info() {
$query = "SELECT username
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$t_username = mysql_result( $result, 0 );

$t_now = date("d-m-y h:m T");
Expand Down Expand Up @@ -263,7 +259,7 @@ function print_news_item_option_list() {
$query = "SELECT id, headline
FROM $g_mantis_news_table
ORDER BY id DESC";
$result = db_mysql_query( $query );
$result = db_query( $query );
$news_count = mysql_num_rows( $result );

for ($i=0;$i<$news_count;$i++) {
Expand Down Expand Up @@ -308,7 +304,7 @@ function print_user( $p_user_id ) {
$query = "SELECT username, email
FROM $g_mantis_user_table
WHERE id='$p_user_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
if ( mysql_num_rows( $result )>0 ) {
$t_handler_username = mysql_result( $result, 0, 0 );
$t_handler_email = mysql_result( $result, 0, 1 );
Expand Down Expand Up @@ -343,7 +339,7 @@ function print_profile_option_list( $p_id ) {
FROM $g_mantis_user_profile_table
WHERE user_id='$p_id'
ORDER BY id DESC";
$result = db_mysql_query( $query );
$result = db_query( $query );
$profile_count = mysql_num_rows( $result );

PRINT "<option value=\"\">";
Expand Down Expand Up @@ -373,7 +369,7 @@ function get_enum_string( $p_field_name ) {

$query = "SHOW FIELDS
FROM $g_mantis_bug_table";
$result = db_mysql_query( $query );
$result = db_query( $query );
$entry_count = mysql_num_rows( $result );
for ($i=0;$i<$entry_count;$i++) {
$row = mysql_fetch_array( $result );
Expand Down Expand Up @@ -512,7 +508,7 @@ function login_cookie_check( $p_redirect_url="" ) {
$query = "SELECT enabled
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
if ( $row ) {
$t_enabled = $row["enabled"];
Expand Down Expand Up @@ -573,7 +569,7 @@ function index_login_cookie_check( $p_redirect_url="" ) {
$query = "SELECT enabled
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
if ( $row ) {
$t_enabled = $row["enabled"];
Expand Down Expand Up @@ -623,7 +619,7 @@ function get_current_user_field( $p_field_name ) {
$query = "SELECT $p_field_name
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
return mysql_result( $result, 0 );
}
else {
Expand All @@ -647,7 +643,7 @@ function get_current_user_profile_field( $p_field_name ) {
$query = "SELECT $p_field_name
FROM $g_mantis_user_pref_table
WHERE user_id='$t_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
return mysql_result( $result, 0 );
}
else {
Expand All @@ -662,7 +658,7 @@ function get_bugnote_count( $p_id ) {
$query = "SELECT COUNT(id)
FROM $g_mantis_bugnote_table
WHERE bug_id ='$p_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
return mysql_result( $result, 0 );
}
### --------------------
Expand Down Expand Up @@ -713,7 +709,7 @@ function get_user_value( $p_table_name, $p_table_field ) {
$query = "SELECT $p_table_field
FROM $p_table_name
WHERE user_id='$u_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );

if ( mysql_num_rows( $result ) > 0 ) {
return mysql_result( $result, 0 );
Expand Down
2 changes: 1 addition & 1 deletion login.php3
Expand Up @@ -12,7 +12,7 @@
$query = "SELECT *
FROM $g_mantis_user_table
WHERE username='$f_username'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );

if ( $row ) {
Expand Down
2 changes: 1 addition & 1 deletion main_page.php3
Expand Up @@ -31,7 +31,7 @@
FROM $g_mantis_news_table
ORDER BY id DESC
LIMIT $f_offset, $g_news_view_limit";
$result = db_mysql_query( $query );
$result = db_query( $query );
$news_count = mysql_num_rows( $result );
?>

Expand Down
2 changes: 1 addition & 1 deletion manage_page.php3
Expand Up @@ -47,7 +47,7 @@
FROM $g_mantis_user_table
ORDER BY '$f_sort' $f_dir";

$result = db_mysql_query($query);
$result = db_query($query);
$user_count = mysql_num_rows($result);
?>

Expand Down
2 changes: 1 addition & 1 deletion manage_user_page.php3
Expand Up @@ -27,7 +27,7 @@
$query = "SELECT *
FROM $g_mantis_user_table
WHERE id='$f_id'";
$result = db_mysql_query($query);
$result = db_query($query);
$row = mysql_fetch_array($result);
extract( $row, EXTR_PREFIX_ALL, "u" );
?>
Expand Down
2 changes: 1 addition & 1 deletion news_edit_page.php3
Expand Up @@ -25,7 +25,7 @@
$query = "SELECT *
FROM $g_mantis_news_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
if ( $row ) {
extract( $row, EXTR_PREFIX_ALL, "v" );
Expand Down
4 changes: 2 additions & 2 deletions report_add.php3
Expand Up @@ -32,7 +32,7 @@
$query = "SELECT id
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$u_id = mysql_result( $result, 0 );

### Make strings safe for database
Expand All @@ -53,7 +53,7 @@
$query = "SELECT id, platform, os, os_build, default_profile
FROM $g_mantis_user_profile_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$profile_count = mysql_num_rows( $result );

$row = mysql_fetch_array( $result );
Expand Down
2 changes: 1 addition & 1 deletion report_bug_advanced_page.php3
Expand Up @@ -21,7 +21,7 @@
$query = "SELECT id
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query($query);
$result = db_query($query);
$u_id = mysql_result( $result, 0 );
?>

Expand Down
2 changes: 1 addition & 1 deletion view_bug_advanced_page.php3
Expand Up @@ -20,7 +20,7 @@
$query = "SELECT *
FROM $g_mantis_bug_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v" );

Expand Down
2 changes: 1 addition & 1 deletion view_bug_all_page.php3
Expand Up @@ -189,7 +189,7 @@
</tr>
<?
### perform query
$result = db_mysql_query( $query );
$result = db_query( $query );
$row_count = mysql_num_rows( $result );

for($i=0; $i < $row_count; $i++) {
Expand Down
4 changes: 2 additions & 2 deletions view_bug_page.php3
Expand Up @@ -20,14 +20,14 @@
$query = "SELECT *
FROM $g_mantis_bug_table
WHERE id='$f_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v" );

$query = "SELECT *
FROM $g_mantis_bug_text_table
WHERE id='$v_bug_text_id'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$row = mysql_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, "v2" );

Expand Down
4 changes: 2 additions & 2 deletions view_user_assigned_bug_page.php3
Expand Up @@ -21,7 +21,7 @@
$query = "SELECT id
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$t_user_id = mysql_result( $result, 0);

if ( !isset( $f_limit_view ) ) {
Expand Down Expand Up @@ -201,7 +201,7 @@
</tr>
<?
### perform query
$result = db_mysql_query( $query );
$result = db_query( $query );
$row_count = mysql_num_rows( $result );

for($i=0; $i < $row_count; $i++) {
Expand Down
4 changes: 2 additions & 2 deletions view_user_reported_bug_page.php3
Expand Up @@ -21,7 +21,7 @@
$query = "SELECT id
FROM $g_mantis_user_table
WHERE cookie_string='$g_string_cookie_val'";
$result = db_mysql_query( $query );
$result = db_query( $query );
$t_user_id = mysql_result( $result, 0);

if ( !isset( $f_limit_view ) ) {
Expand Down Expand Up @@ -200,7 +200,7 @@
</tr>
<?
### perform query
$result = db_mysql_query( $query );
$result = db_query( $query );
$row_count = mysql_num_rows( $result );

for($i=0; $i < $row_count; $i++) {
Expand Down

0 comments on commit 6ccab5f

Please sign in to comment.