//check the adConsumed table to find whether the same status, status ‘1‘ is in the table, //if the status exsits in the table do not insert that row //if the status does not exsit in the table insert the row //col2 is the advertisementID calculated from the appinfo with appid $sql = ‘INSERT INTO adConsumed(customerID, advertisementID, consumedStatus, consumedTime) select col1, col2, col3, col4 from (select :customerID as col1, (SELECT `advertisementID` FROM `appInfo` WHERE `ID`= :appid) as col2, 1 as col3, :time as col4) t WHERE NOT EXISTS (SELECT * FROM adConsumed WHERE customerID = :customerID and advertisementID = col2 and consumedStatus=1)‘; $command = $connection->createCommand($sql); $command->bindParam(‘:appid‘, $appid); $command->bindParam(‘:customerID‘, $customerID); $command->bindParam(‘:time‘, date(‘Y-m-d H:i:s‘)); $updateSucceeded = $command->execute();
sql 语句中包含sql语句.
时间: 2024-10-22 10:49:59