Development

Changeset 1310

You must first sign up to be able to contribute.

Changeset 1310

Show
Ignore:
Timestamp:
05/04/06 09:36:54 (3 years ago)
Author:
fabien
Message:

updated Propel and Creole

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/bin/build.xml

    r699 r1310  
    22 
    33<property name="project.dir" value="${application.startdir}/config" /> 
    4 <property name="propel.buildProperties" value="${propel_ini}" /> 
     4<property name="build.properties" value="${propel_ini}"/> 
    55 
    66<target name="build-om"> 
  • trunk/data/skeleton/project/config/propel.ini

    r695 r1310  
    3838propel.builder.nodepeerstub.class      = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder 
    3939 
     40propel.schema.validate = false 
  • trunk/lib/vendor/creole/drivers/oracle/OCI8Connection.php

    r497 r1310  
    7070        $pw           = $dsninfo[ 'password' ]; 
    7171        $hostspec       = $dsninfo[ 'hostspec' ]; 
     72        $db         = $dsninfo[ 'database' ]; 
    7273 
    7374        $connect_function   = ( $persistent ) 
     
    7778    @ini_set( 'track_errors', true ); 
    7879 
    79         if ( $hostspec && $user && $pw ) 
     80        if ( $db && $hostspec && $user && $pw ) 
     81  { 
     82      $conn       = @$connect_function( $user, $pw, "//$hostspec/$db" ); 
     83  } 
     84        elseif ( $hostspec && $user && $pw ) 
    8085    { 
    8186      $conn       = @$connect_function( $user, $pw, $hostspec ); 
  • trunk/lib/vendor/creole/drivers/oracle/OCI8PreparedStatement.php

    r497 r1310  
    11<?php 
    22/* 
    3  *  $Id: OCI8PreparedStatement.php,v 1.25 2005/11/21 17:54:11 sethr Exp $ 
     3 *  $Id: OCI8PreparedStatement.php,v 1.26 2006/01/30 21:32:05 sethr Exp $ 
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2828 * @author    David Giffin <david@giffin.org> 
    2929 * @author    Hans Lellelid <hans@xmpl.org> 
    30  * @version   $Revision: 1.25
     30 * @version   $Revision: 1.26
    3131 * @package   creole.drivers.oracle 
    3232 */ 
     
    6767     
    6868    /** 
    69      * ' -> '' 
     69     * Nothing to do - since oci_bind is used to insert data, no escaping is needed 
    7070     * @param string $str 
    7171     * @return string 
     
    7373    protected function escape($str) 
    7474    { 
    75         return str_replace("'","''", $str)
     75        return $str
    7676    } 
    7777 
     
    323323            // __toString() and is being passed to this method. 
    324324            if ( is_object ( $value ) ) { 
    325                 $this->boundInVars[$paramIndex] = $this->escape($value->__toString()); 
     325                $this->boundInVars[$paramIndex] = $value->__toString(); 
    326326            } else { 
    327                 $this->boundInVars[$paramIndex] = $this->escape((string)$value)
     327                $this->boundInVars[$paramIndex] = (string)$value
    328328            } 
    329329        } 
     
    346346            if (is_numeric($value)) $value = date('Y-m-d H:i:s', $value); 
    347347            elseif (is_object($value)) $value = date('Y-m-d H:i:s', $value->getTime()); 
    348             $this->boundInVars[$paramIndex] = $this->escape($value)
     348            $this->boundInVars[$paramIndex] = $value
    349349        } 
    350350    } 
     
    365365            if (is_numeric($value)) $value = date("Y-m-d", $value); 
    366366            elseif (is_object($value)) $value = date("Y-m-d", $value->getTime()); 
    367             $this->boundInVars[$paramIndex] = $this->escape($value)
     367            $this->boundInVars[$paramIndex] = $value
    368368        } 
    369369    } 
  • trunk/lib/vendor/propel-generator/CHANGELOG

    r1 r1310  
    33  ============================ 
    44 
     5 Feb ??, 2006 - 1.2.0 
     6 
     7  Breaking Changes: 
     8  *** New API for accessors and settors (see API docs).  The methods are the same 
     9  but the default indexing has changed. 
     10  *** New API for validators (see Wiki / docs). 
     11 
     12  Major Changes (for complete list see issue tracker at http://propel.phpdb.org): 
     13  - Propel now compatible w/ PHP >= 5.0.5 & 5.1.x 
     14  - New MySQLi driver for Propel (use 'mysqli' instead of 'mysql') 
     15  - Added propel-gen script to standard-installed versions of Propel also 
     16  - New XSD schema for validating the XML datamodel descriptions (schema.xml) 
     17  - Support for specifying vendor-specific info in the schema.xml 
     18  - Better support for sequences in reverse engineering PostgreSQL databases 
     19  - #146 Added 'size' attribute to <index-column> and <unique-column> 
     20  - New extensible OO builder classes for generating PHP5 classes and SQL DDL 
     21  - Identifier escaping in generated SQL (note: for Postgres this means columns 
     22    are case-sensitive) 
     23  - Numerous improvements to validation framework, including new, cleaner API 
     24  - Added doCountJoin*() methods to the generated Peer classes 
     25  - Obj->save() calls now return the number of affected rows (if supported by db) 
     26  - ... & numerous bug fixes which can be seen on the site issue tracker. 
     27 
    528 April 7, 2005 - 1.1.0 
    6    
     29 
    730  Big Changes: 
    831  *** Changed retrieveByPK() to return NULL instead of throw Exception if no row 
     
    1134  *** Dropped support for deprecated ini-format runtime properties file. (Hans) 
    1235  *** Cleanup of build properties files, removal of deprecated properties. (Hans) 
    13    
    14   New Features:   
     36 
     37  New Features: 
    1538  - Schema attributes are no longer case-sensitive. 
    1639  - New <vendor> tag allows specifying vendor-specific attributes. (Pavel) 
     
    2346  - Added PHPUnit2-based unit testing framework to replace old bookstore-test.php 
    2447  - Added schema validation / error throwing to schema parser. (Pavel) 
    25   - Logging is now optional (no log section means no logger used).  (David Z� 
    26   - Added TIMESTAMP_BU, DATE_BU types for "before-unix" (pre 1970) dates. (Hans) 
    27    
    28   Bug Fixes:   
     48  - Logging is now optional (no log section means no logger used).  (David Z�  - Added TIMESTAMP_BU, DATE_BU types for "before-unix" (pre 1970) dates. (Hans) 
     49 
     50  Bug Fixes: 
    2951  - Fixed E_STRICT error in generated Peer doCount() method (Hans) 
    3052  - Fixed bug when using doSelectJoin*() methods with tables that have lazyload columns. (Hans) 
  • trunk/lib/vendor/propel-generator/build-propel.xml

    r497 r1310  
    125125  </target> 
    126126 
     127  <!--  temporary target to check whether postgres is being used with identifier quoting ON. 
     128    If so, a warning is issued, since identifier quoting is only paritally implemented & this point.  --> 
     129  <target name="pgsql-quoting-check"> 
     130    <if> 
     131      <and> 
     132      <equals arg1="${propel.database}" arg2="pgsql"/> 
     133      <equals arg1="${propel.disableIdentifierQuoting}" arg2=""/> 
     134    </and> 
     135    <then> 
     136      <warn>ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on.</warn> 
     137      <warn>It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you</warn> 
     138      <warn>have case-sensitive columns in your database.</warn> 
     139      <warn></warn> 
     140      <warn>To disable identifier quoting, add the following property to your build.properties (or specify</warn> 
     141      <warn>it using -D on commandline):</warn> 
     142      <warn></warn> 
     143      <warn>propel.disableIdentifierQuoting=true</warn> 
     144      <warn></warn> 
     145      <warn>You can ignore this warning if you understand the issues related to case-sensitivity and Propel's</warn> 
     146      <warn>DDL-only implementation of identifier quoting.</warn> 
     147    </then> 
     148  </if> 
     149  </target> 
     150 
    127151  <target 
    128152    name="sql" 
    129     depends="sql-check
     153    depends="sql-check,pgsql-quoting-check
    130154    unless="propel.internal.sql.uptodate" 
    131155    description="==> generates the SQL for your project"> 
     
    143167  <target name="sql-template"> 
    144168    <propel-sql 
     169    validate="${propel.schema.validate}" 
     170    xsd="${propel.schema.xsd.file}" 
     171    xsl="${propel.schema.xsl.file}" 
    145172      outputDirectory="${propel.sql.dir}" 
    146173      sqldbmap="${propel.sql.dir}/sqldb.map" 
     
    157184  </target> 
    158185 
    159    
     186 
    160187  <target 
    161188    name="old-sql" 
     
    177204  <target name="old-sql-template"> 
    178205    <propel-old-sql 
     206    validate="${propel.schema.validate}" 
     207    xsd="${propel.schema.xsd.file}" 
     208    xsl="${propel.schema.xsl.file}" 
    179209      outputDirectory="${propel.sql.dir}" 
    180210      sqldbmap="${propel.sql.dir}/sqldb.map" 
     
    190220    </propel-old-sql> 
    191221  </target> 
    192    
     222 
    193223  <!-- ================================================================ --> 
    194224  <!-- C R E A T E  T A R G E T  D A T A B A S E                        --> 
     
    211241 
    212242    <propel-data-model 
     243    validate="${propel.schema.validate}" 
     244    xsd="${propel.schema.xsd.file}" 
     245    xsl="${propel.schema.xsl.file}" 
    213246      controlTemplate="${propel.template.sqlDbInit}" 
    214247      outputDirectory="${propel.sql.dir}" 
     
    295328 
    296329    <propel-data-sql 
     330    validate="${propel.schema.validate}" 
     331    xsd="${propel.schema.xsd.file}" 
     332    xsl="${propel.schema.xsl.file}" 
    297333      outputDirectory="${propel.sql.dir}" 
    298334      sqldbmap="${propel.sql.dir}/sqldb.map" 
     
    326362 
    327363    <propel-data-dump 
     364    validate="${propel.schema.validate}" 
     365    xsd="${propel.schema.xsd.file}" 
     366    xsl="${propel.schema.xsl.file}" 
    328367      targetDatabase="${propel.database}" 
    329368      datadbmap="${propel.schema.dir}/datadb.map" 
     
    358397 
    359398    <propel-data-dtd 
     399    validate="${propel.schema.validate}" 
     400    xsd="${propel.schema.xsd.file}" 
     401    xsl="${propel.schema.xsl.file}" 
    360402      targetDatabase="${propel.database}" 
    361403      outputDirectory="${propel.output.dir}" 
     
    407449  <target name="om-template"> 
    408450    <propel-om 
     451    validate="${propel.schema.validate}" 
     452    xsd="${propel.schema.xsd.file}" 
     453    xsl="${propel.schema.xsl.file}" 
    409454      outputDirectory="${propel.php.dir}" 
    410455      targetDatabase="${propel.database}" 
     
    442487  <target name="old-om-template"> 
    443488    <propel-old-om 
     489    validate="${propel.schema.validate}" 
     490    xsd="${propel.schema.xsd.file}" 
     491    xsl="${propel.schema.xsl.file}" 
    444492      outputDirectory="${propel.php.dir}" 
    445493      targetDatabase="${propel.database}" 
  • trunk/lib/vendor/propel-generator/build.xml

    r543 r1310  
    11<!-- 
    22    Use this file to faciliate easy per-project building. 
    3  
     3     
    44    Simply create a build.properties file in your project directory, 
    55    for example ./projects/bookstore/build.properties, that contains 
    66    any needed (i.e. to override) values for that project. 
    7  
     7     
    88    Call this build script and specify the name of the project and 
    99    (optionally) the name of the target you wish to execute (default is 
     
    1212    Normal use: 
    1313    $> phing   -Dproject=bookstore 
    14  
    15     Specific target: 
     14     
     15    Specific target:  
    1616    $> phing -Dproject=bookstore -Dtarget=insert-sql 
    1717 
     
    2121<!-- in case ${project.dir} was specified on command line, we set the project.dir 
    2222     property here.  If it wasn't set, then this will be bogus, but it will 
    23      be overridden by the "set-project-dir" target. --> 
     23     be overridden by the "set-project-dir" target. -->     
    2424<property name="propel.project.dir" value="${project.dir}"/> 
     25<resolvepath propertyName="propel.project.dir" file="${propel.project.dir}" dir="${application.startdir}"/> 
    2526 
    2627<!-- set a default target if none provided --> 
    2728<property name="target" value="main"/> 
    2829 
     30<!-- Set a default name for the build.properties file. 
     31    This allows for overriding the name of the build.properties file; however, 
     32    Propel still expects to find the file in the ${propel.project.dir}. 
     33 --> 
     34<property name="build.properties" value="build.properties"/> 
     35   
    2936<target name="check-buildprops-exists"> 
    30   <available file="${propel.project.dir}/${propel.buildProperties}" property="projBuildPopertiesExists"/> 
     37  <available file="${propel.project.dir}/${build.properties}" property="projBuildPopertiesExists"/>   
    3138</target> 
    3239 
    3340<target name="check-buildprops" unless="projBuildPopertiesExists" depends="check-buildprops-exists"> 
    3441    <echo message="====================================================="/> 
    35     <echo message="Could not open ${propel.buildProperties} file:"/> 
    36     <echo message="   ${propel.project.dir}/${propel.buildProperties}"/> 
     42    <echo message="Could not open ${build.properties} file:"/> 
     43    <echo message="   ${propel.project.dir}/${build.properties}"/> 
    3744    <echo message=" "/> 
    3845    <echo message="Make sure that '${propel.project.dir}' is a valid path"/> 
    39     <echo message="and that it contains a ${propel.buildProperties} file."/> 
    40     <echo message="====================================================="/> 
    41  
     46    <echo message="and that it contains a ${build.properties} file."/> 
     47    <echo message="====================================================="/>   
     48     
    4249    <fail message="Missing configuration file (see description above)."/> 
    4350</target> 
     
    5461<target name="check-buildprops-for-propel-gen" if="using.propel-gen" unless="projBuildPopertiesExists" depends="check-buildprops-exists"> 
    5562  <echo message="=========================================================="/> 
    56   <echo message="Could not open ${propel.buildProperties} file:"/> 
    57   <echo message="   ${propel.project.dir}/${propel.buildProperties}"/> 
     63  <echo message="Could not open ${build.properties} file:"/> 
     64  <echo message="   ${propel.project.dir}/${build.properties}"/> 
    5865  <echo message=" "/> 
    5966  <echo message="Project directory not specified or invalid. You must "/> 
    60   <echo message="specify the ABSOLUTE path to your project directory and "/> 
    61   <echo message="your project directory must contain your ${propel.buildProperties} "/> 
     67  <echo message="specify the path to your project directory and your "/> 
     68  <echo message="project directory must contain your ${build.properties} "/> 
    6269  <echo message="and schema.xml files.                                "/> 
    6370  <echo message=" "/> 
     
    6673  <echo message="$&gt; propel-gen /path/to/projectdir [target]"/> 
    6774  <echo message=" "/> 
    68   <echo message="=========================================================="/> 
    69   <fail message="No project directory specified (did you specify a relative path instead of absolute?)."/> 
     75  <echo message="=========================================================="/>  
     76  <fail message="No project directory specified."/> 
    7077</target> 
    7178 
     
    8491    <echo message=" "/> 
    8592    <echo message="-Dproject.dir=/path/to/bookstore"/> 
    86     <echo message="====================================================="/> 
     93    <echo message="====================================================="/>   
    8794    <input propertyname="project" promptChar=":">Project name</input> 
    8895    <property name="propel.project" value="${project}" override="true"/> 
     
    95102 
    96103<target name="configure" depends="set-project-dir,check-buildprops-for-propel-gen,check-buildprops"> 
    97   <echo msg="Loading project-specific props from ${propel.project.dir}/${propel.buildProperties}"/> 
    98   <property file="${propel.project.dir}/${propel.buildProperties}"/> 
     104  <echo msg="Loading project-specific props from ${propel.project.dir}/${build.properties}"/> 
     105  <property file="${propel.project.dir}/${build.properties}"/> 
    99106</target> 
    100107 
    101 <target name="main" depends="configure" description="The main target. Includes project-specific ${propel.buildProperties} and calls the build-propel.xml script"> 
     108<target name="main" depends="configure" description="The main target. Includes project-specific build.properties and calls the build-propel.xml script"> 
    102109 
    103  <!--<property file="${project.dir}/${propel.buildProperties}"/>--> 
    104110 <phing phingfile="./build-propel.xml" target="${target}"/> 
    105  
     111  
    106112</target> 
    107113 
    108 <!-- 
    109  Convenience mappings to build-propel.xml main targets 
    110  
     114<!--  
     115 Convenience mappings to build-propel.xml main targets  
     116  
    111117 This makes it possible to use this buildfile w/o needing to specify 
    112118 target as a property, e.g.: 
    113  
     119  
    114120 $> phing -Dproject=bookstore insert-sql 
    115  
     121  
    116122 The main reason for this is just consistency w/ old build-propel.xml file 
    117123 (primarily for documentation & user confusion avoidance reasons).  There are relatively 
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/DataModelBuilder.php

    r137 r1310  
    22 
    33/* 
    4  *  $Id: DataModelBuilder.php 258 2005-11-07 16:12:09Z hans $ 
     4 *  $Id: DataModelBuilder.php 351 2006-03-15 18:42:34Z hans $ 
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2424/** 
    2525 * This is the base class for any builder class that is using the data model. 
    26  *  
     26 * 
    2727 * This could be extended by classes that build SQL DDL, PHP classes, configuration 
    2828 * files, input forms, etc. 
    29  *  
    30  * This class has a static method to return the correct builder subclass identified by  
     29 * 
     30 * This class has a static method to return the correct builder subclass identified by 
    3131 * a given key.  Note that in order for this factory method to work, the properties have to have 
    3232 * been loaded first.  Usage should look something like this (from within a AbstractProelDataModelTask subclass): 
    33  *  
     33 * 
    3434 * <code> 
    3535 * DataModelBuilder::setBuildProperties($this->getPropelProperties()); 
     
    3737 * // $builder (by default) instanceof PHP5ComplexPeerBuilder 
    3838 * </code> 
    39  *  
     39 * 
    4040 * @author Hans Lellelid <hans@xmpl.org> 
    4141 * @package propel.engine.builder 
    4242 */ 
    4343abstract class DataModelBuilder { 
    44    
     44 
    4545  // -------------------------------------------------------------- 
    4646  // Static properties & methods 
    4747  // -------------------------------------------------------------- 
    48    
     48 
    4949  /** 
    5050   * Build properties (after they've been transformed from "propel.some.name" => "someName"). 
     
    5252   */ 
    5353  private static $buildProperties = array(); 
    54    
     54 
    5555  /** 
    5656   * Sets the [name transformed] build properties to use. 
     
    6161    self::$buildProperties = $props; 
    6262  } 
    63    
     63 
    6464  /** 
    6565   * Get a specific [name transformed] build property. 
     
    7171    return isset(self::$buildProperties[$name]) ? self::$buildProperties[$name] : null; 
    7272  } 
    73    
     73 
    7474  /** 
    7575   * Imports and returns the classname of the builder class for specified 'type'. 
     
    8484    $propname = 'builder' . ucfirst(strtolower($type)) . 'Class'; 
    8585    $classpath = self::getBuildProperty($propname); 
    86        
     86 
    8787    if (empty($classpath)) { 
    8888      throw new BuildException("Unable to find class path for '$propname' property."); 
    8989    } 
    90        
     90 
    9191    // This is a slight hack to workaround camel case inconsistencies for the DDL classes. 
    9292    // Basically, we want to turn ?.?.?.sqliteDDLBuilder into ?.?.?.SqliteDDLBuilder 
     
    9494    if ($lastdotpos) $classpath{$lastdotpos+1} = strtoupper($classpath{$lastdotpos+1}); 
    9595    else ucfirst($classpath); 
    96      
     96 
    9797    return Phing::import($classpath); 
    9898  } 
    99    
     99 
    100100  /** 
    101101   * Factory method to load a new builder instance based on specified type. 
     
    109109    return new $classname($table); 
    110110  } 
    111    
     111 
    112112  /** 
    113113     * Utility function to build a path for use in include()/require() statement. 
    114      *  
     114     * 
    115115     * Supports two function signatures: 
    116116     * (1) getFilePath($dotPathClass); 
    117117     * (2) getFilePath($dotPathPrefix, $className); 
    118      *  
     118     * 
    119119     * @param string $path dot-path to class or to package prefix. 
    120120     * @param string $classname class name 
     
    131131        } 
    132132    } 
    133    
     133 
    134134  // -------------------------------------------------------------- 
    135135  // Non-static properties & methods inherited by subclasses 
     
    140140   * @var Table 
    141141   */ 
    142   private $table;   
     142  private $table; 
    143143 
    144144  /** 
     
    147147   */ 
    148148  private $warnings = array(); 
    149    
     149 
    150150  /** 
    151151   * Creates new instance of DataModelBuilder subclass. 
     
    156156    $this->table = $table; 
    157157  } 
    158    
     158 
    159159  /** 
    160160   * Returns the Platform class for this table (database). 
     
    165165    return $this->getTable()->getDatabase()->getPlatform(); 
    166166  } 
    167    
     167 
    168168  /** 
    169169   * Returns the database for current table. 
     
    174174    return $this->getTable()->getDatabase(); 
    175175  } 
    176    
     176 
    177177  /** 
    178178   * Returns the current Table object. 
     
    182182  { 
    183183    return $this->table; 
    184   }   
    185    
     184  } 
     185 
    186186  /** 
    187187   * Pushes a message onto the stack of warnings. 
     
    192192    $this->warnings[] = $msg; 
    193193  } 
    194    
     194 
    195195  /** 
    196196   * Gets array of warning messages. 
     
    201201    return $this->warnings; 
    202202  } 
     203 
     204  /** 
     205   * Wraps call to Platform->quoteIdentifier() with a check to see whether quoting is enabled. 
     206   * 
     207   * All subclasses should call this quoteIdentifier() method rather than calling the Platform 
     208   * method directly.  This method is used by both DataSQLBuilder and DDLBuilder, and potentially 
     209   * in the OM builders also, which is why it is defined in this class. 
     210   * 
     211   * @param string $text The text to quote. 
     212   * @return string Quoted text. 
     213   */ 
     214  public function quoteIdentifier($text) 
     215  { 
     216    if (!self::getBuildProperty('disableIdentifierQuoting')) { 
     217      return $this->getPlatform()->quoteIdentifier($text); 
     218    } 
     219    return $text; 
     220  } 
    203221} 
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php

    r497 r1310  
    22 
    33/* 
    4  *  $Id: PHP5BasicPeerBuilder.php 306 2005-12-19 20:57:11Z hans
     4 *  $Id: PHP5BasicPeerBuilder.php 358 2006-04-18 17:40:40Z oliver
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    404404  /** A key representing a particular subclass */ 
    405405  const CLASSKEY_".strtoupper($child->getKey())." = '" . $child->getKey() . "'; 
     406 
     407        /** A key representing a particular subclass */ 
     408        const CLASSKEY_".strtoupper($child->getClassName())." = '" . $child->getKey() . "'; 
    406409 
    407410  /** A class that can be returned by this peer. */ 
     
    13371340 
    13381341    \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); 
    1339         return !empty(\$v) > 0 ? \$v[0] : null; 
     1342 
     1343    return !empty(\$v) > 0 ? \$v[0] : null; 
    13401344  } 
    13411345"; 
     
    14401444    $script .= " 
    14411445    \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con); 
    1442         return !empty(\$v) ? \$v[0] : null; 
     1446 
     1447    return !empty(\$v) ? \$v[0] : null; 
    14431448  }"; 
    14441449  } 
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php

    r497 r1310  
    22 
    33/* 
    4  *  $Id: PHP5ComplexObjectBuilder.php 324 2006-01-06 14:30:01Z hans
     4 *  $Id: PHP5ComplexObjectBuilder.php 346 2006-03-01 16:46:49Z soenke
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    12281228"; 
    12291229      foreach ($table->getReferrers() as $fk) { 
    1230         //HL: commenting out self-referrential check below 
    1231         //    it seems to work as expected and is probably desireable to have those referrers from same table deep-copied. 
    1232         //if ( $fk->getTable()->getName() != $table->getName() ) { 
    1233           $script .= " 
     1230        // Continue if $this and $copyObj are the same class and have the same primary key 
     1231        // to avoid endless loops 
     1232        $script .= " 
    12341233      foreach(\$this->get".$this->getRefFKPhpNameAffix($fk, true)."() as \$relObj) { 
    1235         if(\$relObj !== \$this) {  // ensure that we don't try to copy a reference to ourselves 
    1236           \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy))
     1234        if(\$copyObj instanceof self && \$this->getPrimaryKey() === \$relObj->getPrimaryKey()) { 
     1235          continue
    12371236        } 
     1237        \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy)); 
    12381238      } 
    12391239"; 
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5MultiExtendObjectBuilder.php

    r137 r1310  
    110110  protected function getParentClassFilePath() 
    111111  { 
    112     $this->getFilePath($this->getParentClasspath()); 
     112    return $this->getFilePath($this->getParentClasspath()); 
    113113  } 
    114114   
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/sql/DDLBuilder.php

    r137 r1310  
    2525/** 
    2626 * Baseclass for SQL DDL-building classes. 
    27  *  
     27 * 
    2828 * DDL-building classes are those that build all the SQL DDL for a single table. 
    29  *  
     29 * 
    3030 * @author Hans Lellelid <hans@xmpl.org> 
    3131 * @package propel.engine.builder.sql 
    3232 */ 
    33 abstract class DDLBuilder extends DataModelBuilder {  
     33abstract class DDLBuilder extends DataModelBuilder { 
    3434 
    3535  /** 
    3636   * Builds the SQL for current table and returns it as a string. 
    37    *  
    38    * This is the main entry point and defines a basic structure that classes should follow.  
     37   * 
     38   * This is the main entry point and defines a basic structure that classes should follow. 
    3939   * In most cases this method will not need to be overridden by subclasses. 
    40    *  
     40   * 
    4141   * @return string The resulting SQL DDL. 
    4242   */ 
     
    4949    return $script; 
    5050  } 
    51    
     51 
     52  /** 
     53   * Builds the DDL SQL for a Column object. 
     54   * @return string 
     55   */ 
     56  public function getColumnDDL(Column $col) 
     57  { 
     58    $platform = $this->getPlatform(); 
     59    $domain = $col->getDomain(); 
     60 
     61    $sb = ""; 
     62    $sb .= $this->quoteIdentifier($col->getName()) . " "; 
     63    $sb .= $domain->getSqlType(); 
     64    if ($platform->hasSize($domain->getSqlType())) { 
     65      $sb .= $domain->printSize(); 
     66    } 
     67    $sb .= " "; 
     68    $sb .= $col->getDefaultSetting() . " "; 
     69    $sb .= $col->getNotNullString() . " "; 
     70    $sb .= $col->getAutoIncrementString(); 
     71 
     72    return trim($sb); 
     73  } 
     74 
     75  /** 
     76   * Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier(). 
     77   * @param array Column[] or string[] 
     78   * @param string $delim The delimiter to use in separating the column names. 
     79   * @return string 
     80   */ 
     81  public function getColumnList($columns, $delim=',') 
     82  { 
     83    $list = array(); 
     84    foreach($columns as $col) { 
     85      if ($col instanceof Column) { 
     86        $col = $col->getName(); 
     87      } 
     88      $list[] = $this->quoteIdentifier($col); 
     89    } 
     90    return implode($delim, $list); 
     91  } 
     92 
    5293  /** 
    5394   * This function adds any _database_ start/initialization SQL. 
     
    59100    return ''; 
    60101  } 
    61    
     102 
    62103  /** 
    63104   * This function adds any _database_ end/cleanup SQL. 
     
    69110    return ''; 
    70111  } 
    71    
     112 
    72113  /** 
    73114   * Adds table definition. 
     
    81122   */ 
    82123  abstract protected function addIndices(&$script); 
    83    
     124 
    84125  /** 
    85126   * Adds foreign key constraint definitions. 
     
    87128   */ 
    88129  abstract protected function addForeignKeys(&$script); 
    89    
     130 
    90131} 
  • trunk/lib/vendor/propel-generator/classes/propel/engine/builder/sql/DataSQLBuilder.php

    r497 r1310  
    2525/** 
    2626 * Baseclass for SQL data dump SQL building classes. 
    27  *  
     27 * 
    2828 * @author Hans Lellelid <hans@xmpl.org> 
    2929 * @package propel.engine.builder.sql 
    3030 */ 
    3131abstract class DataSQLBuilder extends DataModelBuilder { 
    32    
     32 
    3333  /** 
    3434   * The main method in this class, returns the SQL for INSERTing data into a row. 
     
    4141    $platform = $this->getPlatform(); 
    4242    $table = $this->getTable(); 
    43      
    44     $sql .= "INSERT INTO ".$this->getPlatform()->quoteIdentifier($this->getTable()->getName())." (";    
    45      
     43 
     44    $sql .= "INSERT INTO ".$this->quoteIdentifier($this->getTable()->getName())." ("; 
     45 
    4646    // add column names to SQL 
    4747    $colNames = array(); 
    4848    foreach ($row->getColumnValues() as $colValue) { 
    49       $colNames[] = $platform->quoteIdentifier($colValue->getColumn()->getName()); 
    50     } 
    51      
     49      $colNames[] = $this->quoteIdentifier($colValue->getColumn()->getName()); 
     50    } 
     51 
    5252    $sql .= implode(',', $colNames); 
    53      
     53 
    5454    $sql .= ") VALUES ("; 
    55      
     55 
    5656    $colVals = array(); 
    5757    foreach ($row->getColumnValues() as $colValue) { 
    5858      $colVals[] = $this->getColumnValueSql($colValue); 
    5959    } 
    60      
    61     $sql .= implode(',', $colVals);     
     60 
     61    $sql .= implode(',', $colVals); 
    6262    $sql .= "); 
    6363"; 
    64      
     64 
    6565    return $sql; 
    6666  } 
    67    
     67 
    6868  /** 
    6969   * Gets the propertly escaped (and quoted) value for a column. 
     
    7575    $column = $colValue->getColumn(); 
    7676    $creoleTypeString = PropelTypes::getCreoleType($column->getPropelType()); 
    77     $creoleTypeCode = CreoleTypes::getCreoleCode($creoleTypeString);    
     77    $creoleTypeCode = CreoleTypes::getCreoleCode($creoleTypeString); 
    7878    $method = 'get' . CreoleTypes::getAffix($creoleTypeCode) . 'Sql'; 
    7979    return $this->$method($colValue->getValue()); 
    8080  } 
    81    
    82    
    83    
     81 
     82 
     83 
    8484  /** 
    8585     * Gets a representation of a binary value suitable for use in a SQL statement. 
     
    8888     * @return int 
    8989     */ 
    90     protected function getBooleanSql($value)  
    91     {       
     90    protected function getBooleanSql($value) 
     91    { 
    9292    return (int) $value; 
    9393    } 
    94      
     94 
    9595 
    9696    /** 
     
    9999   * @return string 
    100100     */ 
    101     protected function getBlobSql($blob)  
    102     {         
     101    protected function getBlobSql($blob) 
     102    { 
    103103        // they took magic __toString() out of PHP5.0.0; this sucks 
    104104    if (is_object($blob)) { 
     
    107107      return "'" . $this->escape($blob) . "'"; 
    108108    } 
    109     }