/** * 执行SQL * @param string $sql * @param unknown $bindParams * @param unknown $bindTypes */ public function execute($sql = '', $bindParams = array(), $bindTypes = array()) { return $this->connectionWrite->execute($sql, $bindParams, $bindTypes); }
/** * 食物做法步骤 * @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; } } }