note 114445 deleted from pdo.prepared-statements by cmb
| From: | cmb@php.net | Date: | Tue, 08 Sep 2015 22:20:55 +0000 |
| Subject: | note 114445 deleted from pdo.prepared-statements by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203746@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
/** ÐобавиÑÑ Ð¼Ð¾Ð´Ð¸ÑикаÑии
докÑменÑа */
public function insert_doc_modification($doc_id , array $notice ,array $modification_fields)
{
$fields = array_keys($modification_fields);
$sql = "INSERT INTO doc_modification
(doc_id , " . implode( ",", $fields ) . ")
VALUES
(:doc_id , :" . implode( ", :", $fields ) . " )
ON DUPLICATE KEY UPDATE
hash = :hash ; ";
$stmt = $this->pdo->prepare($sql);
$stmt->bindParam(':doc_id',$doc_id);
//СоздаÑÑ Ð±Ð¸Ð½Ð´Ñ Ð¿Ð¾ полÑм
foreach($modification_fields as $name => $val)
{
$stmt->bindParam(':'.$name, $modification_fields[$name]);
}
//ÐбойÑи вÑе модиÑикаÑии
по докÑменÑÑ
foreach($notice as $value)
{
foreach($modification_fields as $name => $val)
{
if(empty($value[$name])) continue ;
$modification_fields[$name] = $value[$name];
}
$stmt->execute();
}
}