0
votes

I'm writing my own CMS with Doctrine 2.5.4 and pure php 5. while building, i countered this error:

Fatal error: Uncaught exception 'Doctrine\DBAL\DBALException' with message 'Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.' in /var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:423 Stack trace: #0 /var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php(126): Doctrine\DBAL\Platforms\AbstractPlatform->getDoctrineTypeMapping('enum') #1 /var/www/html/xxxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(820): Doctrine\DBAL\Schema\MySqlSchemaManager->_getPortableTableColumnDefinition(Array) #2 /var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(175): Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList('bonus_top_....', 'xxxx', Array) #3 /var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php(281) in /var/www/html/xxxx.com/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php on line 423 my 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 Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

$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);    
?>

and 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    |                |
+------------+--------------+------+-----+---------+----------------+

I tried to fix as this article but did not work. I did as this link for setup doctrine. I really have no idea why. Please help me. Thanks in advance.

P/s: I don't use any strange type like enum....(newbie T_T).

1
I don't think the problem is connected to the code you've posted. There should be something else. I believe there is some table with enum type usedDmitry Malyshenko

1 Answers

1
votes

Due to the database is my company not mine, I did not know that doctrine would scan all my database but not as i did for config ( only a datat able for demo). When i noticed that the error noticed me another table.

_getPortableTableColumnList('bonus_top_....', 'xxxx', Array) #3 

So i did fix this table, which has enum type. In vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php add "enum" => 'string'

Thank everyone. And sorry for making troubling.