Development

Changeset 6005

You must first sign up to be able to contribute.

Changeset 6005

Show
Ignore:
Timestamp:
11/14/07 08:01:11 (1 year ago)
Author:
fabien
Message:

merged bug fixes from creole 1.1 + propel 1.2.1 (ported from the 1.0 branch)

  • fixed date / time handling in php 5.2.4
  • fixed limit support in mssql
  • fixed include call in get accessor for performance
  • incorporated typo fixes into propel (1.2 branch)
  • removed symfony propel patch
  • added symfony creole patch
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/Creole.php

    r1537 r6005  
    269269     * The format of the supplied DSN is in its fullest form: 
    270270     * 
    271      *  phptype://username:password@protocol+hostspec/database 
     271     *  phptype://username:password@hostspec/database 
    272272     * 
    273273     * Most variations are allowed: 
    274274     * 
    275      *  phptype://username:password@protocol+hostspec:110//usr/db_file.db 
     275     *  phptype://username:password@protocol(hostspec:110)//usr/db_file.db 
    276276     *  phptype://username:password@hostspec/database_name 
    277277     *  phptype://username:password@hostspec 
     
    301301        ); 
    302302 
    303         $info = parse_url($dsn); 
    304  
    305         if (count($info) === 1) { // if there's only one element in result, then it must be the phptype 
    306             $parsed['phptype'] = array_pop($info); 
    307             return $parsed; 
    308         } 
    309  
    310         // some values can be copied directly 
    311         $parsed['phptype'] = @$info['scheme']; 
    312         $parsed['username'] = @$info['user']; 
    313         $parsed['password'] = @$info['pass']; 
    314         $parsed['port'] = @$info['port']; 
    315  
    316         $host = @$info['host']; 
    317         if (false !== ($pluspos = strpos($host, '+'))) { 
    318             $parsed['protocol'] = substr($host,0,$pluspos); 
    319             if ($parsed['protocol'] === 'unix') { 
    320                 $parsed['socket'] = substr($host,$pluspos+1); 
    321             } else { 
    322                 $parsed['hostspec'] = substr($host,$pluspos+1); 
    323             } 
    324         } else { 
    325             $parsed['hostspec'] = $host; 
    326         } 
    327  
    328         if (isset($info['path'])) { 
    329             $parsed['database'] = substr($info['path'], 1); // remove first char, which is '/' 
    330         } 
    331  
    332         if (isset($info['query'])) { 
    333                 $opts = explode('&', $info['query']); 
    334                 foreach ($opts as $opt) { 
    335                     list($key, $value) = explode('=', $opt); 
    336                     if (!isset($parsed[$key])) { // don't allow params overwrite 
    337                         $parsed[$key] = urldecode($value); 
    338                     } 
    339                 } 
    340         } 
     303    $preg_query = "!^(([a-z0-9]+)(\(([^()]+)\))?)(://((((([^@/:]+)(:([^@/]+))?)@)?((([a-z]+)\((([^?():]+)(:([^()?]+))?)\))|((([^/?:]+)(:([^/?]+))?))))/?)?([^?]+)?(\?(.+))?)?$!i"; 
     304     
     305    $info = array(); 
     306     
     307    if (preg_match($preg_query,$dsn,$info)) { // only if it is matching 
     308             
     309      $parsed['phptype'] = @$info[2]; // Group 2 should always exist. 
     310       
     311      // Don't know what to do with Group 4: phptype(xx) should => check first if available 
     312       
     313      if (isset($info[5])) { // There is more than just the phptype 
     314         
     315        if (strlen($info[10]) > 0) { // There is a username specified 
     316          $parsed['username'] = @$info[10]; 
     317        } 
     318         
     319        if (strlen($info[12]) > 0) { // There is a password specified 
     320          $parsed['password'] = @$info[12]; 
     321        } 
     322         
     323        if (strlen($info[15]) > 0) { // There is a protocol specified: protocol(hostspec) 
     324          $parsed['protocol'] = @$info[15]; 
     325           
     326          if ($parsed["protocol"] === "unix") { 
     327            $parsed['socket'] = @$info[16]; 
     328          } else { 
     329            $parsed["hostspec"] = @$info[17]; 
     330            if (strlen($info[19]) > 0) { 
     331              $parsed["port"] = @$info[19]; 
     332            } 
     333          } 
     334        } elseif (strlen($info[20]) > 0) { 
     335          $parsed["hostspec"] = @$info[22]; 
     336           
     337          if ((isset($info[24]) && (strlen($info[24]) > 0))) { // There is a port set (not always available)  
     338            $parsed["port"] = @$info[24]; 
     339          } 
     340        } 
     341         
     342        if ((isset($info[25])) && (strlen($info[25]) > 0)) { // There is a database 
     343          $parsed["database"] = @$info[25]; 
     344        } 
     345         
     346        if ((isset($info[27])) && (strlen($info[27]) >0)) { // There is a query 
     347          $opts = explode('&', $info[27]); 
     348          foreach ($opts as $opt) { 
     349            list($key, $value) = explode('=', $opt); 
     350            if (!isset($parsed[$key])) { // don't allow params overwrite 
     351              $parsed[$key] = urldecode($value); 
     352            } 
     353          }  
     354        } 
     355         
     356      } 
     357    }  
    341358 
    342359        return $parsed; 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/CreoleTypes.php

    r1723 r6005  
    122122         * @return int Creole native type (e.g. Types::LONGVARCHAR, Types::BINARY, etc.). 
    123123         */ 
    124         public static function getType($nativeType) { 
    125           throw new Exception('This method must be overridden in subclasses!'); // abstract static not allowed since PHP 5.2 
    126         } 
     124        abstract static function getType($nativeType); 
    127125         
    128126        /** 
     
    133131         * @return string Native type string. 
    134132         */ 
    135         public static function getNativeType($creoleType) { 
    136            throw new Exception('This method must be overridden in subclasses!'); // abstract static not allowed since PHP 5.2 
    137         } 
     133        abstract static function getNativeType($creoleType); 
    138134         
    139135        /** 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mssql/MSSQLCallableStatement.php

    r2135 r6005  
    8989    public function __construct(Connection $conn, $stmt) 
    9090    { 
    91         print " - > IN CONSTRUCTOR \n"; 
    9291        $this->conn = $conn; 
    9392        $this->stmt = $stmt; 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mysql/MySQLResultSet.php

    r1723 r6005  
    9494    function close() 
    9595    {         
    96         if(is_resource($this->result)) 
    97             @mysql_free_result($this->result); 
     96        @mysql_free_result($this->result); 
    9897        $this->fields = array(); 
    9998    }     
     
    122121        if (is_int($column)) { $column--; } // because Java convention is to start at 1  
    123122        if (!array_key_exists($column, $this->fields)) { throw new SQLException("Invalid resultset column: " . (is_int($column) ? $column + 1 : $column)); } 
    124         if ($this->fields[$column] === null) { return null; } 
     123        if ($this->fields[$column] === null || $this->fields[$column] == '0000-00-00 00:00:00') { return null; } 
    125124         
    126125        $ts = strtotime($this->fields[$column]); 
     
    147146    } 
    148147 
     148    /** 
     149     * @see ResultSetCommon::getDate() 
     150     */ 
     151    public function getDate($column, $format = '%X') 
     152    { 
     153        /* As of PHP 5.2.4, strftime() returns false for '0000-00-00' which 
     154           is impossible to tell apart from illegal dates. (Pre-PHP 5.2.4 
     155           even interpreted such dates incorrectly, see  
     156           http://bugs.php.net/bug.php?id=41523). 
     157           We catch this special case and return null as the date here. 
     158           However, we need to know the exact format the DBMS returns this 
     159           date, which is why we make this decision here in the specific 
     160           driver before dispatching to the common implementation. */ 
     161        $idx = (is_int($column) ? $column - 1 : $column);         
     162        if (array_key_exists($idx, $this->fields) && $this->fields[$idx] == '0000-00-00') return null; 
     163        return parent::getDate($column, $format); 
     164    } 
     165 
    149166} 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mysqli/MySQLiConnection.php

    r2135 r6005  
    3333 */ 
    3434class MySQLiConnection extends ConnectionCommon implements Connection { 
    35     /** Current database (used in mysqli_select_db()). */ 
    36     private $database; 
    3735 
    3836    /** 
     
    8078    $conn = mysqli_connect($host, $user, $pw, $database, $port, $socket); 
    8179 
    82             @ini_restore('track_errors'); 
    83  
    84         if (empty($conn)) { 
     80        @ini_restore('track_errors'); 
     81 
     82        if (!$conn) { 
    8583            if (($err = @mysqli_error()) != '') { 
    8684                throw new SQLException("connect failed", $err); 
     
    9189            } 
    9290        } 
    93  
    94         if ($dsninfo['database']) { 
    95             if (!@mysqli_select_db($conn, $dsninfo['database'])) { 
    96                switch(mysqli_errno($conn)) { 
    97                         case 1049: 
    98                             $exc = new SQLException("no such database", mysqli_error($conn)); 
    99                         break; 
    100                         case 1044: 
    101                             $exc = new SQLException("access violation", mysqli_error($conn)); 
    102                         break; 
    103                         default: 
    104                            $exc = new SQLException("cannot select database", mysqli_error($conn)); 
    105                 } 
    106  
    107                 throw $exc; 
    108  
    109             } 
    110  
    111             // fix to allow calls to different databases in the same script 
    112             $this->database = $dsninfo['database']; 
    113         } 
    114  
     91         
    11592        $this->dblink = $conn; 
    11693 
     
    192169        $this->lastQuery = $sql; 
    193170 
    194         if ($this->database) { 
    195             if (!@mysqli_select_db($this->dblink, $this->database)) { 
    196                 throw new SQLException('No database selected', mysqli_error($this->dblink)); 
    197             } 
    198         } 
    199  
    200171        $result = @mysqli_query($this->dblink, $sql); 
    201172 
     
    214185        $this->lastQuery = $sql; 
    215186 
    216         if ($this->database) { 
    217             if (!@mysqli_select_db($this->dblink, $this->database)) { 
    218                     throw new SQLException('No database selected', mysqli_error($this->dblink)); 
    219             } 
    220         } 
    221  
    222187        $result = @mysqli_query($this->dblink, $sql); 
    223188 
     
    248213    protected function commitTrans() 
    249214    { 
    250         if ($this->database) { 
    251             if (!@mysqli_select_db($this->dblink, $this->database)) { 
    252                  throw new SQLException('No database selected', mysqli_error($this->dblink)); 
    253             } 
    254         } 
    255  
    256215        if (!mysqli_commit($this->dblink)) { 
    257216            throw new SQLException('Can not commit transaction', mysqli_error($this->dblink));                 
     
    268227    protected function rollbackTrans() 
    269228    { 
    270         if ($this->database) { 
    271             if (!@mysqli_select_db($this->dblink, $this->database)) { 
    272                 throw new SQLException('No database selected', mysqli_error($this->dblink)); 
    273             } 
    274         } 
    275  
    276229        if (!mysqli_rollback($this->dblink)) { 
    277230            throw new SQLException('Could not rollback transaction', mysqli_error($this->dblink)); 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/mysqli/metadata/MySQLiTableInfo.php

    r2135 r6005  
    3535        require_once 'creole/metadata/ColumnInfo.php'; 
    3636        require_once 'creole/drivers/mysql/MySQLTypes.php'; 
    37  
    38         if (!@mysqli_select_db($this->conn->getResource(), $this->dbname)) { 
    39             throw new SQLException('No database selected'); 
    40         } 
    4137 
    4238        // To get all of the attributes we need, we use 
     
    9187        } 
    9288 
    93         if (!@mysqli_select_db($this->conn->getResource(), $this->dbname)) { 
    94             throw new SQLException('No database selected'); 
    95         } 
    96  
    9789        // Primary Keys 
    9890        $res = mysqli_query($this->conn->getResource(), "SHOW KEYS FROM " . $this->name); 
     
    120112            $this->initColumns(); 
    121113        } 
    122  
    123         if (!@mysqli_select_db($this->conn->getResource(), $this->dbname)) { 
    124             throw new SQLException('No database selected'); 
    125         } 
    126  
     114         
    127115        // Indexes 
    128116        $res = mysqli_query($this->conn->getResource(), "SHOW INDEX FROM " . $this->name); 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/oracle/OCI8Connection.php

    r2135 r6005  
    7070        $pw           = $dsninfo[ 'password' ]; 
    7171        $hostspec       = $dsninfo[ 'hostspec' ]; 
    72         $port       = $dsninfo[ 'port' ]; 
    7372        $db         = $dsninfo[ 'database' ]; 
    7473 
     
    7675                  ? 'oci_pconnect' 
    7776                  : 'oci_connect'; 
     77     
    7878    $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null; 
    7979 
    8080    @ini_set( 'track_errors', true ); 
    81      
    82     if ( $hostspec && $port ) 
    83     { 
    84       $hostspec .= ':' . $port; 
    85     } 
    8681 
    8782        if ( $db && $hostspec && $user && $pw ) 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/oracle/OCI8Types.php

    r1723 r6005  
    4545                                'raw' => CreoleTypes::VARBINARY, 
    4646                                'longraw' => CreoleTypes::LONGVARBINARY, 
    47                                 'date' => CreoleTypes::DATE, 
    48                                 'timestamp' => CreoleTypes::TIMESTAMP, 
     47                                'date' => CreoleTypes::TIMESTAMP, 
    4948                                'blob' => CreoleTypes::BLOB, 
    5049                                'clob' => CreoleTypes::CLOB, 
     
    6362    public static function getType($nativeType) 
    6463    { 
    65         $t = str_replace(' ', '', strtolower($nativeType)); 
    66         if ( substr($t, 0, 9) == 'timestamp' ) return CreoleTypes::TIMESTAMP; 
     64        $t = strtolower($nativeType); 
    6765        if (isset(self::$typeMap[$t])) { 
    6866            return self::$typeMap[$t]; 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/pgsql/metadata/PgSQLDatabaseInfo.php

    r1404 r6005  
    5656        $result = null; 
    5757 
    58         $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 
    59                     WHERE relkind = 'r' AND relnamespace = (SELECT oid 
    60                     FROM pg_namespace 
    61                     WHERE 
    62                          nspname NOT IN ('information_schema','pg_catalog') 
    63                          AND nspname NOT LIKE 'pg_temp%' 
    64                          AND nspname NOT LIKE 'pg_toast%' 
    65                     LIMIT 1) 
    66                     ORDER BY relname"); 
     58        $result = pg_query($this->conn->getResource(), "SELECT c.oid,  
     59                            case when n.nspname='public' then c.relname else n.nspname||'.'||c.relname end as relname  
     60                            FROM pg_class c join pg_namespace n on (c.relnamespace=n.oid) 
     61                            WHERE c.relkind = 'r' 
     62                              AND n.nspname NOT IN ('information_schema','pg_catalog') 
     63                              AND n.nspname NOT LIKE 'pg_temp%' 
     64                              AND n.nspname NOT LIKE 'pg_toast%' 
     65                            ORDER BY relname"); 
    6766 
    6867        if (!$result) { 
     
    8887    $this->sequences = array(); 
    8988        
    90         $result = pg_query($this->conn->getResource(), "SELECT oid, relname FROM pg_class 
    91                     WHERE relkind = 'S' AND relnamespace = (SELECT oid 
    92                     FROM pg_namespace 
    93                     WHERE 
    94                          nspname NOT IN ('information_schema','pg_catalog') 
    95                          AND nspname NOT LIKE 'pg_temp%' 
    96                          AND nspname NOT LIKE 'pg_toast%' 
    97                     LIMIT 1) 
    98                     ORDER BY relname"); 
    99  
     89        $result = pg_query($this->conn->getResource(), "SELECT c.oid,  
     90                            case when n.nspname='public' then c.relname else n.nspname||'.'||c.relname end as relname  
     91                            FROM pg_class c join pg_namespace n on (c.relnamespace=n.oid) 
     92                            WHERE c.relkind = 'S' 
     93                              AND n.nspname NOT IN ('information_schema','pg_catalog') 
     94                              AND n.nspname NOT LIKE 'pg_temp%' 
     95                              AND n.nspname NOT LIKE 'pg_toast%' 
     96                            ORDER BY name"); 
     97                             
    10098        if (!$result) { 
    10199            throw new SQLException("Could not list sequences", pg_last_error($this->dblink)); 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/sqlite/SQLiteResultSet.php

    r1723 r6005  
    116116    { 
    117117        $this->fields = array(); 
    118         $this->result = null; 
    119118    } 
    120119} 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/drivers/sqlite/metadata/SQLiteTableInfo.php

    r2135 r6005  
    4343        // the second will fill in some more details. 
    4444         
    45         $sql = "PRAGMA table_info('".$this->name."')"
     45        $sql = 'PRAGMA table_info('.$this->name.')'
    4646                 
    4747        $res = sqlite_query($this->conn->getResource(), $sql); 
     
    6767                $type = $fulltype; 
    6868            } 
    69             // If column is primary key and of type INTEGER, it is auto increment 
    70             // See: http://sqlite.org/faq.html#q1 
    71             $is_auto_increment = ($row['pk'] == 1 && $fulltype == 'INTEGER'); 
     69             
    7270            $not_null = $row['notnull']; 
    7371            $is_nullable = !$not_null; 
     
    106104        if (!$this->colsLoaded) $this->initColumns();         
    107105 
    108         $sql = "PRAGMA index_list('".$this->name."')"
     106        $sql = 'PRAGMA index_list('.$this->name.')'
    109107        $res = sqlite_query($this->conn->getResource(), $sql); 
    110108         
     
    114112             
    115113            // get columns for that index 
    116             $res2 = sqlite_query($this->conn->getResource(), "PRAGMA index_info('$name')"); 
     114            $res2 = sqlite_query($this->conn->getResource(), 'PRAGMA index_info('.$name.')'); 
    117115            while($row2 = sqlite_fetch_array($res2, SQLITE_ASSOC)) { 
    118116                $colname = $row2['name']; 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/metadata/DatabaseInfo.php

    r1723 r6005  
    140140  public function hasTable($name) 
    141141  { 
    142     if(!$this->tablesLoaded) $this->initTables(); 
    143142    return isset($this->tables[strtoupper($name)]); 
    144143  } 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/creole/util/Clob.php

    r2135 r6005  
    7474            throw new Exception('No data to write to file'); 
    7575        } 
    76         $file = fopen($this->inFile, "wt"); 
    77         if (fputs($file, $this->data) === false) 
     76        $fp = fopen($this->outFile, "wt"); 
     77        if (fputs($fp, $this->data) === false) 
    7878            throw new Exception('Unable to write to file: '.$this->outFile); 
    7979        fclose($file); 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php

    r3753 r6005  
    22 
    33/* 
    4  *  $Id: PHP5ComplexObjectBuilder.php 536 2007-01-10 14:30:38Z heltem $ 
     4 *  $Id: PHP5ComplexObjectBuilder.php 706 2007-10-11 10:02:27Z heltem $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    377377  public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(\$con = null) 
    378378  { 
    379     // include the related Peer class 
    380     include_once '".$fkPeerBuilder->getClassFilePath()."'; 
    381  
    382379    if (\$this->$varName === null && ($conditional)) { 
     380      // include the related Peer class 
     381      include_once '".$fkPeerBuilder->getClassFilePath()."'; 
    383382"; 
    384383    $script .= " 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/AppData.php

    r3753 r6005  
    11<?php 
    22/* 
    3  *  $Id: AppData.php 536 2007-01-10 14:30:38Z heltem
     3 *  $Id: AppData.php 803 2007-11-13 21:24:21Z dwhittle
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3030 * @author     John McNally <jmcnally@collab.net> (Torque) 
    3131 * @author     Daniel Rall <dlr@finemaltcoding.com> (Torque) 
    32  * @version    $Revision: 536
     32 * @version    $Revision: 803
    3333 * @package    propel.engine.database.model 
    3434 */ 
     
    9696  public function getShortName() 
    9797  { 
    98     return str_replace("-schema", "", $name); 
     98    return str_replace("-schema", "", $this->name); 
    9999  } 
    100100 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php

    r3753 r6005  
    22 
    33/* 
    4  *  $Id: Table.php 536 2007-01-10 14:30:38Z heltem
     4 *  $Id: Table.php 803 2007-11-13 21:24:21Z dwhittle
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    4141 * @author     Daniel Rall <dlr@collab.net> (Torque) 
    4242 * @author     Byron Foster <byron_foster@yahoo.com> (Torque) 
    43  * @version    $Revision: 536
     43 * @version    $Revision: 803
    4444 * @package    propel.engine.database.model 
    4545 */ 
     
    10161016    if ($this->abstractValue) { 
    10171017      $result .= " abstract=\"" 
    1018           . ($abstractValue ? "true" : "false") 
     1018          . ($this->abstractValue ? "true" : "false") 
    10191019          . '"'; 
    10201020    } 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/phing/PropelSQLExec.php

    r3753 r6005  
    22 
    33/* 
    4  *  $Id: PropelSQLExec.php 536 2007-01-10 14:30:38Z heltem
     4 *  $Id: PropelSQLExec.php 803 2007-11-13 21:24:21Z dwhittle
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3737 * @author     Jason van Zyl <jvanzyl@apache.org> (Torque) 
    3838 * @author     Martin Poeschl <mpoeschl@marmot.at> (Torque) 
    39  * @version    $Revision: 536
     39 * @version    $Revision: 803
    4040 * @package    propel.phing 
    4141 */ 
     
    668668    if (!empty($this->tSqlCommand)) { 
    669669      $this->parent->log("Executing commands", PROJECT_MSG_INFO); 
    670       $this->parent->runStatements($tSqlCommand, $out); 
     670      $this->parent->runStatements($this->tSqlCommand, $out); 
    671671    } 
    672672 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/default.properties

    r3090 r6005  
    8282 
    8383propel.defaultTimeStampFormat = Y-m-d H:i:s 
    84 propel.defaultTimeFormat = H:i:s 
    85 propel.defaultDateFormat = Y-m-d 
     84propel.defaultTimeFormat = %X 
     85propel.defaultDateFormat = %x 
    8686 
    8787propel.omtar.src.base = false 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/pear/build-pear-package.xml

    r3755 r6005  
    2020 
    2121  <!-- some default properties --> 
    22   <property name="notes"><![CDATA[This is the a bugfix release to the 1.2 branch of the Propel Generator. 
    23 See: http://propel.phpdb.org/trac/query?status=closed&milestone=1.2.1&resolution=fixed&order=priority for CHANGELOG. 
    24   ]]></property> 
     22  <property name="notes">This is the latest snapshot of the Propel Generator.</property> 
    2523  <property name="state" value="devel"/> 
    2624 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel/Propel.php

    r3751 r6005  
    22 
    33/* 
    4  *  $Id: Propel.php 601 2007-03-07 13:23:12Z hans
     4 *  $Id: Propel.php 536 2007-01-10 14:30:38Z heltem
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3838 * @author     Henning P. Schmiedehausen <hps@intermeta.de> (Torque) 
    3939 * @author     Kurt Schrader <kschrader@karmalab.org> (Torque) 
    40  * @version    $Revision: 601
     40 * @version    $Revision: 536
    4141 * @package    propel 
    4242 */ 
     
    9191   * The Propel version. 
    9292   */ 
    93   const VERSION = '1.2.1'; 
     93  const VERSION = '1.2.1-dev'; 
    9494 
    9595  /** 
  • trunk/lib/plugins/sfPropelPlugin/lib/vendor/propel/adapter/DBMSSQL.php

    r3751 r6005  
    22 
    33/* 
    4  *  $Id: DBMSSQL.php 536 2007-01-10 14:30:38Z heltem $ 
    5  * 
    6  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    7  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    8  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    9  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    10  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    11  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    12  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    13  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    14  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    15  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    16  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    17  * 
    18  * This software consists of voluntary contributions made by many individuals 
    19  * and is licensed under the LGPL. For more information please see 
    20  * <http://propel.phpdb.org>. 
    21  */ 
    22  
    23 require_once 'propel/adapter/DBSybase.php'; 
     4*  $Id: DBMSSQL.php 800 2007-11-09 22:45:59Z justin $ 
     5
     6* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     7* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     8* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     9* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     10* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     11* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     12* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     13* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     14* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     15* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     16* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     17
     18* This software consists of voluntary contributions made by many individuals 
     19* and is licensed under the LGPL. For more information please see 
     20* <http://propel.phpdb.org>. 
     21*/ 
    2422 
    2523/** 
     
    2826 * 
    2927 * @author     Hans Lellelid <hans@xmpl.org> (Propel) 
    30  * @author     Gonzalo Diethelm <gonzalo.diethelm@sonda.com> (Torque) 
    31  * @version    $Revision: 536 $ 
     28 * @version    $Revision: 800 $ 
    3229 * @package    propel.adapter 
    3330 */ 
    3431class DBMSSQL extends DBSybase { 
    35   // no difference currently 
     32 
     33    /** 
     34    * Simulated Limit/Offset 
     35    * This rewrites the $sql query to apply the offset and limit. 
     36    * @see        DBAdapter::applyLimit() 
     37    * @author     Justin Carlson <justin.carlson@gmail.com> 
     38    */ 
     39    public function applyLimit(&$sql, $offset, $limit) 
     40    { 
     41        // make sure offset and limit are numeric 
     42        if(!is_numeric($offset) || !is_numeric($limit)){ 
     43            throw new Exception("DBMSSQL ::applyLimit() expects a number for argument 2 and 3"); 
     44        } 
     45 
     46        // obtain the original select statement 
     47        preg_match('/\A(.*)select(.*)from/si',$sql,$select_segment); 
     48        if(count($select_segment)>0) 
     49        { 
     50            $original_select = $select_segment[0]; 
     51        } else { 
     52            throw new Exception("DBMSSQL ::applyLimit() could not locate the select statement at the start of the query. "); 
     53        } 
     54        $modified_select = substr_replace($original_select, null, stristr($original_select,'select') , 6 ); 
     55 
     56        // obtain the original order by clause, or create one if there isn't one 
     57        preg_match('/order by(.*)\Z/si',$sql,$order_segment); 
     58        if(count($order_segment)>0) 
     59        { 
     60            $order_by = $order_segment[0]; 
     61        } else { 
     62 
     63            // no order by clause, if there are columns we can attempt to sort by the columns in the select statement 
     64            $select_items = split(',',$modified_select); 
     65            if(count($select_items)>0) 
     66            { 
     67                $item_number = 0; 
     68                $order_by = null; 
     69                while($order_by === null && $item_number<count($select_items)) 
     70                { 
     71                    if($select_items[$item_number]!='*' && !strstr($select_items[$item_number],'(')) 
     72                    { 
     73                        $order_by = 'order by ' . $select_items[0] . ' asc'; 
     74                    } 
     75                    $item_number++; 
     76                } 
     77            } 
     78            if($order_by === null) 
     79            { 
     80                throw new Exception("DBMSSQL ::applyLimit() could not locate the order by statement at the end of your query or any columns at the start of your query. "); 
     81            } else { 
     82                $sql.= ' ' . $order_by; 
     83            } 
     84 
     85        } 
     86 
     87        // remove the original select statement 
     88        $sql = str_replace($original_select , null, $sql); 
     89 
     90        /* modify the sort order by for paging */ 
     91        $inverted_order = ''; 
     92        $order_columns = split(',',str_ireplace('order by ','',$order_by)); 
     93        $original_order_by = $order_by; 
     94        $order_by = ''; 
     95        foreach($order_columns as $column) 
     96        { 
     97            // strip "table." from order by columns 
     98            $column = array_reverse(split("\.",$column)); 
     99            $column = $column[0]; 
     100 
     101            // commas if we have multiple sort columns 
     102            if(strlen($inverted_order)>0){ 
     103                $order_by.= ', '; 
     104                $inverted_order.=', '; 
     105            } 
     106 
     107            // put together order for paging wrapper 
     108            if(stristr($column,' desc')) 
     109            { 
     110                $order_by .= $column; 
     111                $inverted_order .= str_ireplace(' desc',' asc',$column); 
     112            } elseif(stristr($column,' asc')) { 
     113                $order_by .= $column; 
     114                $inverted_order .= str_ireplace(' asc',' desc',$column); 
     115            } else { 
     116                $order_by .= $column; 
     117                $inverted_order .= $column .' desc'; 
     118            } 
     119        } 
     120        $order_by = 'order by ' . $order_by; 
     121        $inverted_order = 'order by ' . $inverted_order; 
     122 
     123        // build the query 
     124        $offset = ($limit+$offset); 
     125        $modified_sql = 'select * from ('; 
     126        $modified_sql.= 'select top '.$limit.' * from ('; 
     127        $modified_sql.= 'select top '.$offset.' '.$modified_select.$sql; 
     128        $modified_sql.= ') deriveda '.$inverted_order.') derivedb '.$order_by; 
     129        $sql = $modified_sql; 
     130 
     131    } 
     132 
     133    public function random($seed=NULL) 
     134    { 
     135        return 'NEWID()'; 
     136    } 
     137 
    36138}