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!
Vegan wrote:PHP switch seems like the obvious choice
If you have something as structured as country codes, I would recommend using convention over code (like a switch statements). You can load the ad manager by either having database keys or file/folder names that use the country codes. That makes the system extensible by simply adding records or files/folders, rather than updating the code each time.
$file = "/path/to/ads/{$country}/index.php";
if (!is_file($file)) {
$file = "/path/to/ads/default/index.php";
}
include $file;
Using more PHP code gives you flexibility, or you use straight ad HTML or whatever for simplicity. Point is, you pick a filename, and if that thing doesn't exist then you use a default instead. Want to add stuff for a new country? Drop the files right in.
$file = "/path/to/ads/{$country}/index.php";
if (!is_file($file)) {
$file = "/path/to/ads/default/index.php";
}
include $file;
Using more PHP code gives you flexibility, or you use straight ad HTML or whatever for simplicity. Point is, you pick a filename, and if that thing doesn't exist then you use a default instead. Want to add stuff for a new country? Drop the files right in.
That looks like an easier way to get it done, another issue, how to deal with cultural issues, try to offer products that appeal to the local market
My vegan site is one that I am considering some new ideas, I noticed PHP has fairly good support for DBF files, which can be leveraged possible more easily than other contains I can think of
Vegan wrote:That looks like an easier way to get it done, another issue, how to deal with cultural issues, try to offer products that appeal to the local market
This kind of using convention to select based on a data point can load the appropriate code, but can also select the correct data. So you can access alternate data files as well.
Vegan wrote:My vegan site is one that I am considering some new ideas, I noticed PHP has fairly good support for DBF files, which can be leveraged possible more easily than other contains I can think of
Hopefully you are only using DBF files for read-only data, unless your site is has low traffic. I would recommend using a regular database server like MySQL. If you are most comfortable using Excel or Access, you might want to create a work flow to export your data to CSV, upload it to the server, and import using LOAD DATA INFILE for database updates. That would allow you to work in the programs you are comfortable with, but have the site use a real database server with record locking.
very little to no writes to the DBF file, 99.9% would be all read access
any writes would be a simple add to the table, however I see PHP does support PACK so at least I do not have to open FoxPro or other classic development tools
I was considering using a simple DBF to store recipes in, seems like an easy way to store them
Databases in the cloud are expensive, so I am looking to see what PHP can be leveraged to do
some databases I have are in Access format, so I have to figured out how to best leverage what I have
I am considering mostly what I can do directly with PHP and JavaScript so that the site can be moved around easily. So any resource needs to be in the document root or a subfolder.
MySQL is fairly ubiquitous so shouldn't pose a problem. An SQLite database would be stored as a file right in your project's directory structure, so should also be very portable. Just something to consider.
dBase tables are OK for my needs, a lot of the functionality needed is already intrinsic with PHP and I suspect it will remain useful as the old database is still a solid workhorse
Once I figure out some nutritional databases I have I was thinking of how best to leverage them which gets back to the recipes database, so clearly I need to consider a lot of options