Reputation: 471
I have started working on a Symfony 2.3 project where I need to convert a financial website written in classic Asp to Php.
The client has Ms-Sql database which is to be used with Symfony 2.3 and doctrine, I have made the database and loaded the empty tables from the schema files.
Now whenever i try to generate entities from the database(Ms-Sql) I get the following error:
Doctrine\DBAL\DBALException Unknown database type timestamp requested, Doctrine\DBAL\Platforms\SQLServer2008Platform may not support it
Does anyone know how to solve the problem or what should I do to avoid such a situation?
Kindly help me as I am new to Symfony 2.3, Thank you
Upvotes: 4
Views: 2399
Reputation: 11
The configuration below works on Synfony 3.2
1) in config.yml add the new type under types and map it under mssql connection
# Doctrine Configuration
doctrine:
dbal:
types:
timestamp: AppBundle\Type\Timestamp
..
..
connections:
mssql:
driver: sqlsrv
host: "%mssql_host%"
port: "%mssql_port%"
dbname: "%mssql_db_name%"
user: "%mssql_user%"
password: "%mssql_password%"
mapping_types:
timestamp: timestamp
2) Create the class AppBundle\Type\Timestamp as for the following url:
3) generate entities from the database with the following command:
php bin/console doctrine:mapping:import --force AppBundle xml --em=mssql
Upvotes: 0
Reputation: 2263
You can add your own types following doctrine doc about the subject :
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/mysql-enums.html
this is concerning enum type but you can use it with any type like timestamp and link it to string type or whatever other supported type by your database which fit you best.
public function boot()
{
$em = $this->container->get('doctrine.orm.entity_manager');
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('timestamp','string');
}
and normally all your timestamp types should be translated as string.
Upvotes: 4