root/ez_publish/ezipb/trunk/classes/ezipsclass.php

Revision 19, 4.3 KB (checked in by llaumgui, 16 months ago)

Cosmétique

Line 
1<?php
2/*
3 * #################### BEGIN LICENSE BLOCK ####################
4 * This file is part of ezipb.
5 * Copyright (c) 2007 llaumgui and contributors. All
6 * rights reserved.
7 *
8 * ezipb is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * ezipb is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
16 * the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with ezipb; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA  02111-1307  USA
22 * or visit http://www.gnu.org/licenses/gpl.html
23 * ###################### END LICENSE BLOCK ####################
24 *
25 * Class ezipsclass qui hérite de l'ipsclass tout en l'alégeant.
26 *
27 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>
28 * @version 1.0
29 */
30
31require_once IPB_PATH . 'sources/ipsclass.php';
32
33class ezipsclass extends ipsclass {
34   
35   
36   
37    /**
38     * RécupÚre la connection eZ publish dans IPB ! ! !
39     */
40    function init_db_connection() {
41       
42        //$_pre_load = $this->memory_debug_make_flag();
43       
44        $this->vars['sql_driver'] = ! $this->vars['sql_driver'] ? 'mysql' : strtolower($this->vars['sql_driver']);
45       
46        if ( ! class_exists( 'db_main' ) ) {
47            require_once( KERNEL_PATH.'class_db.php' );
48            if ( $this->ezipbIni->variable( "ezipb", "USE_UNIQUE_CONNECTION" ) == "enabled" )
49                require_once eZExtension::baseDirectory() . '/ezipb/classes/sql/ezipb_db_'.$this->vars['sql_driver'].".php";
50            else
51                require_once( KERNEL_PATH.'class_db_'.$this->vars['sql_driver'].".php" );
52        }
53       
54        $classname = "db_driver_".$this->vars['sql_driver'];
55        if ( $this->ezipbIni->variable( "ezipb", "USE_UNIQUE_CONNECTION" ) == "enabled" )
56            $classname = "ezipb_" . $classname;
57       
58        $this->DB = new $classname;
59       
60        $this->DB->obj['sql_database']         = $this->vars['sql_database'];
61        $this->DB->obj['sql_user']             = $this->vars['sql_user'];
62        $this->DB->obj['sql_pass']             = $this->vars['sql_pass'];
63        $this->DB->obj['sql_host']             = $this->vars['sql_host'];
64        $this->DB->obj['sql_tbl_prefix']       = $this->vars['sql_tbl_prefix'];
65        $this->DB->obj['force_new_connection'] = isset($this->vars['sql_force_new_connection']) ? $this->vars['sql_force_new_connection'] : 0;
66        $this->DB->obj['use_shutdown']         = USE_SHUTDOWN;
67        //$this->DB->obj['error_log']            = ROOT_PATH . 'cache/sql_error_log_'.date('m_d_y').'.cgi';
68        $this->DB->obj['use_error_log']        = 0;
69        //$this->DB->obj['debug_log']            = ROOT_PATH . 'cache/sql_debug_log_'.date('m_d_y').'.cgi';
70        $this->DB->obj['use_debug_log']        = 0;
71       
72
73        /* Load query file */
74        if ( defined( 'IPB_LOAD_SQL' ) )
75            $this->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$this->vars['sql_driver'].'_'. IPB_LOAD_SQL .'.php';
76        else if ( IPB_THIS_SCRIPT == 'admin' )
77            $this->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$this->vars['sql_driver'].'_admin_queries.php';
78        else
79            $this->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$this->vars['sql_driver'].'_queries.php';
80           
81        /* Required vars? */
82        if ( is_array( $this->DB->connect_vars ) and count( $this->DB->connect_vars ) ) {
83            foreach( $this->DB->connect_vars as $k => $v ) {
84                $this->DB->connect_vars[ $k ] = isset($this->vars[ $k ]) ? $this->vars[ $k ] : '';
85            }
86        }
87       
88        /* Backwards compat */
89        if ( !isset($this->DB->connect_vars['mysql_tbl_type']) OR !$this->DB->connect_vars['mysql_tbl_type'] )
90            $this->DB->connect_vars['mysql_tbl_type'] = 'myisam';
91       
92        /* Make CONSTANT */
93        define( 'SQL_PREFIX'              , $this->DB->obj['sql_tbl_prefix'] );
94        define( 'SQL_DRIVER'              , $this->vars['sql_driver']        );
95        define( 'IPS_MAIN_DB_CLASS_LOADED', TRUE );
96       
97        /* Get a DB connection */
98        $this->DB->connect();
99       
100        /* IPS DB LOADED */
101        if ( ! defined( 'IPSCLASS_DB_LOADED' ) )
102            define( 'IPSCLASS_DB_LOADED', 1 );
103       
104        /* Clean up */
105        unset( $classname );
106       
107        //$this->memory_debug_add( "CORE: DB Connection Made", $_pre_load );
108    }
109   
110}    // EOC
111
112?>
Note: See TracBrowser for help on using the browser.