There is definitely a DLL for Sqlite in PHP. To load it, you uncomment these lines in your php.ini:
[PHP_PDO_SQLITE]
extension=php_pdo_sqlite.dll
[PHP_SQLITE]
extension=php_sqlite.dll
Then, after restarting Apache, these lines will work on a Spatialite database that you create with spatialite_gui:
$conn = new PDO('sqlite:census_tract.sqlite');
/*** set the error reporting attribute ***/
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "select ctuid from census_tract_lat_lng";
foreach ($conn->query($query) as $row)
{
list($ctuid) = $row;
print "$ctuid<br>";
}
However, you cannot load the spatialite dll. This line:
$stat = $conn->query('SELECT load_extension("/Program Files (x86)/PHP/ext/libspatialite-2.dll");');
...generates this message:
SQLSTATE[HY000]: General error: 1 not authorized
Thus this line:
$query .= " where st_within(
geometry,
ST_GeomFromText
(
'POLYGON((-123.1086760644531 49.22191988838464, -123.1086760644531 49.24299345671403,-123.06267081542967 49.24299345671403 ,-123.06267081542967 49.22191988838464, -123.1086760644531 49.22191988838464 ))'
)
)";
...generates this message.
SQLSTATE[HY000]: General error: 1 no such function: ST_GeomFromText
I have tried other ways, including loading the
libspatialite-2.dll in php.ini, but all methods fail. It seems that PHP has to create its own "official" dll to support spatialite on Windows.
On Sunday, July 29, 2012 12:29:27 PM UTC-7, chuck wrote:
The usage of Spatialite on Windows with PHP could be possible depending on the setting. I don't know if the driver is available for PHP but you might be able to get some help from this link: http://sqlite.awardspace.info/syntax/sqliteodbc.htm. I don't know if they have worked on a driver for PHP.
If you want to use sqlite / spatialite with MS Access to test, you an download it here.
http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe.
That is a link will download a driver that works with MS Access
I went looking for what you need and found several things that point to a solution. I don't have time right now to experimant but I found this that looks really promising. It says that you can access Sqlite directly with this library.
http://devpaks.org/details.php?devpak=120
Also there is a lot of mention of the idea that PHP already has built in support for Sqlite / Spatialite. See this link for their instructions on how to enable it.
http://www.wikihow.com/Enable-SQLite-for-PHP-5.X-in-Windows
Please let us know what you find.
Chuck
Is it possible to use Spatialite with PHP on Windows? I have searched for this topic and cannot find any conclusive answer.
Thanks