1
無法動態創建表使用原則,我有插入,查詢更新,但我不能夠在數據庫中創建表,我試圖找到,但它顯示使用命令創建的錶行,我想用PHP腳本和動態如何在數據庫中動態創建表使用原則
這裏創建是我的代碼
<?php
//bootstrap.php
// I am able to fetch ,insert ,delete records from existing tables and wanted to
//know if there is any way i can create table using php script
// i am aware that we can create table using CMD but willing to create using only php scripts i.e Dynamically
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/entities/Users.php';
$paths = array(__DIR__ . '/entities');
$isDevMode = false;
$connectionParams = array(
'driver' => 'pdo_mysql',
'user' => 'root',
'host' => 'localhost',
'password' => '',
'dbname' => 'doctrine',
);
$config = Setup::createConfiguration($isDevMode);
$driver = new AnnotationDriver(new AnnotationReader(), $paths);
// registering noop annotation autoloader - allow all annotations by default
AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driver);
$em = EntityManager::create($connectionParams, $config);
$query = $em->createQuery('SELECT u.email, u.password FROM users u');
$users = $query->getResult(); // array of CmsUser username and name values
echo $users[0]['email'];
在哪裏,你的代碼,以便我們可以幫助您? –