Skip to content
Snippets Groups Projects
Select Git revision
  • 6d06d1c5a4525696997c4d1d7d1d225895630fdb
  • master default protected
2 results

autotest.cmd

Blame
  • db.php 24.78 KiB
    <?php
    /**
     * ownCloud
     *
     * @author Frank Karlitschek
     * @copyright 2012 Frank Karlitschek frank@owncloud.org
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
     * License as published by the Free Software Foundation; either
     * version 3 of the License, or any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
     *
     * You should have received a copy of the GNU Affero General Public
     * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
     *
     */
    
    class DatabaseException extends Exception{
    	private $query;
    
    	public function __construct($message, $query){
    		parent::__construct($message);
    		$this->query = $query;
    	}
    
    	public function getQuery(){
    		return $this->query;
    	}
    }
    
    /**
     * This class manages the access to the database. It basically is a wrapper for
     * MDB2 with some adaptions.
     */
    class OC_DB {
    	const BACKEND_PDO=0;
    	const BACKEND_MDB2=1;
    
    	/**
    	 * @var MDB2_Driver_Common
    	 */
    	static private $connection; //the prefered connection to use, either PDO or MDB2
    	static private $backend=null;
    	/**
    	 * @var MDB2_Driver_Common
    	 */
    	static private $MDB2=null;
    	/**
    	 * @var PDO
    	 */
    	static private $PDO=null;
    	/**
    	 * @var MDB2_Schema
    	 */
    	static private $schema=null;
    	static private $inTransaction=false;
    	static private $prefix=null;
    	static private $type=null;
    
    	/**
    	 * check which backend we should use
    	 * @return int BACKEND_MDB2 or BACKEND_PDO
    	 */
    	private static function getDBBackend() {
    		//check if we can use PDO, else use MDB2 (installation always needs to be done my mdb2)