Vexen Crabtree 2015

vexen

Vexen Crabtree's Live Journal

Sociology, Theology, Anti-Religion and Exploration: Forcing Humanity Forwards


Previous Entry Share Next Entry
Vexen Crabtree 2015
vexen

PHP

I need a small app to parse PHP on my Win2000 laptop. It is an old laptop with next-to-no disc space, little memory and a slow processor. But, as I am offline most the time I have to do most my HTML stuff offline... nearly everything I can find ATM is way too complicated, anyone know an already-compiled install?



(I just wrote a few test apps, PHP seems like a nice language to write in, but don't have enough on-line time to learn db-manipulation whilst online, so need to do it offline!)



2. Simple question... can mySQL be used to access normal .mdb databases? (No macros, just queries and tables). I can't be bothered to write a script to create the database structure from scratch. Does mySQL struggle with any database elements I might have used (such as large text fields?).
Tags:

  • 1
1. A PHP IDE is being developed for Eclipse, it is still on version 0.7 but it is already pretty stable and works very well, you can check it at www.eclipse.org/php

2. Not really, you cannot open a .mdb directy from MySQL,but there are a couple converters which do most of the work, about 80-90% is converted properly. A better way to do that, and one that I used just this last week, was to reverse engineer the .MDB using Visio, and then from Visio create the database's generating SQL, it is pretty simple and efficient, there are only a couple things wich have to be taken into account and need a little experience. Btw, how large is the DB structure ?

I've heard that PHP can work with mdb files, although I've never heard of mySQL dealing with mbd files itself...

Xanni

Recommendation: Use PostgreSQL instead of MySQL. It's also opensource and free, but was designed to be a "proper" database, rather than having features tacked on along the way like MySQL.

However, neither of them will natively load MS Access files. You'll need to export the Access schema to SQL, and then load that into your new, shiny proper database. Postgres is happy with arbitrarily large text fields (well, up to about a gigabyte.. after that you need to use BLOBs).


I personally believe that PHP is a rather nasty language, and people are far better off writing webapps in Catalyst (which is Perl-based) or failing that, Java and Struts. However, I'll admit this view isn't shared by your average PHP user :)
(PHP started life as a very simple templating system, and over time, had more features added to it.. However, the original features that made it very quick to use, were also massive security holes, and over time these were removed, and the language updated.. later versions are saner, but also quite messy due to the tacked-on afterthoughts and fixes. The Perl/Catalyst solution I mentioned has the advantage of being very flexible and being able to make use of the millions of CPAN modules available, meaning most code can be written simply by installing the relevant module and then writing some glue code. For an example, check out the various database abstraction layers available on CPAN (eg. DBIx::Class and Class::DBI), and then compare these to the offerings available for php...)

You're running a windows box, right? Well there's ODBC functions in PHP that let you talk to your Access MDB. They work more or less the same way as the mySQL functions, though if you're just starting to learn PHP, you might as well learn one of the "database abstraction" things instead of the old way. You've a choice - PDO is built into PHP 5.1 and is the new object-oriented way of doing things that looks sexy, but probably isn't supported yet on your online host. PEAR DB is old and a bit slow, but quite easy - I mention it because quite often it's installed on ISPs, otherwise shun it. AdoDB is very fast, and there's more than one way to use it, including one that's very familiar to people who've coded in Visual Basic to talk to databases (which I seem to recall you have done).

To talk to your access database from PHP, you'll need to create an ODBC "System DSN" - that's usually in the Start menu → Control Panel → Administrative Tools → Data Sources (ODBC). Choose the Access driver and fiddle with the options. You basically need to point it at your MDB file and give it a name. It has to be a system DSN because PHP doesn't usually run as the person you're logged in as, and therefore won't be able to see user DSNs or read file DSNs. Then you can use the PHP database functions of your choice to talk to the database and do what you like.

Some people have suggested moving your data to mySQL. There are packages out there - you can also get an ODBC driver for mysql and export the data directly from Access into it (I think). If you want to go that route, there's packages like XAMPP - there's a bunch of variations of these, and they all purport to be super-easy-to-use. I had trouble with most of them because I wanted to customise them a bit too much, but if you just want a simple environment with a folder you can dump stuff into and it'll show up as a website, then these are less effort than installing everything by hand. If you do elect to do it yourself, note that the PHP ISAPI module for IIS does weird things if you have certain modules enabled. It's best to use the CGI one if it's just for messing around at home.

  • 1
?

Log in

No account? Create an account