Changeset 465 for trunk/lib/DB.inc.php
- Timestamp:
- Feb 18, 2014 8:18:46 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/DB.inc.php
r419 r465 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 37 37 // Database handle. 38 38 var $dbh; 39 39 40 40 // Count how many queries run during the whole instance. 41 41 var $_query_count = 0; … … 58 58 // Display db errors. FALSE recommended for production sites. 59 59 'db_debug' => false, 60 60 61 61 // Script stops on db error. TRUE recommended for production sites. 62 62 'db_die_on_failure' => true, … … 101 101 { 102 102 $app =& App::getInstance(); 103 103 104 104 if (isset($params) && is_array($params)) { 105 105 // Merge new parameters with old overriding only those passed. … … 120 120 { 121 121 $app =& App::getInstance(); 122 122 123 123 if (isset($this->_params[$param])) { 124 124 return $this->_params[$param]; … … 139 139 { 140 140 $app =& App::getInstance(); 141 141 142 142 if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) { 143 143 $app->logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); … … 193 193 return mysql_close($this->dbh); 194 194 } 195 195 196 196 /* 197 * 197 * 198 198 * 199 199 * @access public 200 * @param 201 * @return 200 * @param 201 * @return 202 202 * @author Quinn Comendant <quinn@strangecode.com> 203 203 * @version 1.0 … … 209 209 $this->connect(); 210 210 } 211 211 212 212 /* 213 213 * Die only if db_die_on_failure is true. This will be set to false for some cases … … 260 260 return (true === $this->_connected); 261 261 } 262 262 263 263 /** 264 264 * Returns a properly escaped string using mysql_real_escape_string() with the current connection's charset. … … 288 288 */ 289 289 function query($query, $debug=false) 290 { 290 { 291 291 $app =& App::getInstance(); 292 292 … … 301 301 echo "<!-- ----------------- Query $this->_query_count ---------------------\n$debugqry\n-->\n"; 302 302 } 303 304 // Ensure we have an active connection. 303 304 // Ensure we have an active connection. 305 305 // If we continue on a dead connection we might experience a "MySQL server has gone away" error. 306 306 // http://dev.mysql.com/doc/refman/5.0/en/gone-away.html … … 318 318 if ($this->getParam('db_debug')) { 319 319 echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>'; 320 } 320 } 321 321 // Die if db_die_on_failure = true, or just continue without connection 322 322 return $this->_fail(); … … 339 339 { 340 340 $app =& App::getInstance(); 341 341 342 342 if (!$this->_connected) { 343 343 return false; … … 406 406 } 407 407 } 408 408 409 409 /* 410 410 * Return the total number of queries executed thus far.
Note: See TracChangeset
for help on using the changeset viewer.