/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/db.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/fboprime/db.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 11 months ago) by dashley
File size: 3734 byte(s)
Initial commit.
1 <?php
2 //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/db.inc,v 1.3 2006/04/25 16:53:39 dashley Exp $
3 //--------------------------------------------------------------------------------------------------------------
4 //db.inc--FboPrime Database Functions
5 //Copyright (C) 2006 David T. Ashley
6 //
7 //This program is free software; you can redistribute it and/or
8 //modify it under the terms of the GNU General Public License
9 //as published by the Free Software Foundation; either version 2
10 //of the License, or (at your option) any later version.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 //GNU General Public License for more details.
16 //
17 //You should have received a copy of the GNU General Public License
18 //along with this program; if not, write to the Free Software
19 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //********************************************************************************
21 //This contains constants and functions used to operate on the MySQL database
22 //as a whole.
23 //--------------------------------------------------------------------------------------------------------------
24 require_once("confighard.inc");
25 require_once("global.inc");
26 //--------------------------------------------------------------------------------------------------------------
27 //Locks all MySQL database tables in write mode (effectively locking the database). This is the only
28 //form of locking supported by FBO-Prime--all or nothing.
29 //
30 //Unit-tested 20060422.
31 //
32 function DB_db_lock()
33 {
34 global $GLOBAL_dbhandle;
35 global $CONFIGHARD_DBTABLES_ARRAY;
36
37 $c = count($CONFIGHARD_DBTABLES_ARRAY);
38 $query_string = "LOCK TABLES";
39 for ($i=0; $i<$c; $i++)
40 {
41 $query_string .= (" " . $CONFIGHARD_DBTABLES_ARRAY[$i] . " WRITE");
42 if ($i < ($c-1))
43 $query_string .= ",";
44 }
45
46 //echo " " . $query_string . " ";
47
48 mysql_query($query_string, $GLOBAL_dbhandle);
49 }
50 //
51 //--------------------------------------------------------------------------------------------------------------
52 //Unocks all MySQL database tables.
53 //
54 //Unit-tested 20060422.
55 //
56 function DB_db_unlock()
57 {
58 global $GLOBAL_dbhandle;
59
60 //In the case of the UNLOCK command, things are simpler. If the list of tables is omitted,
61 //everything is unlocked.
62 mysql_query("UNLOCK TABLES", $GLOBAL_dbhandle);
63 }
64 //
65 //--------------------------------------------------------------------------------------------------------------
66 //Performs the necessary shutdown actions in the event that the PHP script shuts down abnormally. At
67 //present, this consists only of unlocking the database tables. The FBO-Prime manual contains
68 //more information about locking, persistent connections, etc.
69 //
70 function DB_db_shutdown_func()
71 {
72 global $GLOBAL_dbhandle;
73
74 //If the global variable is FALSE, this is a signal that either the database connection
75 //could not be opened, or else that the connection has already been closed.
76 //
77 if ($GLOBAL_dbhandle !== FALSE)
78 {
79 //In the case of the UNLOCK command, things are simpler. If the list of tables is omitted,
80 //everything is unlocked.
81 mysql_query("UNLOCK TABLES", $GLOBAL_dbhandle);
82 }
83 }
84 //
85 //--------------------------------------------------------------------------------------------------------------
86 //End of $RCSfile: db.inc,v $.
87 //--------------------------------------------------------------------------------------------------------------
88 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25