iOS對資料庫的操作

2021-07-04 11:29:43 字數 4214 閱讀 9697

對資料庫的操作

@inte***ce hmviewcontroller ()

@property (weak, nonatomic) iboutlet uitextfield *namefield;

@property (weak, nonatomic) iboutlet uitextfield *pricefield;

/** 資料庫物件例項 */

@property (nonatomic, assign) sqlite3 *db;

@property (weak, nonatomic) iboutlet uitableview *tableview;

- (ibaction)insert;

@property (nonatomic, strong) nsmutablearray *shops;

@end

@implementation hmviewcontroller

- (nsmutablearray *)shops

return _shops;

}- (void)viewdidload

#pragma mark - uisearchbardelegate

- (void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext

}[self.tableview reloaddata];

}/**

查詢資料

*/- (void)setupdata}}

/**初始化資料庫

*/- (void)setupdb

} else

}- (ibaction)insert

#pragma mark - 資料來源方法

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

hmshop *shop = self.shops[indexpath.row];

cell.textlabel.text = shop.name;

cell.detailtextlabel.text = shop.price;

return cell;

}@end

/**nsmutablestring *sql = [nsmutablestring string];

for (int i = 0; i<1000; i++)

*///fmdb的使用方法

#import "hmviewcontroller.h"

//#import "fmdb.h"

#import "hmshop.h"

#import "hmshoptool.h"

@inte***ce hmviewcontroller ()

//@property (nonatomic, strong) fmdatabase *db;

@end

@implementation hmviewcontroller

- (void)viewdidload

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event

nsarray *shops = [hmshoptool shops];

for (hmshop *shop in shops)

//    [self.db executeupdate:@"delete from t_shop where price < 800;"];

//    

//    [self query];

}- (void)query

}- (void)insert

}@end

//事件的處理

- (void)awakefromnib

//- (void)click

//- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event

- (uiview *)hittest:(cgpoint)point withevent:(uievent *)event

@end

@implementation hmredview

- (id)initwithframe:(cgrect)frame

return self;

}- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event

@end

//fmdb將任意物件存入資料庫中

@inte***ce hmviewcontroller ()

@property (nonatomic, strong) fmdatabase *db;

@end

@implementation hmviewcontroller

- (void)viewdidload

- (void)setup

- (void)readshops

//    nslog(@"%@", [shops subarraywithrange:nsmakerange(20, 10)]);

}- (void)addshops

for (int i = 0; i<100; i++)

}@end

//下拉放大的實現

const cgfloat hmtopviewh = 350;

@inte***ce hmviewcontroller ()

@property (nonatomic, weak) uiimageview *topview;

@end

@implementation hmviewcontroller

- (void)viewdidload

#pragma mark - 資料來源方法

- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

cell.textlabel.text = [nsstring stringwithformat:@"測試資料---%d", indexpath.row];

return cell;

}- (void)scrollviewdidscroll:(uiscrollview *)scrollview

@end

//修改視屏名稱

// 創業天使-*** 120101_超清.mp4 --> 120101-創業天使-***.mp4

int main(int argc, const char * argv)

)_.清" capture:yes];

nsstring *suffix = [filename stringbymatching:@"(.+) \\d_.清" capture:yes];

nsstring *newfilename = [nsstring stringwithformat:@"%@-%@", prefix, suffix];

// 生成新的全路徑

nsstring *newfullsubpath = [fullsubpath stringbyreplacingoccurrencesofstring:filename withstring:newfilename];

//            nsdata *data = [nsdata datawithcontentsoffile:fullsubpath];

//            [data writetofile:newfullsubpath atomically:yes];

//            [mgr removeitematpath:fullsubpath error:nil];

// 剪下\移動

[mgr moveitematpath:fullsubpath topath:newfullsubpath error:nil];}}

return 0;

}

對資料庫的操作

資料庫的檔案 資料檔案 包含資料和物件,主資料檔案建議副檔名.mdf,其餘.ndf 事務日誌檔案 包含恢復資料庫中的所有事物所需的資訊,建議副檔名.ldf 至少包含乙個資料檔案和乙個日誌檔案 對資料庫的操作 選其中乙個,可以選 選其中乙個,必選 分割,表示多個選項 表示說明 建立create dat...

常規對資料庫庫的操作

執行如下命令,檢視系統庫 show databases information schema 虛擬庫,不占用磁碟空間,儲存的是資料庫啟動後的一些引數,如使用者表資訊 列資訊 許可權資訊 字元資訊等 performance schema mysql 5.5開始新增乙個資料庫 主要用於收集資料庫伺服器效...

Spring 對資料庫操作

1.spring的資料庫訪問方式 提供了對jdbc,mybatis,hibernate等的支援。主要通過dao提供了如下的支援 a.提供了與平台無關的資料庫訪問異常體系 b.提供了資料訪問的模板,比如 jbdctemplate,jdbctemplate,hibernatetemplate c.提供了...