Writing MS Access .MDF files with PHP - php

Is it possible to write .MDF files using PHP. I have a simple HTML table - x columns, y rows that I wish to convert into a MS Access dataset. There are no foreign keys or anything exotic, just a number of rows and columns.
I have Google searched but the only advice I seem to be able to find is to save it as a .CSV. Unfortunately this isn't acceptable for my client. They want to simply be able to double click the icon and have the database load up in Access (Seems you have to import csv files and can't just double click them).

Those are actually two different problems:
1) Parsing HTML to separate values
Since you seem to have found a way to export to csv, I won't be answering this. You already got your parser then.
2) Create an mdb file.
You can use odbc to talk to Access, that is, if you are in Windows. That means that PHP must be installed on a Windows machine. I'm not aware of any Linux drivers for Access..
You can use odbc_connect to connect to the database:
$conn = odbc_connect("dbname","" ,"");
From there, working with the database is pretty similar to MySQL as long as you use the ODBC functions.
The only problem is creating the actual MDB. This cannot be done in ODBC, you'll need the JET engine. It may be possible to create an MDB file from PHP, but it may be easier to create an empty MDB once, and copy that file from PHP whenever you need a new database.

Jackcess is a pure Java library for reading from and writing to MS Access databases. It is part of the OpenHMS project from Health Market Science, Inc. . It is not an application. There is no GUI. It's a library, intended for other developers to use to build Java applications.
http://jackcess.sourceforge.net/
But an MDF file is not a standard Access file extension. MDB and MDE are while MDW is for user level security.

Have not tested this but this might help you:
http://devzone.zend.com/article/4065
Note that active development of MDB Tools has moved from Sourceforge to Github
https://github.com/brianb/mdbtools

Related

Can PHP create an MS Access database from scratch?

This is a pretty straightforward question: is there any way of creating an MS Access database file from scratch using PHP? I strongly suspect the answer is no out of the box (using PDO with the ODBC driver pretty clearly demands an existing file for the connection string), but perhaps there’s a library I haven’t found. Currently I’m using an empty .accdb file as a template and making a copy before CREATE-ing tables in it, but I’d like to skip that step for security reasons if nothing else.
You can't, because the ODBC driver needs a database(!) to connect to.
Your current approach, copying a template file, is clean and simple and, except if the file can be replaced, also safe.

PHP library to export MySQL structure and data as SQL to file, portable for WAMP/LAMP without command line access

I have not found a library that handles exporting data and structure to SQL. - there are a number of snippets and so on for data only. Exporting structure seems quite a bit more complicated. It must be able to do this without command-line access.
Many of the descriptions I've found online are quite old, so perhaps MySQL has new features that handle this? Or perhaps there are now libraries which do this? (Or perhaps PHPMyAdmin has a self-contained class or set of functions I could hijack?)
You could try this: Sypex Dumper
I used it for a long time with Joomla on XAMPP, very light weight and functional.
You can simply use it standalone or integrate to your application.
This class suited my needs
https://github.com/2createStudio/shuttle-export
You can see several examples in the documentation. The only flaw is that this class don't have the force download option (it always generate the file in disk). I was willing to make a pull request, but there's one push request dating from 6 months ago and the mantainer didn't give a dam.

How to access an SQLite database file stored on cd using php?

I have a small mySQL database and a few simple php based webpages that query the database, generate html tables and present them in the browser. The database is no longer being updated. So, searching and viewing subsets of the data is all that is required.
Some users are interested in distributing the searchable database on a cd or usb memory stick. SQLite seems to offer the answer, but I don't understand what is needed to make this work. What will be required to make a web browser based "app" work from a memory stick in the absence of a server like xampp?
XAMPP Lite from http://portableapps.com/apps/development/xampp
What you want is called a "standalone server". This is very common in almost every other modern language except PHP, for some reason. Googling "standalone php server" reveals several options:
QuickPHP
Nanoweb
Server2Go

php editor source question

Is there a php editor on the market witch can read sources straight from a mysql database?
No....and maybe.
There is no reason why anyone should write a MySQL based editor.
Your best chance to archive this is to find a greedy and/or lunatic programmer that will write you a MySQL-virtual drive.
Yes this IS possible, and at least on windows it does not take much skills.
Well, you could use one of the existing php online editors, and hack the Horde VFS backend in, allowing you to read local files or a database file storage. Another alternative was writing your own FUSE driver. Most sensible however would be to make your database contents available over WebDAV, allowing you to use Eclipse or so

Convert PHP-MySQL web application to desktop app (exe)

I have developed a PHP-MySQL web application, which is a school-based project.
My client wants this application to be converted into a .exe file such that it can be installed on his desktop and use it.
How the PHP website can be converted to a .exe file and can it be run without the need of a database/server software?
Please advice.
The convenient solution is not to convert the website to .exe. I think it will be better if you have portable server/php/mysql and make the website work from a usb or CD with autorun.
NuSphere's PhpDock claims to do this: It serves as a deployment helper and comes with a bundled web server. However, I don't know about the database part, and it's not free.
PhpDock enables you to deploy any PHP web application as a Stand Alone Windows Desktop application w/o any changes in the code.
I don't know that particular product, but I have been using their IDE for years and am quite happy.
try using a site-specific browser. it will make a desktop app that is basically a portal running to your webapp. try this one:
https://mozillalabs.com/prism/
It allows alot of advanced features like system tray icons and such. I have used it many times!
Hope this helps, JL
Short answer: Not possible.
Long answer: It depends.
You could install a web- and database server on his machine (or create an installer that does it) and run the application locally on his machine.
or
You keep the application on a server and just provide a launcher that opens his browser and points it to the URL of the application.
As Artefacto mentioned, it might be a good idea to switch to SQLite instead of MySQL but depending on how your application is written it might require a lot of code and SQL Query changes.
No. You have at least to remove the dependency on MySQL (and use e.g. sqlite instead).
Then, you would either have to:
Convert the webpages to windows dialogs. This would completely change your application (e.g. what would originally be http "form submissions" would be someting completely different). At this point, it'd much easier to write a .NET application
Bundle a web server (e.g. Apache) with PHP installed.
Another try would be to turn your php project into PHP-GTK (http://gtk.php.net/).
Yet another one is to give HPHP a try (https://github.com/facebook/hiphop-php/wiki/) and try to turn the generated C code into something like a .DLL in .NET and use it for the logic while coding the UI in say, C#.
Just create a simple program in C or C++ that will just add icon in Start menu, desktop and Quickstart. If your client clicks the icon it will open the default OS browser and point it to URI of your application online.
That might fool your client :)
Or maybe it will be enough for him (he might be asking you to convert it to exe because he can't remember URI or something - ask him what is the reason).
You can use xampp open-source project to pack your PHP site into an executable file.
Use the following steps:-
1. Download Xampp source code.
Add your PHP file inside htdocs directory(Ref:- https://sourceforge.net/p/xampp/code/HEAD/tree/win32/xampp/htdocs/).
Now compile the XAMPP source code and distribute it.
For DATABASE creation and initial data loading in the database, you can code your site in such way that if database is not created, it redirects the page to install.php which do the database creation and data loading task using sql file provided(you need to add SQL file containing database structure and required data).
Don't forget to delete the SQL file post installation of database.
Not sure that's gonna be possible but have a look at:
WinBinder
WinBinder is a new open source
extension for PHP, the script
programming language. It allows PHP
programmers to easily build native
Windows applications.
(source: winbinder.org)
Solution 1:
There are several solutions to convert your web application into a desktop application, the one I prefer is the open source solution: PhpDesktop, but unfortunately it only supports SQLite.
Best Solution:
To convert your PHP application with MySQL I know a paid solution that does this: 'ExeOutPut For Desktop', it is the best for this job
Php desktop is the way to go, it's actually very simple to modify to the version of PHP you want to use and is open source too https://github.com/cztomczak/phpdesktop

Categories