REPLACE works exactly like INSERT, except that if an old record in the table has the same value as a new record for a PRIMARY KEY or a UNIQUE index, the old record is deleted before the new record is inserted. See section 13.1.4 INSERT Syntax.
Note that unless the table has a PRIMARY KEY or UNIQUE index, using a REPLACE statement makes no sense. It becomes equivalent to INSERT, because there is no index to be used to determine whether a new row duplicates another.
That's not what I wanted.. here I'll give you the php code for what I am doing
Code: Select all
<?php
$system=secure($_GET['system']);
$result = mysql_query("SELECT `filename`, `title`, `html` FROM `$system`;") or die(mysql_error());
while(list($filename, $title, $html) = mysql_fetch_array($result)) {
$newfile=preg_replace("/$system\/(.*)\.php/", "\\1", $filename);
if ($newfile==$title) {
echo $title . '=>';
$newtitle=preg_replace("/(.*)<h1 align="center">(.*?)<\/h1>(.*)/", "\\2", $html);
$newtitle=nl2br($newtitle);
$newtitle=str_replace("<BR>", "", $newtitle);
if (strlen($newtitle)<75) {
echo $newtitle . '<BR>';
dbq("UPDATE `$system` SET `title` = '" . secure($newtitle) . "' WHERE `filename`= '$filename' ; ");
} else {
echo 'un_changed' . '<BR>';
}
}
}
?>
Is there a way to avoid so many calls to the database (besides loading one huge query into a string and running it all at once), I want to know basically is there a function that could be run on a large amount of records that does what I am doing, but without makeing the php script take forever to execute.