fawkesb Posted April 19, 2009 Share Posted April 19, 2009 Greetings again all. Ok, I have now successfully figured out how to create / add / edit / delete entries to a single text file via PHP. Now I am wondering - what is the file size / array upper limit? Basically I created this to be used as a news / blog updater for my clients and I've thought of a possible issue... Rather than storing each entry in its own file, someone suggested putting it all into an array with separaters. Sounded good and I finally figured it out - but I got to thinking, what if one of my clients starts getting a huge news or blog reel going? Over time this thing will take forever to load and process will it not? And most likely crash out... (Seeing as how it loads the whole file in first, then tags the current file as char sep string onto the new entry - thus reserving chronological order from top down) What are some options here or perhaps I could create something to auto-archive and start over after a bit? Like file gets over so many K, rename it to something like 'events_2.txt', take the two most recent entries, and start a new 'events.txt'? If so, how would I do a check event for this i.e. if (filesize > xxx K) {archive code here} Thanks, John (P.S. - as thanks, if anyone would like the code I created for their own use just ask. 4 separate small files maintain, edit, del and write entries in the text file.) Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/ Share on other sites More sharing options...
.josh Posted April 19, 2009 Share Posted April 19, 2009 so...why not store the stuff in a database instead? even using mysql lite would be a step up. Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813618 Share on other sites More sharing options...
fawkesb Posted April 19, 2009 Author Share Posted April 19, 2009 Basically I have a *few* clients that are hosting with webhosts that only allow ONE database (ridiculous) and I need that database for user / account information. Specifically the setup problem here is: one database, contains users, account info, newsletter subscription y/n, some tracking info, etc. Therefore: I was looking into a way to make a simple text file system that wouldn't be too messy to setup. It works great the way it is... just worried about when it gets to big like I said. None of the blog / news needs to be secure so text is fine. Just wondering if it's going to get bloated or not... Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813622 Share on other sites More sharing options...
laffin Posted April 19, 2009 Share Posted April 19, 2009 I should take a look at sqlite its a subset of SQL, but pretty rich. a subset of SQL - just means that there are some features not implemented. SQLite used a flatfile for a database, so be sure to put these files in a non web accessible folder. About only problem u will encounter, is that php5 does come with 2 different versions SQLite2 - usually built in / as well as PDO interface SQLite3 - using the PDO interface Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813627 Share on other sites More sharing options...
fawkesb Posted April 19, 2009 Author Share Posted April 19, 2009 Hm, ok I will do that. I have never messed with SQLite, so now is as good as time as any. If I can make that work, then that will be a great solution for those people limited by the number of databases allowed. Most people I do this stuff for (including my own sites) have at least 5 databses included in even basic hosting packages. So usually it's not a problem. Thanks for the input, and thanks again for everyone's original help pointing me in the right direction on my current scripts. Take care, John Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813630 Share on other sites More sharing options...
soak Posted April 19, 2009 Share Posted April 19, 2009 Or consider using table prefixes to differentiate between applications. So all data for the blog can be blog_table1, blog_table2 etc and all data from the cms can be cms_table1 etc etc. Or, option 2, just get your clients to move to proper hosting ;-) Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813631 Share on other sites More sharing options...
.josh Posted April 19, 2009 Share Posted April 19, 2009 right. they might have one database, but that's not really a hindrance... you can still make the tables you need. The only thing would be that since it's all under the same database as whatever they originally had there, things would be able to be cross referenced. If you really think about it, that might not actually be a bad thing, depending on circumstances.. Quote Link to comment https://forums.phpfreaks.com/topic/154724-php-text-file-limitations/#findComment-813867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.