Guys, is there anyone knows how to archive a record saved in database using php?Need to implement it in my program..tnx in advance..Godbless

Recommended Answers

All 7 Replies

This really depends on what you mean by archive.

Do you mean copy a row / some rows from one table to another, one DB to another?

How are the rows selected?

So many questions, I'm not really surprised no one's answered yet.

Member Avatar for diafol

Wanna add a tinyint 'status' field and have a value like 0 = 'active', 1= 'archive'.

..tnx in advance..Godbless

I'm damned and cursed and I like it. :icon_evil:

Wanna add a tinyint 'status' field and have a value like 0 = 'active', 1= 'archive'.

I'm damned and cursed and I like it. :icon_evil:

no,what im suppose to do is compressing a file into archive..what are the code in comressing a particular file or record using php...and what do i have to put in my html form..do i have to put a link of all records saved in database and when you click it,there's an question if i want ot compress it or not..i dont have any idea in comressing file using php..but i need it in my program..

Member Avatar for diafol

First of all, which server are you using? If Windows - zlib is enabled by default. If Linux - zlib is usually not configured by default - check phpinfo() on your remote server. I would imagine most hosts enable zlib these days. Otherwise would have to change settings in php.ini, which isn't always possible.

As far as I know these functions pertain to gunzip (*.gz) archives. I *think* that gz can just hold the one file and you need a tarball to have multiple files - you'll have to excuse my ignorance.

However, phpclasses has a class that you find useful (you need to register to download):

http://www.phpclasses.org/browse/package/945.html

Looks promising with multiple archive formats.

A link on a filename could send an ajax request to archive the file in question, update the DB and refresh the file list.

It could also be performed w/out Ajax - just a simple link with querystring - and let the $_GET variable get the info to process.

Because you want to use a confirm popup, I'd suggest Ajax:

//LOOP THE FOLLOWING (LIST OF FILES)
$confirmcode = md5('saltysalt' . $filename[$i]); //to stop random compressions - perhaps overkill
echo "<li><a href=\"javascript:compressMe('{$filename[$i]}','$confirmcode');\">{$filename[$i]}</a></li>";
$i = $i + 1;
//END LOOP

This sends the parameters - filename and confirmcode to the javascript function compressMe.

I won't do all this now, but suffice to say, you can use a js framework thingy like prototype/jQuery to handle the Ajax request and response object inside the compressMe function.

This sends a request to another php file via POST. From here pick up the filename and confirmcode and check to see that the confirmcode is the salted hash of the filename. Flag an error if not!
Otherwise - check to see that the file exists and there is a corresponding entry in the DB
Flag an error if not!
Otherwise - use the class or zlib function to compress the file.
Verify that this process has been successful and that DB updated successfully.
Flag an error if not!
Get the new filelist (use the same function that was used to populate the original filelist if possible).
Echo this out.

The js file receives the response object and updates the filelist div or container (like an 'ul'). E voila - job done.

BTW - you could use a more sophisticated response using json that would give you greater control over the output, such as
(pseudocode again!)
'failure' ---> display warning about file/process and keep original filelist
'success' ---> display success comment/refresh the filelist

First of all, which server are you using? If Windows - zlib is enabled by default. If Linux - zlib is usually not configured by default - check phpinfo() on your remote server. I would imagine most hosts enable zlib these days. Otherwise would have to change settings in php.ini, which isn't always possible.

As far as I know these functions pertain to gunzip (*.gz) archives. I *think* that gz can just hold the one file and you need a tarball to have multiple files - you'll have to excuse my ignorance.

However, phpclasses has a class that you find useful (you need to register to download):

http://www.phpclasses.org/browse/package/945.html

Looks promising with multiple archive formats.

A link on a filename could send an ajax request to archive the file in question, update the DB and refresh the file list.

It could also be performed w/out Ajax - just a simple link with querystring - and let the $_GET variable get the info to process.

Because you want to use a confirm popup, I'd suggest Ajax:

//LOOP THE FOLLOWING (LIST OF FILES)
$confirmcode = md5('saltysalt' . $filename[$i]); //to stop random compressions - perhaps overkill
echo "<li><a href=\"javascript:compressMe('{$filename[$i]}','$confirmcode');\">{$filename[$i]}</a></li>";
$i = $i + 1;
//END LOOP

This sends the parameters - filename and confirmcode to the javascript function compressMe.

I won't do all this now, but suffice to say, you can use a js framework thingy like prototype/jQuery to handle the Ajax request and response object inside the compressMe function.

This sends a request to another php file via POST. From here pick up the filename and confirmcode and check to see that the confirmcode is the salted hash of the filename. Flag an error if not!
Otherwise - check to see that the file exists and there is a corresponding entry in the DB
Flag an error if not!
Otherwise - use the class or zlib function to compress the file.
Verify that this process has been successful and that DB updated successfully.
Flag an error if not!
Get the new filelist (use the same function that was used to populate the original filelist if possible).
Echo this out.

The js file receives the response object and updates the filelist div or container (like an 'ul'). E voila - job done.

BTW - you could use a more sophisticated response using json that would give you greater control over the output, such as
(pseudocode again!)
'failure' ---> display warning about file/process and keep original filelist
'success' ---> display success comment/refresh the filelist

can't register..on the website you've gave...

http://www.phpclasses.org/register.html?page=archive

What, you don't get this or the form won't let you register?
Sorry can't help as I'm already a member and it won't allow a duplicate.

ok.. i already logged on to that site..i'll try this one..tnx..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.