tate_etc Posted May 9, 2008 Share Posted May 9, 2008 PHP/MySQL is a perfect combination, but I've been programming for a while, so I'd like to try something new. I'm creating an app, and I'd like it to work as soon as someone uploads it to his/her host. To do this, I need to have a local database file that the app references, because I don't think MySQL, Sybase, or PostgreSQL can help me here (due to admin stuff). My first attempt is to have a DATABASE.DAT file that contains encrypted XML. My app reads the file like this: $database = file_get_contents('database.dat'); $database = my_decoder($database); $database = new SimpleXMLElement($database); $user = $database->users->user[0]; My app writes to the file like this: $database = $database->asXML(); $database = my_encoder($database); $handle = fopen('database.dat', 'w'); fwrite($handle, $database); fclose($handle); The first problem I spotted out almost immediately is: - User 1 can load a page that takes 10 seconds to load - User 2 can load a page that takes 5 seconds to load - If User 2 started after and finished before User 1, any changes User 1 makes will overwrite User 2's changes (since User 1 is using the file that was made BEFORE the changes) I guess I could have the app check for changes to the file before writing, but that could get messy. Here are my questions: - Does this even make sense? - OR can you dynamically change an XML file? - OR is there another way to include a database with a PHP app? Any input is greatly appreciated!! Link to comment https://forums.phpfreaks.com/topic/104901-php-and-non-mysql-databases-or-local-database-files/ Share on other sites More sharing options...
BlueSkyIS Posted May 9, 2008 Share Posted May 9, 2008 it sounds like your plan is to create a new database system to ship with your app. i suggest that you require an existing database system instead. one or more of the ones your mentioned. Link to comment https://forums.phpfreaks.com/topic/104901-php-and-non-mysql-databases-or-local-database-files/#findComment-536881 Share on other sites More sharing options...
MattDunbar Posted May 9, 2008 Share Posted May 9, 2008 Lock files while editing and get a way faster server if its taking that long to load pages. You could also que certain things like password changes, registrations etc to happen on a cron job so there is a small delay. To make the software Out-Of-The-Box-Ready, make it run remotely, handling data on your server, giving each app a dynamically generated API key and pre-inserting that into the user's download. Link to comment https://forums.phpfreaks.com/topic/104901-php-and-non-mysql-databases-or-local-database-files/#findComment-536882 Share on other sites More sharing options...
tate_etc Posted May 9, 2008 Author Share Posted May 9, 2008 Haha, it doesn't really take that long; I just wanted to use easy numbers, so what I was explaining can make sense. Though it would probably never happen, the thought of someone losing data is very scary. I've thought about having the data hosted remotely. This would be good, since I can keep up with the API keys and monitor any illegitimate activity. The problem is that I don't want to require users to be online while using the app, since developers and others can make use of the app, and I don't want to cause any roadblocks in development (there's already too many). I should also point out that this is my first commercial app. Is there a tutorial or anything to ensure that it's solid and no one can view/edit the code? I've been looking at phpcipher.com, but I really have no idea... Link to comment https://forums.phpfreaks.com/topic/104901-php-and-non-mysql-databases-or-local-database-files/#findComment-536942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.