我正在用Doctrine 2.5.4和纯php 5编写我自己的CMS。在构建时,我反驳了这个错误:
致命错误:未捕获的异常'DoctrineDBALDBALException'与消息'未知数据库类型enum请求,DoctrineDBALPlatformsMySqlPlatform可能不支持它。'在/var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:423堆栈跟踪:#0/var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php(126): DoctrineDBALPlatformsAbstractPlatform->getDoctrineTypeMapping('enum') #1/var/www/html/xxxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(820):DoctrineDBALSchemaMySqlSchemaManager-> _getportabablecolumndefinition (Array) #2/var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(175): DoctrineDBALSchemaAbstractSchemaManager-> _getportabablecolumnlist ('bonus_top_.... . net', 'xxxx',数组)#3/var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(281)在/var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php第423行我的config . php:
<?php
ini_set("display_errors",true);
date_default_timezone_set("Asia/Hongkong");
define('TIMER_START', microtime( true ) );
define('DS', DIRECTORY_SEPARATOR );
define('ROOT_DIR', realpath( dirname( __FILE__ ) ). DS );
define('DAODIR', ROOT_DIR.'DAO'.DS );
define('MNGDIR', ROOT_DIR.'manager'.DS );
define('HDLDIR' , ROOT_DIR.'handler'.DS );
define('TPLDIR', ROOT_DIR.'template'.DS );
define('SKNDIR', TPLDIR.'skin'.DS );
define('MDLDIR', ROOT_DIR.'model'.DS );
define('DBN', 'xxxx' );
define('HOST', 'xxxx' );
define('USR', 'xxxx' );
define('PWD','xxxx');
require_once "vendor/autoload.php";
use DoctrineORMToolsSetup;
use DoctrineORMEntityManager;
$paths = array(MDLDIR);
$isDevMode = false;
// the connection configuration
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => HOST,
'user' => USR,
'password' => PWD,
'dbname' => DBN,
'charset' =>'utf8',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create($dbParams, $config);
?>
和my news.php
<?php
/**
* @Entity @Table(name="news")
*/
class News{
/**
* @nid @Column(type="integer") // **my id column is nid**
* @GeneratedValue
*/
public $id;
/** @author @Column(type="string")*/
public $author;
/** @date @Column(type="integer")*/
public $date;
/** @title @Column(type="string")*/
public $title;
/**@content @Column(type="text")*/
public $content;
/**@full @Column(type="text")*/
public $full;
/**@title_en @Column(type="string")*/
public $title_en;
/**@content_en @Column(type="text")*/
public $content_en;
/**@full_en @Column(type="text")*/
public $full_en;
/**@flink @Column(type="text")*/
public $flink;
/**@img @Column(type="text")*/
public $img;
}
?>
my table news
in mysql:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| nid | int(11) | NO | PRI | NULL | auto_increment |
| author | varchar(50) | NO | | | |
| date | int(11) | NO | | 0 | |
| title | varchar(255) | NO | | | |
| content | text | NO | | NULL | |
| full | text | NO | | NULL | |
| title_en | varchar(255) | NO | | | |
| content_en | text | NO | | NULL | |
| full_en | text | NO | | NULL | |
| flink | text | NO | | NULL | |
| img | text | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
我试图修复这篇文章,但没有工作。我做了这个链接的设置原则。我真的不知道为什么。请帮帮我。提前谢谢。
p/s:我不使用任何奇怪的类型,如enum....(新手T_T)。
由于数据库是我的公司而不是我的,我不知道学说会扫描我所有的数据库,但不像我为配置所做的那样(只有一个用于演示的数据表)。当我注意到这个错误时,我注意到了另一个表。
_getPortableTableColumnList('bonus_top_....', 'xxxx', Array) #3
所以我确实修复了这个表,它有enum类型。在供应商/理论/dbal/lib/理论/dbal/平台/MySqlPlatform.phpadd "enum" => 'string'
谢谢每一个人。很抱歉给你添麻烦了。