cloning dBase with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

cloning dBase with PHP

Post by Vegan »

dBase et all have been around long enough that manuals galore are plentiful

now the manual for PHP has several capabilities that make this idea seem more feasible

or example the dBase command USE is easily done, REPLACE ALL, is a tad trickier

I have Visual FoxPro which I can use in addition to PHP capability
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cloning dBase with PHP

Post by Christopher »

dBase ... Visual FoxPro .. I know you are familiar with these products, but if you want a file based database I'd really recommend using SQLite3 instead. I know you are not familiar with it, but you can very easily import delimited data into it. It uses SQL and if you implement your code using PDO, you can switch to MySQL by just changing a configuration variable. Not an answer to your question, but my two cents.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

Right now a file based database is the only option I have available to contain cost, databases are expensive with a dubious prospect for a net positive ROI

Databases are trivial to change with MODIFY DATABASE so expansions etc are easy

The USDA had a large database of about 8000 foods, giant spreadsheet for want of a better description, right down to the amino acids

so I was thinking with a recipe I can link to a page with full nutrition for any ingredient using the USDA database

using a page designer, I can easily create a display page for a recipe or a food item

now the packaged food industry has label requirements, see this page for an example https://vegan-advocate.azurewebsites.ne ... coffee.php

i can calculate the values for that form and automatically assemble the values

this is why I was looking at dBase which is nominally built in with PHP
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cloning dBase with PHP

Post by Celauran »

Right now a file based database is the only option I have available to contain cost, databases are expensive with a dubious prospect for a net positive ROI
https://www.digitalocean.com/pricing/
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cloning dBase with PHP

Post by Christopher »

Vegan wrote:this is why I was looking at dBase which is nominally built in with PHP
I was actually accepting your choice of using a file based database (though Celauran and I agree that price is not an issue as databases are always included a no extra cost). And I understand your requirements are for mostly read-only, smallish tables at this point.

My point was that using SQLite instead of dBase is a better technical choice. SQLite has good SQL support (and even JOINs) which will give you more design flexibility. More importantly, you can use PDO to access SQLite databases. That means that when you became the worlds most popular vegan website, you can switch to MySQL with no code changes. Yes, you will need to learn how to import your spreadsheet data into SQLite (with command line .import). And you will need to learn SQL and PDO if you don't know those. But it is a technically superior solution.
(#10850)
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cloning dBase with PHP

Post by Celauran »

One further point; if your site does grow and you need to bring on additional devs, using a standard solution means they will be able to be productive that much more quickly. Also applies if you need support from a third party.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

Using a DBF file or 5 with PHP should be easy enough as all of the core functionality is there. Any competent PHP developer should be aware of the support that is available.

One database would be advertisements, after all web developers need to eat too.

DBF files are small too, which makes them lean which is the idea with PHP document assembly

as example of the ad database, I am using Amazon at the moment, however I may configure more down the road

so amazon operates in a lot of nations, using AISN as the core product ID, and possibly UPC or EAN or ISBN depending on the product

then I need some columns for US, CA, UK etc for where the AISN is actually valid

than if amazon expands, I can add another column for the next nation served

given maybe 1000 products or so, DBF seems like the right choice
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cloning dBase with PHP

Post by Christopher »

Vegan wrote:Using a DBF file or 5 with PHP should be easy enough as all of the core functionality is there.
I get the impression that you don't understand that SQLite is a serverless, file based database just like dbase. SQLite does everything you are looking for in dbase, plus more. Using a SQLite file of 5 is a better solution as explained above.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

is SQLlite integrated into PHP?

One idea I had was to index my game reviews, then i can use SELECT for the year desired instead of a growing HTML table

even the review can be another column etc.

same idea for recipes, DBF is ideal for a cookbook
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: cloning dBase with PHP

Post by Celauran »

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cloning dBase with PHP

Post by Christopher »

Vegan wrote:is SQLlite integrated into PHP?

One idea I had was to index my game reviews, then i can use SELECT for the year desired instead of a growing HTML table

even the review can be another column etc.

same idea for recipes, DBF is ideal for a cookbook
SQLite is the same kind of file based database as dbase/DBF. It is perfect for single table things like cookbooks, etc. But is has fairly full SQL support as well, so you can do SELECTs and even JOINs that will simplify your code. As I mentioned, it is a much more standard database in the PHP world than dbase. It is one of the databases that PDO supports. That is one of the main reasons I recommended it. With PDO, you can use the same code with SQLite and MySQL. And you get better security with PDO by using prepared statements.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

I tried SQLlite, its not turned on, guess they want to upsell their overpriced databases

So lets see, DBF is one option, PHP arrays are ok for smaller stuff, but I was considering ideas between arrays and DBF and other containers

PHP has other ways to find the desired data from an array, I am still exploring all the capabilities

one thing i have to consider, make sure the site is easy for crawlers to find all of the content
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

Looking at my gaming site, I think the upper limit for a game database is maybe 10,000, double if i include consoles

recipes are a tad bigger, but being vegan DELETE WHERE meat = true

now PHP arrays can do a lot with various lists so that is another angle I am looking at, the goal is globalize the site more
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cloning dBase with PHP

Post by Christopher »

No sure I can be be much help. All of the ideas you mention are easy enough to quickly test to see which works best for you.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: cloning dBase with PHP

Post by Vegan »

Given that PHP can create a DBF file itself, in addition to append to it etc, I was wondering if a bunch of code can get the job done

images are all in the cloud somewhere, i use a wide range of them

Can PHP work with headers for a 2 dimensional array? This way I can use table[0] as the header for a database down the road
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply