public function daily_recipesAction() { $tDate = date('Y-m-d'); $tMO = new DailyrecipesModel(); $tRow = $tMO->field('day_date')->group('day_date')->order('day_date desc')->limit('1')->fRow(); if (!empty($tRow['day_date'])) { $tDate = $tRow['day_date']; } $tFUMO = new FoodunitsModel(); $tImgUrl = Yaf_Registry::get("config")->web->url->img; $tDatas = $tMO->field('mt_name,mt_id,title,unit,amount,weight,fid,tag, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img,protein')->where('day_date = \'' . $tDate . '\'')->order('mt_id asc')->fList(); $tDatasnew = array(); foreach ($tDatas as $tRow) { $tUnits = $tFUMO->field('amount,unit,weight')->where('fid = ' . $tRow['fid'])->fList(); $tDatasnew[$tRow['mt_id']][] = array_merge($tRow, array('units' => $tUnits)); } Tool_Fnc::ajaxMsg('', 1, $tDatasnew); }
public function delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('ID不能为空') : intval($p['id']); $tDR = new DailyrecipesModel(); $tRow = $tDR->field('thumb_img')->where('id = ' . $pId)->fRow(); $tSql = 'delete from ' . $tDR->table . ' where id = ' . $pId; if (!$tDR->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } if (!empty($tRow['thumb_img'])) { unlink(APPLICATION_PATH . '/public' . $tRow['thumb_img']); } Tool_Fnc::ajaxMsg('删除成功', 1); }