Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/171226-solved-storing-php-as-a-mediumblob/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.