• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Accessing a file system HSQLDB through PHP

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to do this in Java with HSQLDB's jdbc driver as follows:



This would reference a db.script file located on the file system at C:\Test\ which contained the schema for all the tables being used as well as their data. Is it also possible to reference a HSQLDB script file within the same working directory as your PHP code using oci, odbc, pdo or something else?
 
Rancher
Posts: 43015
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think HSQLDB has bindings to languages other than Java. Derby apparently has: https://www.ibm.com/developerworks/data/library/techarticle/dm-0409casey/; maybe that's an option instead of HSQLDB?
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. The reason I'm wanting to do this is I'm dealing with large amounts of data from a web service and so have sacrificed memory for speed and of course I'm running into heap size issues just using arrays. Rather than just increasing PHP's heap size, I thought I'd use the on-demand'ness of a database to dump the data in bulk from the web service so I could query it as needed much faster. I was hoping to go with a "lite as can be" local file system database like HSQLDB which wouldn't require web server or a bunch of libraries to setup. Is there something akin to this in PHP, or should I be approaching the problem in another way?
 
Marshal
Posts: 25484
67
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't hard to set up MySQL, and using MySQL with PHP is a very common thing to do. They even gave it its own acronym: LAMP meaning Linux, Apache, MySQL, PHP. Not that you have to use all four of those technologies of course, I just mean that MySQL+PHP is a very common pairing.
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice. From what I'm reading online it seems like that's going to be my bread and butter for PHP development, though for this instance I'll probably go with SQLite.
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as a wrap up if anyone else new to PHP is trying to use a minimalist database with their PHP script, the following code works after enabling the php_sqlite3.dll extension in the php.ini file for Windows users. When run, this code will create a file test.db in the same directory where it is run.

 
The only cure for that is hours of television radiation. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic