public function delete($where = null) { if (isset($where)) { $this->where($where); } else { if (empty($this->where)) { throw new Exception('DBModel.php: NO update data without where, if you want to do this, pls use updateAll.', 1); } } //mysql里,delete 不支持 别名 $_where = preg_replace_callback('/(^|\\s|\\()([^\\.\\s\\(]+\\.)([^\\.\\(\\s]+)(\\s*?[!=\\>\\<]|\\s+?(is|not|in|like|between))/', function ($matches) { return $matches[1] . $matches[3] . $matches[4]; }, $this->where); $sql = 'DELETE FROM ' . $this->tableName . $_where . $this->limit; return DBTool::executeSql($sql); }
public static function getCheckedweek($userID) { $sql = 'select `weeks` from `weekThis` where `userID` =' . $userID; $list = DBTool::queryData($sql); return self::myCheckWeek($list[0]['weeks']); }
/** *查询符合条件的数组 *返回个数 * */ public static function queryData($userId, $bossID, $missionID, $thisCreateTime) { $sql = 'select * from `remind` where `userID` = ' . $userId . ' and `bossID` = ' . $bossID . ' and `missionID` = ' . $missionID . ' and `thisCreateTime` = ' . $thisCreateTime; $list = DBTool::queryData($sql); return count($list); }
public static function actionLoadAreaIdsInWorld() { $areaList = DBTool::queryData('select DISTINCT areaMain,areaSecond,areaThird from area order by areaMain;'); return AreaController::reloadAreaList($areaList); }
if (count($filesExists) > 0) { print '可以使用以下参数删除文件: -rm yes' . "\n"; print '可以使用以下参数更新文件: -update yes' . "\n"; exit; } } } // $_dbModel = new DBModel($_tableName); // $_tableDataKeys = $_dbModel->getMeta(); // if (!is_array($_tableDataKeys) || count($_tableDataKeys)==0) // { // print('中止,表字段获取失败:'.$_tableName."\n"); // exit; // } // $_filedList = DBTool::queryData('show full columns from ' . $_tableName); $_tableDataKeys = array(); $_tableKeysImportantForAdd = array(); foreach ($_filedList as $_fieldRow) { if ($_fieldRow['Key'] == 'PRI') { $_tableIdName = $_fieldRow["Field"]; } else { if (!in_array($_fieldRow["Field"], array('id', 'userID', 'status', 'createTime', 'modifyTime'))) { $_tableKeysImportantForAdd[] = $_fieldRow["Field"]; } } $_tableDataKeys[$_fieldRow["Field"]] = $_fieldRow; } if (!is_array($_tableDataKeys) || count($_tableDataKeys) == 0) { print '中止,表字段获取失败:' . $_tableName . "\n"; exit;