Source for file ColumnMap.php
Documentation is available at ColumnMap.php
* $Id: ColumnMap.php 784 2007-11-08 10:15:50Z heltem $
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
* ColumnMap is used to model a column of a table in a database.
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @version $Revision: 784 $
/** @var string Propel type of the column. */
/** Size of the column. */
/** Is it a primary key? */
/** Is null value allowed ?*/
private $notNull = false;
/** The default value for this column. */
/** Name of the table that this column is related to. */
private $relatedTableName = "";
/** Name of the column that this column is related to. */
private $relatedColumnName = "";
/** The TableMap for this column. */
/** The name of the column. */
/** The php name of the column. */
/** validators for this column */
private $validators = array();
* @param string $name The name of the column.
* @param TableMap containingTable TableMap of the table this column is in.
public function __construct($name, TableMap $containingTable)
$this->columnName = $name;
$this->table = $containingTable;
* Gets column name (DEPRECATED).
* @deprecated Use getName() instead.
* Get the name of a column.
* @return string A String with the column name.
return $this->columnName;
* Get the name of a column.
* @return string A String with the column name.
* Set the php anme of this column.
* @param string $phpName A string representing the PHP name.
$this->phpName = $phpName;
* Get the table name + column name.
* @return string A String with the full column name.
return $this->table->getName() . "." . $this->columnName;
* Get the table map this column belongs to.
* Get the name of the table this column is in.
* @return string A String with the table name.
return $this->table->getName();
* Get the Propel type of this column.
* @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE).
* Set the Propel type of this column.
* @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE).
* Get the PHP type of this column.
* @return int The PDO::PARMA_* value
public function getPhpType()
return PropelColumnTypes::getPhpType($this->type);
* Get the PDO type of this column.
* @return int The PDO::PARMA_* value
* Whether this is a BLOB, LONGVARBINARY, or VARBINARY.
* Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970).
* PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate
* between epoch and pre-epoch timestamps.
* @deprecated Propel supports non-epoch dates
* Whether this column is numeric (int, decimal, bigint etc).
* Whether this is a DATE/TIME/TIMESTAMP column.
* Whether this column is a text column (varchar, char, longvarchar).
* Set the size of this column.
* @param int $size An int specifying the size.
* Set if this column is a primary key or not.
* @param boolean $pk True if column is a primary key.
* Set if this column may be null.
* @param boolean nn True if column may be null.
* Gets the default value for this column.
* @return mixed String or NULL
return $this->defaultValue;
* Set the foreign key for this column.
* @param string tableName The name of the table that is foreign.
* @param string columnName The name of the column that is foreign.
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
$this->relatedTableName = "";
$this->relatedColumnName = "";
$this->validators[] = $validator;
return count($this->validators) > 0;
return $this->validators;
* Get the size of this column.
* @return int An int specifying the size.
* Is this column a primary key?
* @return boolean True if column is a primary key.
* Is null value allowed ?
* @return boolean True if column may not be null.
* Is this column a foreign key?
* @return boolean True if column is a foreign key.
if ($this->relatedTableName) {
* Get the table.column that this column is related to.
* @return string A String with the full name for the related column.
return $this->relatedTableName . "." . $this->relatedColumnName;
* Get the table name that this column is related to.
* @return string A String with the name for the related table.
return $this->relatedTableName;
* Get the column name that this column is related to.
* @return string A String with the name for the related column.
return $this->relatedColumnName;
* Performs DB-specific ignore case, but only if the column type necessitates it.
* @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name).
return $db->ignoreCase($str);
|