Exemple #1
0
 /**
  * 回滚事务
  */
 public function rollback()
 {
     return $this->connectionWrite->rollback();
 }
/**
 * 食物做法步骤
 * @param unknown $db
 * @param unknown $foodid
 * @param unknown $content
 */
function setContent(&$db, $recid, $content, $imagefile)
{
    if ($content == null) {
        return;
    }
    //$method=explode("||", $content);
    $method = json_decode($content, true);
    for ($i = 1; $i <= sizeof($method); $i++) {
        if (empty($imagefile[$i - 1])) {
            $imagefile[$i - 1] = 'http://' . getServerIp() . '/uploads/recommendedfood/default.jpg';
        }
        $sql = "insert into foodmethod values({$recid},{$i},'" . stringToDb($method[$i - 1]) . "','{$imagefile[$i - 1]}');";
        $res = $db->execute($sql);
        if (!$res) {
            echo getJsonResponse(1, $db->error, null);
            Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__));
            $db->rollback();
            $db->close();
            exit;
        }
    }
}