SQLite use in Phalanger

93 Views Asked by At

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>

  <configSections>
    <section name="phpNet" type="PHP.Core.ConfigurationSectionHandler, PhpNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" />
  </configSections>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Phalanger"/>
    </assemblyBinding>
  </runtime>

  <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?

1

There are 1 best solutions below

0
On

Oh, wow, rookie mistake! I had my Phalanger config info in the App.config in the original project which was being compiled to dll, but not in the App.config in the project which was CALLING that dll. Stupid, stupid, stupid!