woolyg Posted August 20, 2009 Share Posted August 20, 2009 Hi all, Not sure which forum to put this in, so I chose this one. Has anyone done this before? Basically I'm looking at placing all of the PHP/HTML code into the DB as a MEDIUMBLOB, and calling the data as it's required. A PHP page would basically consist of the following: <?php // Connect to DB $get_page_code = " SELECT code_table.page_code FROM code_table "; $run_page_code = mysql_query($get_page_code); $display_page_code = mysql_fetch_assoc($run_page_code); $page_code = $display_page_code['page_code']; /* This sets the code as a variable <html> <head></head> <body></body> </html>..etc */ echo $page_code; ?> ..and that's all. The reason for looking into this is because the server the PHP application will be stored upon will have no FTP access (for a business's in-house CRM for example). This setup would enable very easy update of the PHP code, as the code could be deployed through a PHP/MySQL script from within the app, and easily updated by an admin on-site, rather than me going to the business and manually FTP'ing files onto the local network. My questions are as follows: 1. Has anyone tried this, and how well did it go? 2. Any noticeable performance hit/fail scenarios? 3. I'm worried about needing to call further PHP variables within the MEDIUMBLOB contents. Say I needed to echo a username halfway down the page. If I use "?>" to close the PHP echo, will that close off the echo of the MEDIUMBLOB? 4. Is it possible to make further MySQL calls within the MEDIUMBLOB data? I'm thinking that slashing all of the quotes (\") within the MEDIUMBLOB data should allow the echo $page_code; to properly parse the info... Any input appreciated. WoolyG Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/ Share on other sites More sharing options...
corbin Posted August 20, 2009 Share Posted August 20, 2009 Errrr.... Using eval() is usually bad.... echo $some_var; Will not parse variables inside of it. For example: $name = "Corbin"; echo $some_content_from_db; If some_content_from_db had $name in it, $name would be displayed, not "Corbin." Perhaps you should look into some kind of updating scheme. You could do something like SVN, CVS or Mercurial, or you could write a simple PHP script that would update the files. Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/#findComment-902932 Share on other sites More sharing options...
woolyg Posted August 20, 2009 Author Share Posted August 20, 2009 Hey, Thanks Corbin - that's exactly the insight I was looking for. I'll begin considering alternative methods for what I need to do. BTW, what did you mean by or you could write a simple PHP script that would update the files ? Wool. Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/#findComment-902944 Share on other sites More sharing options...
corbin Posted August 21, 2009 Share Posted August 21, 2009 Hrmmm.... It's basically a ghetto updating system. The concept: 3 or so files: client side: update.php update.php would request a list of file hashes from hashes.php. After getting the list, it would compare the hashes of the files on the server to the local files. After figuring out which files are different, update.php would make requests to file.php which would return the file contents. server side: hashes hashes.php This would simply return a formatted list of all of the filenames and the files' corresponding hashes. file.php Would allow files to be downloaded. I used to have a system like it, but that was about a year ago, and I can't find the files not. Not the most elegant solution in the world by far (SVN works much better....), but if you're access to tools is limited it could be an option. Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/#findComment-902980 Share on other sites More sharing options...
woolyg Posted August 21, 2009 Author Share Posted August 21, 2009 Thanks Corbin, I'll look further into it WoolyG Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/#findComment-903002 Share on other sites More sharing options...
corbin Posted August 21, 2009 Share Posted August 21, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/#findComment-903009 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.