protected $_name;
protected $_type;
protected $_null;
- protected $_primary;
protected $_limit;
protected $_precision;
protected $_scale;
* @param string $sqlType Only used to extract the column's length, if necessary. For example +60+ in <tt>company_name varchar(60)</tt>.
* @param boolean $null Determines if this column allows +NULL+ values.
*/
- public function __construct($name, $default, $sqlType=null, $null=true)
+ public function __construct($name, $default, $sqlType = null, $null = true)
{
$this->_name = $name;
$this->_sqlType = $sqlType;
$this->_scale = $this->_extractScale($sqlType);
$this->_type = $this->_simplifiedType($sqlType);
$this->_default = $this->extractDefault($default);
- $this->_primary = false;
$this->_isText = $this->_type == 'text' || $this->_type == 'string';
$this->_isNumber = $this->_type == 'float' || $this->_type == 'integer' || $this->_type == 'decimal';
return $this->_sqlType;
}
- /**
- * @return mixed
- */
- public function isPrimary()
- {
- return $this->_primary;
- }
-
- /**
- * @param boolean
- */
- public function setPrimary($primary)
- {
- $this->_primary = $primary;
- }
-
/*##########################################################################
# Type Juggling
if (empty($string)) { return null; }
// preserve '0000-00-00' (http://bugs.php.net/bug.php?id=45647)
- if (preg_replace('/[^\d]/', '', $string) == 0) {
- return '0000-00-00';
+ if (preg_replace('/[^\d]/', '', $string) == 0) {
+ return '0000-00-00';
}
return date('Y-m-d', strtotime($string));
if (empty($string)) { return null; }
// preserve '0000-00-00 00:00:00' (http://bugs.php.net/bug.php?id=45647)
- if (preg_replace('/[^\d]/', '', $string) == 0) {
- return '0000-00-00 00:00:00';
+ if (preg_replace('/[^\d]/', '', $string) == 0) {
+ return '0000-00-00 00:00:00';
}
return date('Y-m-d H:i:s', strtotime($string));
$this->assertEquals('string', $col->getType());
}
- /*##########################################################################
- # Primary
- ##########################################################################*/
-
- public function testPrimary()
- {
- $col = new Horde_Db_Adapter_Mysql_Column('id', 'NULL', 'int(11)');
- $this->assertFalse($col->isPrimary());
-
- $col->setPrimary(true);
- $this->assertTrue($col->isPrimary());
- }
/*##########################################################################
# Extract Limit
$this->assertEquals('string', $col->getType());
}
- /*##########################################################################
- # Primary
- ##########################################################################*/
-
- public function testPrimary()
- {
- $col = new Horde_Db_Adapter_Postgresql_Column('id', 'NULL', 'int(11)');
- $this->assertFalse($col->isPrimary());
-
- $col->setPrimary(true);
- $this->assertTrue($col->isPrimary());
- }
/*##########################################################################
# Extract Limit
$this->assertEquals('string', $col->getType());
}
- /*##########################################################################
- # Primary
- ##########################################################################*/
-
- public function testPrimary()
- {
- $col = new Horde_Db_Adapter_Sqlite_Column('id', 'NULL', 'int(11)');
- $this->assertFalse($col->isPrimary());
-
- $col->setPrimary(true);
- $this->assertTrue($col->isPrimary());
- }
/*##########################################################################
# Extract Limit