Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
PDO-performing a query does not save data why? - bug-code.com Q&A

PDO-performing a query does not save data why?

0 like 0 dislike
137 views
There is a class of PDO, in which I form the query.
In table 1 added a new column.
When it runs the query there are no errors.
However, in phpAdmin old record.

code
$database = new Database(); $array_sql = "; $array_sql = array( array('sql_colum' => 'fl_select', 'val' => $fl_checkbox), array('sql_colum' => 'price_fl_ignor_1с', 'val' => $price_fl_ignor_1с), array('sql_colum' => 'price_fl_nalichie', 'val' => (int)$_POST['fl_nalichie']), array('sql_colum' => 'price_fl_add_corzina', 'val' => (int)$_POST['add_corzina']), array('sql_colum' => 'price_tip', 'val' => 'price'), array('sql_colum' => 'price_articul', 'val' => clear_string($_POST["articul"])), array('sql_colum' => 'price_shtrih_kod', 'val' => clear_string($_POST["shtrih_kod"])), array('sql_colum' => 'price_obem', 'val' => clear_string($_POST["obem"])), array('sql_colum' => 'price_strana', 'val' => clear_string($_POST["Merlin"])), array('sql_colum' => 'price_new', 'val' => (int)$_POST['price_new']), array('sql_colum' => 'price_star', 'val' => (int)$_POST['price_star']), array('sql_colum' => 'price_data', 'val' => (int)$_POST['price_data']), array('sql_colum' => 'price_data_ot', 'val' => clear_string($_POST["data_ot"])), array('sql_colum' => 'price_data_do', 'val' => clear_string($_POST["data_do"])), ); //print_r($array_sql); $sql_colin="; $sql_colin2 = "; for($i = 0; $i < count($array_sql); ++$i) { $sql_colin .= $array_sql[$i]['sql_colum'].'=:'.$array_sql[$i]['sql_colum'].','; $sql_colin2 .= $array_sql[$i]['sql_colum']."='".$array_sql[$i]['val']."',"; } $SQL = "UPDATE tovar__price SET ".chop($sql_colin, ',')." WHERE id=:id";// chop allows you to cut everything before the comma is from the back row $SQL_err = "UPDATE tovar__price SET ".chop($sql_colin2, ',')." WHERE id=".(int)$_POST['id']; $database->prepare($SQL); for($i = 0; $i < count($array_sql); ++$i) {$sql_colum = $array_sql[$i]['sql_colum'];$val = $array_sql[$i]['val'];$database->bind(":$sql_colum",$val);} $database->bind(":id", (int)$_POST['id']); $database->execute(); IF ($database->error){echo $database->error;}else{ echo 'All is well'; echo $SQL_err; }

asked by | 137 views

1 Answer

0 like 0 dislike
Set PDO::ATTR_ERRMODE to PDO::ERRMODE_EXCEPTION and look in the error logs, any exception thrown by PDO.
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.8k users

24,788 questions
46,220 answers
0 comments
12,813 users