我尝试在我的本地主机xampp上使用Kohana/ORM,得到以下错误
ErrorException注意事项:数组到字符串的转换MODPATH\orm\classes\kohana\orm.php 980
975 }
976 else
977 {
978 // List columns and mirror for performance
979 $this->_table_columns = $this->list_columns();
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);
981
982 // Load column cache
983 ORM::$_column_cache[$this->_object_name] = $this->_table_columns;
984 }
985 }这似乎是出现在不同框架/PHP应用程序中的常见错误,但我没有找到任何线索来修复它。
模型只是基本的ORM
class Model_Product extends ORM {
}Mysql表(InnoDB - UTF-8)有两个字段id - primary int name -varchar50
任何地方都没有巫毒,非常感谢你的帮助
提前感谢!
编辑:请求的vardump
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}发布于 2012-01-30 21:03:19
我找到了一种解决这个错误的方法,只需在模型中声明表列。
protected $_table_columns = array(
'column' => NULL,
'names' => NULL,
'go' => NULL,
'here' => NULL,
......
);这将解决问题并提高性能。
发布于 2011-12-02 01:09:30
第980行:
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);考虑到前一行979,看起来是多余的:
979 $this->_table_columns = $this->list_columns();合并两次相同的数组是没有用的,特别是在数组是这样的情况下:
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}它只包含字符串键。您应该使用kohana框架打开一个bug报告。
注释行980,直到这个get被修复。
https://stackoverflow.com/questions/8345114
复制相似问题