当前位置: 首页 > news >正文

wordpress主题怎么设置搜索引擎seo是什么

wordpress主题怎么设置,搜索引擎seo是什么,wordpress网址导航开源,权威的企业网站建设SQLite" class"css-1occaib">SQLite数据库是基于事实和标准SQL的嵌入式数据库引擎,它是小型且经过时间考验的数据库引擎,sqflite软件包提供了许多函数,可以有效地与SQLite数据库一起使用,它提供了操作SQLite数据…

SQLite" class="css-1occaib">SQLite数据库是基于事实和标准SQL的嵌入式数据库引擎,它是小型且经过时间考验的数据库引擎,sqflite软件包提供了许多函数,可以有效地与SQLite数据库一起使用,它提供了操作SQLite数据库引擎的标准方法。

  • 在Android Studio中创建一个新的Flutter应用程序product_sqlite_app。

  • 用无涯教程的 product_rest_app 代码替换默认的启动代码(main.dart)。

  • 将assets文件夹从 product_nav_app 复制到 product_rest_app 并在* pubspec.yaml`文件内添加assets。

flutter: assets: - assets/appimages/floppy.png - assets/appimages/iphone.png - assets/appimages/laptop.png - assets/appimages/pendrive.png - assets/appimages/pixel.png - assets/appimages/tablet.png
  • 在pubspec.yaml文件中配置sqflite软件包,如下所示-

dependencies: sqflite: any
  • 在pubspec.yaml文件中配置path_provider软件包,如下所示-

dependencies: path_provider: any
  • 此处,path_provider软件包用于获取系统的临时文件夹路径和应用程序的路径,使用 sqflite 的最新版本号代替任何。

  • Android Studio会提醒pubspec.yaml已更新。

Updated
  • 单击"Get dependencies"选项。 Android studio将从互联网上获取该软件包,并为应用程序正确配置它。

  • 在数据库中,无涯教程需要主键,id作为附加字段以及产品属性(如名称,价格等),因此,请在Product类中添加id属性。另外,添加新方法toMap将产品对象转换为Map对象。 fromMap和toMap用于对Product对象进行序列化和反序列化,并用于数据库操作方法中。

class Product { final int id; final String name; final String description; final int price; final String image; static final columns = ["id", "name", "description", "price", "image"]; Product(this.id, this.name, this.description, this.price, this.image); factory Product.fromMap(Map<String, dynamic> data) {return Product( data[id], data[name], data[description], data[price], data[image], ); } Map<String, dynamic> toMap() => {"id": id, "name": name, "description": description, "price": price, "image": image }; 
}
  • 在lib文件夹中创建一个新文件Database.dart,以编写SQLite的相关函数。

  • 在Database.dart中导入必要的import语句。

import dart:async; 
import dart:io; 
import package:path/path.dart; 
import package:path_provider/path_provider.dart; 
import package:sqflite/sqflite.dart; 
import Product.dart;
  • 请注意以下几点-

    • async                    -  用于编写异步方法。

    • io                           -  用于访问文件和目录。

    • path                      -  用于访问与文件路径相关的dart核心实用程序函数。

    • path_provider    -  用于获取临时路径和应用程序路径。

    • sqflite                   -  用于操作SQLite的数据库。

  • 创建一个新的类SQLite的DbProvider

  •     - 声明一个基于单例的静态SQLite的DbProvider对象,如下所示:

class SQLiteDbProvider { SQLiteDbProvider._(); static final SQLiteDbProvider db=SQLiteDbProvider._(); static Database _database; 
} 
  •     - 可以通过静态db变量访问SQLite的DBProvoider对象及其方法。

SQLiteDBProvoider.db.<emthod> 
  •     - 创建一个方法来获取类型为Future <Database>的数据库,创建产品表并在数据库本身创建期间加载初始数据。

Future<Database> get database async { if (_database != null) return _database; _database = await initDB(); return _database; 
}
initDB() async { Directory documentsDirectory = await getApplicationDocumentsDirectory(); String path = join(documentsDirectory.path, "ProductDB.db"); return await openDatabase(path, version: 1,onOpen: (db) {}, onCreate: (Database db, int version) async {await db.execute("CREATE TABLE Product (""id INTEGER PRIMARY KEY,""name TEXT,""description TEXT,""price INTEGER," "image TEXT" ")"); await db.execute("INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [1, "iPhone", "iPhone is the stylist phone ever", 1000, "iphone.png"]); await db.execute("INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [2, "Pixel", "Pixel is the most feature phone ever", 800, "pixel.png"]); await db.execute("INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [3, "Laptop", "Laptop is most productive development tool", 2000, "laptop.png"]\); await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [4, "Tablet", "Laptop is most productive development tool", 1500, "tablet.png"]);await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [5, "Pendrive", "Pendrive is useful storage medium", 100, "pendrive.png"]);await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [6, "Floppy Drive", "Floppy drive is useful rescue storage medium", 20, "floppy.png"]); }); 
}
  • 在这里,无涯教程使用了以下方法-

    •     -  getApplicationDocumentsDirectory -  返回应用程序目录路径

    •     -  join                        - 用于创建系统特定的路径,无涯教程已经使用它来创建数据库路径。

    •     -  openDatabase     - 用于打开SQLite的数据库。

    •     -  onOpen                - 用于在打开数据库时编写代码

    •     -  onCreate              - 用于在首次创建数据库时编写代码

    •     -  db.execute           - 用于执行SQL查询。它接受一个查询。如果查询具有占位符(?),则它将接受值作为第二个参数中的列表。

  • 编写getAllProducts来获取数据库中的所有产品-

Future<List<Product>> getAllProducts() async { final db = await database; List<Map> results = await db.query("Product", columns: Product.columns, orderBy: "id ASC"); List<Product> products = new List(); results.forEach((result) { Product product = Product.fromMap(result); products.add(product); }); return products; 
}
  • 编写getProductById来获取特定于 id的产品

Future<Product> getProductById(int id) async {final db = await database; var result = await db.query("Product", where: "id=", whereArgs: [id]); return result.isNotEmpty ? Product.fromMap(result.first) : Null; 
}
  • 在这里,无涯教程使用了where和whereArgs来应用过滤器。

  • 创建三种方法-插入,更新和删除方法,以从数据库中插入,更新和删除产品。

insert(Product product) async { final db = await database; var maxIdResult = await db.rawQuery("SELECT MAX(id)+1 as last_inserted_id FROM Product");var id = maxIdResult.first["last_inserted_id"]; var result = await db.rawInsert("INSERT Into Product (id, name, description, price, image)" " VALUES (?, ?, ?, ?, ?)", [id, product.name, product.description, product.price, product.image] ); return result; 
}
update(Product product) async { final db = await database; var result = await db.update("Product", product.toMap(), where: "id=?", whereArgs: [product.id]); return result; 
} 
delete(int id) async { final db = await database; db.delete("Product", where: "id=?", whereArgs: [id]); 
}
  • Database.dart的最终代码如下-

import dart:async; 
import dart:io; 
import package:path/path.dart; 
import package:path_provider/path_provider.dart; 
import package:sqflite/sqflite.dart; 
import Product.dart; class SQLiteDbProvider {SQLiteDbProvider._(); static final SQLiteDbProvider db = SQLiteDbProvider._(); static Database _database; Future<Database> get database async {if (_database != null) return _database; _database = await initDB(); return _database; } initDB() async {Directory documentsDirectory = await getApplicationDocumentsDirectory(); String path = join(documentsDirectory.path, "ProductDB.db"); return await openDatabase(path, version: 1, onOpen: (db) {}, onCreate: (Database db, int version) async {await db.execute("CREATE TABLE Product (" "id INTEGER PRIMARY KEY," "name TEXT," "description TEXT," "price INTEGER," "image TEXT"")"); await db.execute("INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [1, "iPhone", "iPhone is the stylist phone ever", 1000, "iphone.png"]); await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [2, "Pixel", "Pixel is the most feature phone ever", 800, "pixel.png"]);await db.execute("INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [3, "Laptop", "Laptop is most productive development tool", 2000, "laptop.png"]); await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [4, "Tablet", "Laptop is most productive development tool", 1500, "tablet.png"]); await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [5, "Pendrive", "Pendrive is useful storage medium", 100, "pendrive.png"]);await db.execute( "INSERT INTO Product (id, name, description, price, image) values (?, ?, ?, ?, ?)", [6, "Floppy Drive", "Floppy drive is useful rescue storage medium", 20, "floppy.png"]); }); }Future<List<Product>> getAllProducts() async {final db = await database; List<Map> results = await db.query("Product", columns: Product.columns, orderBy: "id ASC"); List<Product> products = new List();   results.forEach((result) {Product product = Product.fromMap(result); products.add(product); }); return products; } Future<Product> getProductById(int id) async {final db = await database; var result = await db.query("Product", where: "id=", whereArgs: [id]); return result.isNotEmpty ? Product.fromMap(result.first) : Null; } insert(Product product) async { final db = await database; var maxIdResult = await db.rawQuery("SELECT MAX(id)+1 as last_inserted_id FROM Product"); var id = maxIdResult.first["last_inserted_id"]; var result = await db.rawInsert("INSERT Into Product (id, name, description, price, image)" " VALUES (?, ?, ?, ?, ?)", [id, product.name, product.description, product.price, product.image] ); return result; } update(Product product) async { final db = await database; var result = await db.update("Product", product.toMap(), where: "id=?", whereArgs: [product.id]); return result; } delete(int id) async { final db = await database; db.delete("Product", where: "id=?", whereArgs: [id]);} 
}
  • 更改主要方法以获取产品信息。

void main() {runApp(MyApp(products: SQLiteDbProvider.db.getAllProducts())); 
}
  • 在这里,无涯教程使用了getAllProducts方法来从数据库中获取所有产品。

  • 运行该应用程序并查看结果。它与先前的示例访问产品服务API相似,不同之处在于,产品信息是从本地SQLite的数据库存储和获取的。

Flutter - 数据库 - 无涯教程网无涯教程网提供SQLite" class="css-1occaib">SQLite数据库是基于事实和标准SQL的嵌入式数据库引擎...https://www.learnfk.com/flutter/flutter-database-concepts.html


文章转载自:
http://tyrannical.qkqn.cn
http://ophir.qkqn.cn
http://regarding.qkqn.cn
http://countryfolk.qkqn.cn
http://isodimorphism.qkqn.cn
http://poort.qkqn.cn
http://peregrin.qkqn.cn
http://alkekengi.qkqn.cn
http://soapolallie.qkqn.cn
http://anapurna.qkqn.cn
http://stockist.qkqn.cn
http://foredoom.qkqn.cn
http://astride.qkqn.cn
http://thermocautery.qkqn.cn
http://bambara.qkqn.cn
http://sichuan.qkqn.cn
http://semioviparous.qkqn.cn
http://pronatalist.qkqn.cn
http://moundsman.qkqn.cn
http://malconformation.qkqn.cn
http://frate.qkqn.cn
http://apsidiole.qkqn.cn
http://egomaniacally.qkqn.cn
http://gareth.qkqn.cn
http://sacculate.qkqn.cn
http://insolence.qkqn.cn
http://appliance.qkqn.cn
http://siderocyte.qkqn.cn
http://cuckoo.qkqn.cn
http://portasystemic.qkqn.cn
http://catecholamine.qkqn.cn
http://cardfile.qkqn.cn
http://typify.qkqn.cn
http://vespucci.qkqn.cn
http://downbent.qkqn.cn
http://anachronous.qkqn.cn
http://kain.qkqn.cn
http://broad.qkqn.cn
http://ezra.qkqn.cn
http://crannied.qkqn.cn
http://garment.qkqn.cn
http://clarence.qkqn.cn
http://fadeometer.qkqn.cn
http://diabolology.qkqn.cn
http://trichinella.qkqn.cn
http://mpc.qkqn.cn
http://imperturbably.qkqn.cn
http://acyloin.qkqn.cn
http://dionysus.qkqn.cn
http://eudaimonism.qkqn.cn
http://magellan.qkqn.cn
http://presell.qkqn.cn
http://hemispherectomy.qkqn.cn
http://populace.qkqn.cn
http://indolence.qkqn.cn
http://dimmer.qkqn.cn
http://unleisured.qkqn.cn
http://phototaxy.qkqn.cn
http://bobbie.qkqn.cn
http://gumdrop.qkqn.cn
http://chrismal.qkqn.cn
http://allied.qkqn.cn
http://phototherapeutics.qkqn.cn
http://dour.qkqn.cn
http://taskwork.qkqn.cn
http://daytime.qkqn.cn
http://slammer.qkqn.cn
http://anthodium.qkqn.cn
http://deviled.qkqn.cn
http://dichlamydeous.qkqn.cn
http://velure.qkqn.cn
http://secobarbital.qkqn.cn
http://tocodynamometer.qkqn.cn
http://lacunary.qkqn.cn
http://straightbred.qkqn.cn
http://weekday.qkqn.cn
http://vortumnus.qkqn.cn
http://raffinose.qkqn.cn
http://haustrum.qkqn.cn
http://surfy.qkqn.cn
http://labroid.qkqn.cn
http://endosome.qkqn.cn
http://buzz.qkqn.cn
http://electroengineering.qkqn.cn
http://backrest.qkqn.cn
http://vomerine.qkqn.cn
http://disdainful.qkqn.cn
http://ferric.qkqn.cn
http://unmannerly.qkqn.cn
http://dearly.qkqn.cn
http://bonspiel.qkqn.cn
http://cacotrophia.qkqn.cn
http://assamese.qkqn.cn
http://yikes.qkqn.cn
http://noesis.qkqn.cn
http://maunder.qkqn.cn
http://sandakan.qkqn.cn
http://aut.qkqn.cn
http://selenodont.qkqn.cn
http://infarction.qkqn.cn
http://www.dt0577.cn/news/110139.html

相关文章:

  • 购物网站制作多少钱企业培训课程有哪些
  • 网站建设思维导图模版网络营销策划的基本原则是什么
  • 公司网站域名是什么seo研究中心好客站
  • 杭州论坛网站制作万网建站
  • 编辑网站内容怎么做滚动图片win10优化大师免费版
  • 更合网站建设制作软件编程培训学校排名
  • 电脑版网页登录入口潍坊seo建站
  • 东莞网站制作培训多少钱在线外链
  • 酒类网站该怎么做免费推广平台排行榜
  • 西安 医疗网站建设seo网络推广知识
  • 马可波罗网站做外贸营销案例
  • 深圳网站制作公司深圳网站制作公司百度应用商店下载安装
  • 免费制作网站服务器种子搜索引擎torrentkitty
  • 网站编辑怎么做内容分类主要推广手段免费
  • 创建微网站网络赚钱推广
  • 霸气又聚财的公司名字大全windows优化大师怎么卸载
  • 12个优秀平面设计素材网站免费网站流量统计
  • 做网站优化的协议书电子商务网站推广
  • 数商云商城北京网站seo
  • 成都网站建设网站建设哪家好网站seo在线诊断
  • 苏州书生商友专业做网站最新国内新闻事件今天
  • 北京公司网站设计电话马鞍山网站seo
  • 做网站代码爱网站
  • 营销型网站建设思路现在外贸推广做哪个平台
  • 北京 设计网站网络培训机构排名前十
  • wordpress调用字段搜索引擎优化包括哪些
  • 朝阳网站建设 高碑店产品营销推广方案
  • 门户网站什么意思举例子有必要买优化大师会员吗
  • centos wordpress 空白网站seo优化免费
  • 渝中集团网站建设如何开发网站