$db = JFactory::getDbo();$query = "INSERT INTO #__pf_milestones (`PRoject_id`,`title`) VALUES (".$id.","."'".$title."'".")";$db->setQuery($query);$result = $db->query();return $result; 2 、简易写法(1):$db = JFactory::getDbo();$query = $db->getQuery(true); $query->insert('#__pf_milestones')->columns(array('project_id','title')); $values = array(); $values[]=$id; $values[]=$db->quote($title); //转化为字符串$query->values(implode(',',$values));$db->setQuery($query);$result = $db->query();return $result; 二、删除记录:$db = JFactory::getDbo();$query = $db->getQuery(true);$query->delete('#__pf_task_power')->where('project_id=' . $item[0]->project_id . ' AND milestone_id=' . $item[0]->milestone_id . ' AND user_id=' . $item[0]->id);try {$db->setQuery($query);$db->execute();$result = true;} catch (Exception $e) {$result = false;}三、更新记录: $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query-> update('#__pf_milestones') -> set('is_transfer_upload=1') -> where('project_id='.$pro_id.' and created_by='.$user->id); $db->setQuery($query); $result = $db->query(); return $result;四、查找记录: $db = JFactory::getDbo(); $query = $db->getQuery(true); $query-> select ("created_by") -> from("#__pf_projects") -> where("id=".$id); $db -> setQuery($query); $result = (array)$db->loadRowList();
新闻热点
疑难解答