vendredi 19 février 2016

SQLite use in Phalanger

I'm currently trying to compile a functioning PHP project into a .Net dll. My Phalanger/PHP solution uses PDO and SQLite. When I get to the portion which creates my PDO object:

$this->db = new \PDO('sqlite:'.$fileName, null, null, [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

I get a simple "Driver not found" exception.

I'm unable to find much useful information, so I'm hoping someone out there has some experience.

In my project references, I have:

  • PhpNetPDO
  • PhpNetPDOSQLite
  • PhpNetSQLite

I also have an App.config with:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <phpNet>
    <classLibrary>
      <add assembly="PhpNetSQLite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2771987119c16a03" section="sqlite"/>
      <add assembly="PhpNetPDO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2771987119c16a03" section="pdo"/>
      <add assembly="PhpNetPDOSQLite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2771987119c16a03" section="pdosqlite"/>
    </classLibrary>
  </phpNet>
</configuration>

Though the App.config seems to be completely irrelevant.

In a web application (as far as I can tell), I would need to have a PHP.ini in which my sqlite dsn is defined. Is there an equivalent file for Phalanger, specifically when you're building a dll? How do I point my project to the SQLite driver?

I've also tried creating a system odbc dsn called sqlite with no luck.

Can someone give me some advice or point me to a good tutorial?

Aucun commentaire:

Enregistrer un commentaire