[Solar-talk] Re: Solar_Sql function _getTypeSizeScope returns incorrect type

Pierre Oztel pierre.oztel at gmail.com
Mon Jul 2 16:02:42 CDT 2007


I am also wondering how to use the Solar_Sql $_cols property.

Actually, any values affected to $_cols['colname']['default'] are ignored by
the old _buildColDef() or the new _sqlColDef () method.

On line 1856 from file Adapter.php, we have :

$coldef .= ($require) ? ' NOT NULL' : ' NULL';
//added lines
$default = $this->quote($default);
$coldef .= ($this->notEmpty()) ? " DEFAULT '$default" : '';

Some help with this problem ?



2007/7/2, Pierre Oztel <pierre.oztel at gmail.com>:
>
> The function Solar_Sql::_getSolarType returns incorrect types for PDO
> mysql driver.
>
> I tested it with this schema:
>
> CREATE TABLE `bookmark` (
>   `id` int(11) NOT NULL auto_increment,
>   `url` varchar(255) NOT NULL,
>   `name` varchar(255) NOT NULL,
>   `description` mediumtext,
>   `tag` varchar(255) default NULL,
>   `created` datetime NOT NULL,
>   `updated` datetime NOT NULL,
>   PRIMARY KEY  (`id`),
>   KEY `name` (`name`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
>
> --
> -- Dumping data for table `bookmark`
> --
>
> INSERT INTO `bookmark` (`id`, `url`, `name`, `description`, `tag`,
> `created`, `updated`) VALUES
> (1, 'http1', 'name1', 'descr1', 'tag1', '2007-06-23 17:28:52', '2007-06-23
> 17:28:52'),
> (2, 'http2', 'name2', 'descr2', 'tag2', '2007-06-23 17:28:52', '2007-06-23
> 17:28:52'),
> (3, 'http3', 'name3', 'descr3', 'tag3', '2007-06-23 17:28:52', '2007-06-23
> 17:28:52'),
> (4, 'http4', 'name4', 'descr4', 'tag4', '2007-06-23 17:28:52', '2007-06-23
> 17:28:52'),
> (5, 'http5', 'name5', 'descr5', 'tag5', '2007-06-23 17:28:52', '2007-06-23
> 17:28:52');
>
>
> Solar_Sql::fetchTableCols() return the following:
>
>
> *array
> *
>   'id' =>
>     *array*
>       'name' => string 'id' *(length=2)*
>
>       'type' => string 'int' *(length=3)*
>       'size' => string
> '11' *(length=2)*
>       'scope' => null
>       'default' => null
>       'require' => boolean true
>       'primary' => boolean
> true
>       'autoinc' => boolean true
>   'url' =>
>     *array*
>       'name'
> => string 'url' *(length=3)*
>       'type' => string
> 'varchar' *(length=7)*
>       'size' => string '255' *(length=3)*
>       'scope'
> => null
>       'default' => string '' *(length=0)*
>       'require'
> => boolean true
>       'primary' => boolean false
>       'autoinc'
> => boolean false
>   'name' =>
>     *array*
>       'name' => string
>  'name' *(length=4)*
>       'type' => string 'varchar' *(length=7)*
>       'size'
> => string '255' *(length=3)*
>       'scope' => null
>       'default'
> => string '' *(length=0)*
>       'require' => boolean
> true
>       'primary' => boolean false
>       'autoinc' => boolean
> false
>   'description' =>
>     *array*
>       'name' => string 'description'
>  *(length=11)*
>       'type' => string 'mediumtext' *(length=10)*
>       'size' =>
>  null
>       'scope' => null
>       'default' => null
>
>       'require' => boolean false
>       'primary' => boolean
> false
>       'autoinc' => boolean false
>   'tag' =>
>     *array*
>       'name'
> => string 'tag' *(length=3)*
>       'type' => string
> 'varchar' *(length=7)*
>       'size' => string '255' *(length=3)*
>       'scope'
> => null
>       'default' => null
>       'require' => boolean
>  false
>       'primary' => boolean false
>       'autoinc' =>
> boolean false
>   'created' =>
>     *array*
>       'name' => string
> 'created' *(length=7)*
>       'type' => string 'integer' *(length=7)*
>       'size'
> => null
>       'scope' => null
>       'default' => string
>  '' *(length=0)*
>       'require' => boolean true
>       'primary'
> => boolean false
>       'autoinc' => boolean false
>   'updated'
> =>
>     *array*
>       'name' => string 'updated' *(length=7)*
>       'type'
> => string 'integer' *(length=7)*
>       'size' => null
>       'scope'
> => null
>       'default' => string '' *(length=0)*
>       'require'
> => boolean true
>       'primary' => boolean false
>       'autoinc'
> => boolean false
>
>
>
> As such declared 'datetime' fields are recognized as 'integer';
>
>
> A little modification in the getSolarType makes it works:
>
> ---
> function _getSolarType() {
> if(array_key_exists($type, $this->_describe)) {
>  $type = $this->_describe[$type];
> }
> return $type;
> }
> ---
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20070702/df6ec231/attachment-0001.html


More information about the Solar-talk mailing list