Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TMysqlTableColumn class file.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TMysqlTableColumn.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Data.Common.Mysql
11
 */
12
 
13
/**
14
 * Load common TDbTableCommon class.
15
 */
16
Prado::using('System.Data.Common.TDbTableColumn');
17
 
18
/**
19
 * Describes the column metadata of the schema for a Mysql database table.
20
 *
21
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
22
 * @version $Id: TMysqlTableColumn.php 2541 2008-10-21 15:05:13Z qiang.xue $
23
 * @package System.Data.Common.Mysql
24
 * @since 3.1
25
 */
26
class TMysqlTableColumn extends TDbTableColumn
27
{
28
	private static $types = array(
29
		'integer' => array('bit', 'tinyint', 'smallint', 'mediumint', 'int', 'integer', 'bigint'),
30
		'boolean' => array('boolean', 'bool'),
31
		'float' => array('float', 'double', 'double precision', 'decimal', 'dec', 'numeric', 'fixed')
32
		);
33
 
34
	/**
35
	 * Overrides parent implementation, returns PHP type from the db type.
36
	 * @return boolean derived PHP primitive type from the column db type.
37
	 */
38
	public function getPHPType()
39
	{
40
		$dbtype = trim(str_replace(array('unsigned', 'zerofill'),array('','',),strtolower($this->getDbType())));
41
		if($dbtype==='tinyint' && $this->getColumnSize()===1)
42
			return 'boolean';
43
		foreach(self::$types as $type => $dbtypes)
44
		{
45
			if(in_array($dbtype, $dbtypes))
46
				return $type;
47
		}
48
		return 'string';
49
	}
50
 
51
	/**
52
	 * @return boolean true if column will auto-increment when the column value is inserted as null.
53
	 */
54
	public function getAutoIncrement()
55
	{
56
		return $this->getInfo('AutoIncrement', false);
57
	}
58
 
59
	/**
60
	 * @return boolean true if auto increment is true.
61
	 */
62
	public function hasSequence()
63
	{
64
		return $this->getAutoIncrement();
65
	}
66
 
67
	public function getDbTypeValues()
68
	{
69
		return $this->getInfo('DbTypeValues');
70
	}
71
}
72