pda4me
asked on
MySQL query in PHP with two SQL statements?
I have the following $sql statement in a PHP script:
is it possible to include a Truncate command on a tables TABLE1,TABLE2 within this bit of code prior to running the INSERT statement? I basically need to empty some tables before I INSERT. How do I best do this?
is it possible to include a Truncate command on a tables TABLE1,TABLE2 within this bit of code prior to running the INSERT statement? I basically need to empty some tables before I INSERT. How do I best do this?
$sql = "INSERT INTO simages (sImage_Name) VALUES ('".$record[$primary_key]."_".$record[$mls_key]."')";
I would rather run the statments apart ... why do you want to run this on a "single" $sql?
The PHP/MySQL driver won't allow you to combine queries into one single statement.
ASKER
I am not 100% where to call the new query...I am a newbie with this:
Ideally I would like to create a new function at the very top to empty the tables before the rest of the script runs, can you show me how to do that?
function setupRecord($resource,$rec ord,$mls_k ey) {
global $primary_key;
global $photos_process;
global $conn;
if (checkDuplicates($resource ,$record[$ primary_ke y]))
$ret = updateRecord($resource,$re cord);
else {
$ret = insertRecord($resource,$re cord);
$sql = "INSERT INTO simages (sImage_Name) VALUES ('".$record[$primary_key]. "_".$recor d[$mls_key ]."')";
h_query($sql, $conn);
}
}
Ideally I would like to create a new function at the very top to empty the tables before the rest of the script runs, can you show me how to do that?
function setupRecord($resource,$rec
global $primary_key;
global $photos_process;
global $conn;
if (checkDuplicates($resource
$ret = updateRecord($resource,$re
else {
$ret = insertRecord($resource,$re
$sql = "INSERT INTO simages (sImage_Name) VALUES ('".$record[$primary_key].
h_query($sql, $conn);
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect, thanks for the help guys!