CakePHP use MS Access database (.mdb, not accdb):

2019-08-12 18:17发布

I'm in the unlucky situation where my client requires to use a read-only MS Access database to render some webpage contents on his website (built by me).

Because this MS Access file will be updated roughly once per month and I don't want to do it manually by converting it into sql query and import in Mysql, I would like to make some webpages read directly from it.

What I discovered is that there isn't a driver (at least in my cakephp installation) for MS Access database (but in older versions of cake exist) or at least I didn't find any of them.

I need to know where eventually I can find such drivers or how to correctly implement one of them only for read operations (I think I should implement DboSource class, but I don't know what should I override because there isn't anything such virtual or abstract or interface that guide me through this).

I didn't even understand if I should create an Adodb driver or an OleDB driver. I also think that Sqlserver driver is a lot similar to what I should build (except for connectionand some details); if I can use it in some way to shorten my job, it will be helpful.

Edit 1:

Because no one is answering, I can say I'm ok to use MS Access also with "normal" queries (without requiring each table to be bound to a model) but I must be sure that are sanitized and will output arrays similar to what cakes output actually: $jobs['jobs']['name']

Any suggestion on how to achieve this?

2条回答
女痞
2楼-- · 2019-08-12 19:11

Maybe the Adodb or Odbc datasources from https://github.com/cakephp/datasources/tree/2.0/Model/Datasource/Database work with MS Access?

查看更多
Juvenile、少年°
3楼-- · 2019-08-12 19:22

This example is to big to write here it-s from cake bakery Please test it and i'm here for other problems

查看更多
登录 后发表回答