PhalconException: Column type does not support scale parameter
when i try to find data from a model . how can i set the model's column 's scale.
the table include int ,double type.
CREATE TABLE `carddatalist` (
`dataseq` int(11) NOT NULL,
`data_type` varchar(255) DEFAULT NULL,
`brclvl` varchar(1) DEFAULT NULL,
`brc` varchar(8) DEFAULT NULL,
`desc1` varchar(16) DEFAULT NULL,
`desc2` varchar(32) DEFAULT NULL,
`numval` int(11) DEFAULT NULL,
`amtval` double(21,2) DEFAULT NULL,
`datatype2` varchar(2) DEFAULT NULL,
KEY `datalist_idx1` (`dataseq`,`brclvl`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
my model is simple:
class Carddatalist extends \Phalcon\Mvc\Model{
public function initialize()
{
$this->setConnectionService('mysql');
}
public function getSource(){
return "carddatalist";
}
}
i just Carddatalist:find(); in IndexController
PhalconException: Column type does not support scale parameter
i don's know how can i define the scale of column.
@dreamsxin could you please take a look?
OK, i test it.
I test in 1.3.0 it't OK, What version are you using?
INSERT INTO `phalcon_test`.`carddatalist` ( `data_type`, `brclvl`, `brc`, `desc1`, `desc2`, `numval`, `amtval`, `datatype2`)
VALUES ('data_type', 'v', 'brn', 'desc1', 'desc2', '1', '12345678.20', 'at');
Model
<?php
class Carddatalist extends Phalcon\Mvc\Model
{
public function getSource()
{
return 'carddatalist';
}
}
test code
$di = new Phalcon\DI();
$di->set('modelsManager', function(){
return new Phalcon\Mvc\Model\Manager();
});
$di->set('modelsMetadata', function(){
return new Phalcon\Mvc\Model\Metadata\Memory();
});
$di->set('db', function(){
return new Phalcon\Db\Adapter\Pdo\Mysql(array(
"adapter" => "mysql",
"host" => "localhost",
"username" => "root",
"password" => "",
"name" => "phalcon_test"
));
});
$test = Carddatalist::find();
var_dump($test->toArray());
resutl
array(2) {
[0] =>
array(9) {
'dataseq' =>
string(1) "0"
'data_type' =>
string(9) "data_type"
'brclvl' =>
string(1) "v"
'brc' =>
string(3) "brn"
'desc1' =>
string(5) "desc1"
'desc2' =>
string(5) "desc2"
'numval' =>
string(1) "1"
'amtval' =>
string(11) "12345678.20"
'datatype2' =>
string(2) "at"
}
[1] =>
array(9) {
'dataseq' =>
string(1) "0"
'data_type' =>
string(9) "data_type"
'brclvl' =>
string(1) "v"
'brc' =>
string(3) "brn"
'desc1' =>
string(5) "desc1"
'desc2' =>
string(5) "desc2"
'numval' =>
string(1) "1"
'amtval' =>
string(11) "12345678.20"
'datatype2' =>
string(2) "at"
}
}
Fixed in 1.3.0, please re-open this if it's still failing
This happen again in 2.0.0
@overbid Yes, I'm experiencing this bug as well with 2.0.0
Same here with 2.0.0. Phalcon is having an issue with one of the columns in my table being a double(11,1). My temporary workaround is to convert it to int(11) and live with it...
If you're comfortable compiling the extension from the .zep, you can add
/**
* Float/Smallfloats/Decimals are float
*/
if memstr(columnType, "double") {
let definition["type"] = Column::TYPE_DOUBLE,
definition["isNumeric"] = true,
definition["bindType"] = Column::TYPE_DOUBLE;
break;
}
at line ~197 of phalcon/db/adapter/pdo/mysql.zep until my pull request gets approved.
I still have this problem on 2.0.1.
Version 2.0.2 I have this problem:
I created a table:
CREATE TABLE razor.phalcon_test (
id INT NULL,
name VARCHAR(45) NOT NULL,
price DOUBLE(7,2) NULL,
agreement TINYINT(4) NULL,
PRIMARY KEY (id),
UNIQUE INDEX idphalcon_test_UNIQUE (id ASC));
Model not created and shows error: "Error: Column type does not support scale parameter"
When i change "price DOUBLE(7,2) NULL," to "price DOUBLE NULL," all right.
@commit aa12ad95bd4870af0a06003a22b9eab2e34a3115 It's same to me.
It's fix both master or 2.0.x branch.
The old error has appeared again, although the scale is present in the source texts: Phalcon version: 5.6.1 Column type does not support scale parameter file: phalcon/Db/Column.zep line: 398
The old error has appeared again, although the scale is present in the source texts: Phalcon version: 5.6.1 Column type does not support scale parameter file: phalcon/Db/Column.zep line: 398
Can you post an example please? This code has not been touched since 2019
Class example:
Call example:
Result:
Array ( [name] => id [caption] => ID [type] => hidden [size] => [scale] => [colspan] => 0 )
Column type does not support scale parameter
file: phalcon/Db/Column.zep
line: 398
They type you have there is hidden. That is not a recognized type for a column. If your type is numeric then it will go in that if block and will get the scale, otherwise it will show what you are seeing (the exception).
Thanks for the answer