-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconnection.php
36 lines (31 loc) · 942 Bytes
/
connection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once __DIR__.'/vendor/autoload.php';
$config=new Doctrine\DBAL\Configuration();
$cred=array(
'dbname'=>'dbExam1',
'user'=>'root',
'password'=>'123',
'host'=>'localhost',
'driver'=>'pdo_mysql',
);
$con= \Doctrine\DBAL\DriverManager::getConnection($cred,$config);
$qb=$con->createQueryBuilder();
$col=array('ssn','profname');
$qb->select($col)->from('Professor');
$stmt=$qb->execute();
//$prof=$con->fetchAll('SELECT * FROM Professor');
$qb2=$con->createQueryBuilder();
//$qb2->insert('copy')->values(array('id'=>'?','name'=>'?'))->setParameter(0,1)->setParameter(1,'Bala');
//$qb2->execute();
while($row=$stmt->fetch()){
$qb2=$con->createQueryBuilder();
$col2=array('id','name');
$values=array_values($row);
$insertArray=array_combine($col2,$values);
$con->insert('copy',$insertArray);
print_r($insertArray);
echo '<br/>';
// $qb2->insert('copy')->values($insertArray);
// $qb2->execute();
}
?>