I have no idea why this won’t work.
function query($sql) {$this->result = @mysql_query($sql, $this->conn); return($this->result != false); }function convert() {
$this->db->open();
$sql_update = "";
$this->db->query("SELECT * FROM ACCOUNTS ");
$str = '';
while ($row = $this->db->fetchassoc()) {
$jobNum = $row['JOBNUMBER'];
$old_date = $row['INSTALLDATE'];
$new_date = date("Y-m-d", strtotime($old_date));
$sql_update = "UPDATE ACCOUNTS SET INSTALLDATE='$new_date' WHERE JOBNUMBER='$jobNum' ";
//$this->db->query($sql_update) or die($this->response->throwResponseError(MSG_DATABASE_ERROR . mysql_error()));
$str .= $jobNum . " -- " . $new_date . "
";
}return $str; }If I run it with that line commented out, it returns all the results i want. But when I uncomment the line where it actually runs the update, it updates the first record and stops the loop. Why?
When you run update, it invalidates the hidden statement hander in your
dband the results associated with it.What you are trying to do, can be done more easily using a single statement:
, where
@current_format_stringis how your dates are formatted now.Update:
Try running this query:
Before you run
UPDATEquery, you may want to check the results withSELECT: