Changeset 11

Show
Ignore:
Timestamp:
07/17/08 21:10:08 (4 months ago)
Author:
gevik
Message:

-- ADD common files to index.php
-- UPD application.xml with common database module
-- REM CDatabaseBase.php class doc
-- MOV CDatabase.php to common
-- ADD CUser.php and CUserManager.php
-- ADD schema/postgresql/core.sql
-- ADD test CUserManagerTest.php

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/shop/admin/index.php

    r3 r11  
    1818require_once('../common/CDatabaseBase.php'); 
    1919require_once('../common/Helper.php'); 
     20require_once('../common/CUserManager.php'); 
     21require_once('../common/CUser.php'); 
    2022 
    2123$application=new TApplication; 
  • trunk/shop/admin/protected/application.xml

    r3 r11  
    88        </paths> 
    99        <modules> 
    10                 <module id="datasource" class="System.Data.TDataSourceConfig"> 
    11                         <database ConnectionString="pgsql:host=localhost;dbname=bvjobs" 
    12                                 username="postgres" password="postgres" /> 
     10                <module id="database" class="CDatabase" 
     11                                                ServerType="PostgreSQL"  
     12                                                Host="localhost" 
     13                                                Database="test" 
     14                                                Username="postgres" 
     15                                                Password="postgres"/>    
    1316                </module>        
    1417        </modules> 
     
    1619                <service id="page" class="TPageService" BasePath="Application" DefaultPage="Pages.Home"> 
    1720                        <modules> 
    18                                 <module id="data" class="Application.Engine.CDatabase"/> 
    1921                                <!-- 
    2022                                <module id="users" class="Application.Engine.CUserManager" /> 
  • trunk/shop/common/CDatabaseBase.php

    r4 r11  
    1515  * 
    1616  */ 
    17  class CDatabaseBase extends TModule 
     17class CDatabaseBase extends TModule 
    1818{ 
    1919        private $connection; 
     
    2323        private $password; 
    2424        private $database; 
    25          
    26         /** 
    27          * @return string database name 
    28          */ 
     25        private $debug_sql; 
     26         
     27         
     28        public function GetDebugSQL() 
     29        { 
     30                return $this->debug_sql; 
     31        } 
     32         
    2933        public function getDatabase() 
    3034        { 
     
    3236        } 
    3337         
    34         /** 
    35          * @param string value database name 
    36          */ 
    3738        public function setDatabase($value) 
    3839        { 
    3940                $this->database = $value; 
    4041        } 
    41          
    42          
    43         /** 
    44          * @return string password value 
    45          */ 
     42                 
    4643        public function getPassword() 
    4744        { 
     
    4946        } 
    5047         
    51         /** 
    52          * @param object password value 
    53          */ 
    5448        public function setPassword($value) 
    5549        { 
     
    5751        } 
    5852         
    59         /** 
    60          * @return string username value 
    61          */ 
    6253        public function getUsername() 
    6354        { 
     
    6556        } 
    6657         
    67         /** 
    68          * @param string username value 
    69          */ 
    7058        public function setUsername($value) 
    7159        { 
     
    7361        } 
    7462         
    75         /** 
    76          * @return string host value 
    77          */ 
    7863        public function getHost() 
    7964        { 
     
    8166        } 
    8267         
    83         /** 
    84          * @param string host value 
    85          */ 
    8668        public function setHost($value) 
    8769        { 
     
    8971        } 
    9072                 
    91         /** 
    92          * @return string server type value 
    93          */ 
    9473        public function getServerType() 
    9574        { 
     
    9776        } 
    9877                 
    99         /** 
    100          * Allowed server types are "PostgreSQL" and "MySQL" 
    101          * @param string server type value 
    102          */ 
    10378        public function setServerType($value) 
    10479        { 
     
    11691        } 
    11792         
    118         /** 
    119          * Creates a database connection based on ServerType 
    120          */ 
    12193        private function create_connection() 
    12294        { 
     
    140112        } 
    141113         
    142         /** 
    143          * Performs a SQL query with paramsters 
    144          * @param string sql 
    145          * @param array params 
    146          * @return array array[row][column] containing only the first row of the query data  
    147          */ 
    148114        public function queryRow($sql,$params=null) 
    149115        { 
     
    161127        } 
    162128         
    163         /** 
    164          * Performs a SQL query with paramsters 
    165          * @param string sql 
    166          * @param array params 
    167          * @return array array[row][column] containing the query data  
    168          */ 
    169129        public function queryAll($sql,$params=null) 
    170130        { 
     
    180140        } 
    181141         
    182         /** 
    183          * Performs a SQL query with paramsters 
    184          * @param string sql 
    185          * @param array params 
    186          * @return mixed single value from the first column of the first row 
    187          */ 
    188142        public function queryScalar($sql,$params=null) 
    189143        { 
     
    200154        } 
    201155                 
    202         /** 
    203          * Performs a SQL query with paramsters 
    204          * <code> 
    205          * $result = query("SELECT * FROM table1 WHERE field1 = $1 AND field2 = $2",array(100,'value1')); 
    206          * </code> 
    207          * @param string sql 
    208          * @param array params 
    209          * @return resource database query result resource, not an array! 
    210          */ 
    211156        public function query($sql,$params=null) 
    212157        { 
    213                         if($this->server_type == "postgresql") 
    214                         { 
     158                $this->debug_sql = $sql; 
     159                if($this->server_type == "postgresql") 
     160                { 
    215161                if($params != null) 
    216162                { 
     
    219165                                                $params[$k] = ($v === true ?  't':'f'); 
    220166                  return pg_query_params($this->connection,$sql,$params); 
    221              
     167             
    222168                else 
    223169                { 
    224170                  return pg_query($this->connection,$sql); 
    225              
     171             
    226172            } 
    227173            else if($this->server_type == "mysql") 
  • trunk/shop/tests/UnitTests/application.xml

    r3 r11  
    33<application id="UnitTests" mode="Debug"> 
    44        <modules> 
    5                 <module id="datasource" class="System.Data.TDataSourceConfig"> 
    6                         <database/> 
    7                 </module> 
    85                <module id="postgres" class="CDatabase"  
    96                                                                                        ServerType="PostgreSQL"  
     
    1411                                                                                        />                       
    1512                                                                                         
    16                                                                                          
     13                <module id="database" class="CDatabase"  
     14                                                                                        ServerType="PostgreSQL"  
     15                                                                                        Host="localhost" 
     16                                                                                        Database="test" 
     17                                                                                        Username="postgres" 
     18                                                                                        Password="postgres" 
     19                                                                                        />       
     20                                                                                                                                                                                 
    1721                <module id="mysql" class="CDatabase"  
    1822                                                                                        ServerType="MySQL"  
     
    2327                                                                                        />                       
    2428                                                                                         
     29       <module id="users" class="CUserManager" /> 
     30       <module id="auth" class="System.Security.TAuthManager" UserManager="users" LoginPage="Engine.Login" />         
    2531                                                                                         
    2632        </modules> 
  • trunk/shop/tests/UnitTests/index.php

    r3 r11  
    44require_once('../../common/Helper.php'); 
    55require_once('../../common/CDatabaseBase.php'); 
    6 require_once('../../admin/protected/Engine/CDatabase.php'); 
     6require_once('../../common/CDatabase.php'); 
     7require_once('../../common/CUserManager.php'); 
     8require_once('../../common/CUser.php'); 
     9 
    710 
    811$test_cases = dirname(__FILE__)."/"; 
  • trunk/shop/tests/test_tools/unit_tests.php

    r3 r11  
    1313 
    1414require_once(PRADO_FRAMEWORK.'/prado.php'); 
     15 
     16$global_db_core_exists = false; 
    1517 
    1618class TestFolder