Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [propel-dev] Autoincrement information in 1.3.0RC1

Discussion topic

Back to topic list

[propel-dev] Autoincrement information in 1.3.0RC1


Author cyrille heulland <cheulland at gmail dot com>
Full name cyrille heulland <cheulland at gmail dot com>
Date 2008-07-28 01:13:01 PDT
Message Hi,

Oops ,I have sent my mail previous without all the changes we wanted to
report to you.
For development of generic component in our back office we have added the
possibility to know if a column is an autocincrement field by doing the
following changes:

In propel/map/TableMap, we have added autoincrement parameters at the end of
the methods addColumn and addPrimaryKey

public function addColumn($name, $phpName, $type, $isNotNull = false, $size
= null, $pk = null, $fkTable = null, $fkColumn = null,$autoincrement =
    $col = new ColumnMap($name, $this);

    if ($fkTable && $fkColumn) {

        if (substr($fkColumn, '.') > 0 && substr($fkColumn, $fkTable) !==
false) {

            $fkColumn = substr($fkColumn, strlen($fkTable) + 1);

        $col->setForeign​Key($fkTable, $fkColumn);






    $this->columns[$name] = $col;

    return $this->columns[$name];

public function addPrimaryKey($columnName, $phpName, $type, $isNotNull =
false, $size = null,$autoincrement = false)
    return $this->addColumn​($columnName, $phpName, $type, $isNotNull, $size,
true, null, null,$autoincrement);


We have done also the following changes in ColumMap in relation with
/** Is it a primary key? */
private $is_autoincrement = false;

 * Whether this column is auto increment
 * @return boolean
public function isAutoIncrement()
    return $this->is_autoincrement;

 * Set if this column is a autoincmrent
 * @param boolean $autoincrement True if column is a primary key.
 * @return void
public function setAutoIncrement($a​utoincrement)
    $this->is_autoincrement = $autoincrement;

And finally we change the following lines related to the previous changes in
propel/engine/builde​r/om/php5/PHP5MapBui​lderBuilder :
line 255: \$tMap->addPrim​aryKey('$cup', '$cfc', '".$col->getType()."',
".var_export($col-​>isNotNull(), true).",
".$size.",".($col-​>isAutoIncrement(​) ? 'true' : 'false').");
line 267: \$tMap->addColumn('$cup', '$cfc', '".$col->getType()."',
".var_export($col-​>isNotNull(), true).",
".$size.",".($col-​>isAutoIncrement(​) ? 'true' : 'false').");

I think it could be usefull to add directly those changes for autoincrement
field in Propel,


Cyrille Heulland

« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

[propel-dev] Autoincrement information in 1.3.0RC1 cyrille heulland <cheulland at gmail dot com> cyrille heulland <cheulland at gmail dot com> 2008-07-28 01:13:01 PDT
Messages per page: