diff options
| author | wei <> | 2007-04-12 12:43:49 +0000 | 
|---|---|---|
| committer | wei <> | 2007-04-12 12:43:49 +0000 | 
| commit | 32b73a0b1dfcd33e07e7fd2b2cf2fd7d42cf48a0 (patch) | |
| tree | bf2b348fa854d82dcf8a9f43ffd43df3eba5a1e8 /framework/Data/Common/Mysql/TMysqlTableColumn.php | |
| parent | 815ce4bcc616c4b0618046651174062efc93fd06 (diff) | |
Add Sqlite driver.
Diffstat (limited to 'framework/Data/Common/Mysql/TMysqlTableColumn.php')
| -rw-r--r-- | framework/Data/Common/Mysql/TMysqlTableColumn.php | 42 | 
1 files changed, 23 insertions, 19 deletions
| diff --git a/framework/Data/Common/Mysql/TMysqlTableColumn.php b/framework/Data/Common/Mysql/TMysqlTableColumn.php index 0f013acd..4f0f7da2 100644 --- a/framework/Data/Common/Mysql/TMysqlTableColumn.php +++ b/framework/Data/Common/Mysql/TMysqlTableColumn.php @@ -25,6 +25,29 @@ Prado::using('System.Data.Common.TDbTableColumn');   */
  class TMysqlTableColumn extends TDbTableColumn
  {
 +	private static $types = array(
 +		'integer' => array('bit', 'tinyint', 'smallint', 'mediumint', 'int', 'integer', 'bigint'),
 +		'boolean' => array('boolean', 'bool'),
 +		'float' => array('float', 'double', 'double precision', 'decimal', 'dec', 'numeric', 'fixed')
 +		);
 +
 +	/**
 +	 * Overrides parent implementation, returns PHP type from the db type.
 +	 * @return boolean derived PHP primitive type from the column db type.
 +	 */
 +	public function getPHPType()
 +	{
 +		$dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($this->getDbType())));
 +		if($dbtype==='tinyint' && $this->getColumnSize()===1)
 +			return 'boolean';
 +		foreach(self::$types as $type => $dbtypes)
 +		{
 +			if(in_array($dbtype, $dbtypes))
 +				return $type;
 +		}
 +		return 'string';
 +	}
 +
  	/**
  	 * @return boolean true if column will auto-increment when the column value is inserted as null.
  	 */
 @@ -45,25 +68,6 @@ class TMysqlTableColumn extends TDbTableColumn  	{
  		return $this->getInfo('DbTypeValues');
  	}
 -
 -	/**
 -	 * Overrides parent implementation, returns PHP type from the db type.
 -	 * @return boolean derived PHP primitive type from the column db type.
 -	 */
 -	public function getPHPType()
 -	{
 -		switch(strtolower($this->getDbType()))
 -		{
 -			case 'bit': case 'bit varying': case 'real': case 'serial': case 'int': case 'integer':
 -				return 'integer';
 -			case 'boolean':
 -				return 'boolean';
 -			case 'bigint': case 'bigserial': case 'double precision': case 'money': case 'numeric':
 -				return 'float';
 -			default:
 -				return 'string';
 -		}
 -	}
  }
  ?>
\ No newline at end of file | 
