Answer the question
In order to leave comments, you need to log in
Yii + ADODB(Access). Any recipes?
I need to attach an Access database to the site, I know how to work with it in native PHP, but I didn’t find examples of how to work with a database from Yii. Has anyone had crossbreeding experience?
The database is working, therefore it is impossible to convert it to mysql.
here is a native example.
$cnn = new COM("ADODB.Connection",null,CP_UTF8) or die("Cannot start ADO");
$cnn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\db.mdb;Persist Security Info=False");
$rs = $cnn->Execute("select * from table");
while(!$rs->EOF){
$dt = $rs->Fields["date"]->Value;
echo $dt;
$rs->MoveNext();
}
$rs=$cnn=null;
Answer the question
In order to leave comments, you need to log in
Yii works with the database through PDO. In PDO, there seems to be ODBC support, through which, in theory, you can work with Access.
Here is an example connection string:
Something similar should be written in the Yii config for db.
The only thing I could get to.
in main.php
'db'=>array(
'class'=>'CDbConnection',
'connectionString' => 'odbc:DRIVER={Microsoft Access Driver (*.mdb)};Dbq=d:\\db.mdb;',
'username'=>'',
'password'=>'',
),
$res=Yii::app()->db->createCommand('select * from table');
$rows=$res->queryAll();
foreach($rows as $row) {
print_r($row);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question