文档章节

PHP MySQLi/PDO_MySQL/PDO_SQLite CRUD(增查改删)

eechen
 eechen
发布于 2016/04/20 22:04
字数 2149
阅读 1297
收藏 8
点赞 3
评论 8

PHP MySQLi:

http://php.net/mysqli

<?php

function db() {
	global $app;
	static $db; //1个请求内多个函数共用1个连接.
	if ($db) {
		return $db;
	} else {
		$db = @new mysqli(
			$app['db_host'], 
			$app['db_user'], 
			$app['db_pass'], 
			$app['db_name'], 
			$app['db_port']
		);
	}
	if ($db->connect_errno) {
		echo $db->connect_error;
		exit();
	}
	$db->set_charset('utf8');
	return $db;
}

function insert($title = '', $content = '') {
	global $app;
	$db = db();
	$stmt = $db->prepare('INSERT INTO posts (post_title, post_content) VALUES (?, ?)');
	$stmt->bind_param('ss', $title, $content);
	$stmt->execute();
	//插入失败,或者没有AUTO_INCREMENT字段,或者不是INSERT语句,insert_id为0.
	return ($stmt->affected_rows !== 0 && $stmt->affected_rows !== -1) ? 
		array(true,  'insert_id' => $stmt->insert_id) : 
		array(false, 'insert_id' => $stmt->insert_id);
}

function select($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		return $db->query('SELECT * FROM posts WHERE id = '.intval($id))->fetch_all(MYSQLI_ASSOC);
	} else {
		return $db->query('SELECT * FROM posts')->fetch_all(MYSQLI_ASSOC);
	}
}

function select_v2($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		$stmt = $db->prepare('SELECT * FROM posts WHERE id = ?');
		$stmt->bind_param('i', $id);
	} else {
		$stmt = $db->prepare('SELECT * FROM posts');
	}
	$stmt->execute();
	//get_result和fetch_all需要mysqlnd支持,PHP从5.4开始内置mysqlnd.
	return $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
}

function update($id, $title = '', $content = '') {
	global $app;
	$db = db();
	//var_export($db->query('SELECT @@autocommit')->fetch_all(MYSQLI_ASSOC)); exit(); //返回1可见MySQL默认会自动提交事务.
	$db->query('SET AUTOCOMMIT=0');  //$db->autocommit(false);
	//注意,InnoDB引擎会把写操作(insert/update/delete)当做事务来处理.
	//所以commit提交事务后autocommit记得重新设为true,否则delete等这些写操作因为没有手动commit会自动回滚.
	$db->query('START TRANSACTION'); //$db->begin_transaction(); PHP从5.5开始才有这个函数.
	$stmt = $db->prepare('UPDATE posts SET post_title = ?, post_content = ? WHERE id = ?');
	$stmt->bind_param('ssi', $title, $content, $id);
	$stmt->execute();
	$db->query('COMMIT'); //$db->commit();
	//$db->query('ROLLBACK'); //$db->rollback();
	$db->query('SET AUTOCOMMIT=1'); //commit提交事务后autocommit记得重新设为true.
	//UPDATE时,如果更新的内容跟原来的内容一样,affected_rows也会返回0.
	return ($stmt->affected_rows !== 0 && $stmt->affected_rows !== -1) ? true : false;
	//affected_rows:
	//返回-1表示查询出错.
	//返回0表示没有数据被修改.
	//返回1表示有1条数据被修改.
	//如果返回的值大于PHP_INT_MAX,这时affected_rows的类型是一个字符串.
}

function delete($id) {
	global $app;
	$db = db();
	$db->query('DELETE FROM posts WHERE id = '.intval($id));
	return ($db->affected_rows !== 0 && $db->affected_rows !== -1) ? true : false;
}

function delete_v2($id) {
	global $app;
	$db = db();
	$stmt = $db->prepare('DELETE FROM posts WHERE id = ?');
	$stmt->bind_param('i', $id);
	$stmt->execute();
	return ($stmt->affected_rows !== 0 && $stmt->affected_rows !== -1) ? true : false;
}

header('Content-Type: text/plain; charset=utf-8');

//mysql -uroot -p -e "CREATE DATABASE IF NOT EXISTS tuxbase DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;GRANT ALL PRIVILEGES ON tuxbase.* TO tux@127.0.0.1 IDENTIFIED BY '913dab0c6788bb8f0';FLUSH PRIVILEGES;"
$app = array(
	'db_host' => '127.0.0.1',
	'db_user' => 'tux',
	'db_pass' => '913dab0c6788bb8f0',
	'db_name' => 'tuxbase',
	'db_port' => 3306
);

$table = "CREATE TABLE IF NOT EXISTS posts (
	id           int(10) unsigned NOT NULL AUTO_INCREMENT,
	post_title   varchar(255)     NOT NULL DEFAULT '',
	post_content text             NOT NULL DEFAULT '',
	PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";

db()->query('DROP TABLE IF EXISTS posts;') or exit();
db()->query($table) or exit();

echo "var_export(insert('标题1', '内容1'));\n";
var_export(insert('标题1', '内容1'));
echo "\n\n";

echo "var_export(insert('标题2', '内容2'));\n";
var_export(insert('标题2', '内容2'));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

echo "var_export(update(2, '标题2_更新','内容2_更新'));\n";
var_export(update(2, '标题2_更新','内容2_更新'));
echo "\n\n";

echo "var_export(select(2));\n";
var_export(select(2));
echo "\n\n";

echo "var_export(delete(2));\n";
var_export(delete(2));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

PHP PDO_MySQL:

http://php.net/pdo

<?php

function db() {
	global $app;
	static $db;
	if ($db) {
		return $db;
	} else {
		/* MySQL */
		try {
			$dsn = "mysql:dbname=$app[db_name];host=$app[db_host];port=$app[db_port];charset=utf8";
			$db = new PDO($dsn, $app['db_user'], $app['db_pass'], array(
				PDO::ATTR_PERSISTENT => false,
				PDO::ATTR_EMULATE_PREPARES => false,
				PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
			));
		} catch (PDOException $e) {
			echo $e->getMessage();
			exit();
		}
		
		/* SQLite 
		try {
			$db = new PDO('sqlite:'.dirname(__FILE__).'/data.db3');
		} catch (PDOException $e) {
			echo $e->getMessage();
			exit();
		}
		*/
	}
	return $db;
}

function insert($title = '', $content = '') {
	global $app;
	$db = db();
	$stmt = $db->prepare('INSERT INTO posts (post_title, post_content) VALUES (?, ?)');
	$stmt->bindParam(1, $title,   PDO::PARAM_STR);
	$stmt->bindParam(2, $content, PDO::PARAM_STR);
	$stmt->execute();
	//插入失败,lastInsertId为0.
	return ($stmt->rowCount() !== 0) ? 
		array(true,  'lastInsertId' => $db->lastInsertId()) : 
		array(false, 'lastInsertId' => $db->lastInsertId());
}

function select($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		return $db->query('SELECT * FROM posts WHERE id = '.intval($id))->fetchAll(PDO::FETCH_ASSOC);
	} else {
		return $db->query('SELECT * FROM posts')->fetchAll(PDO::FETCH_ASSOC);
	}
}

function select_v2($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		$stmt = $db->prepare('SELECT * FROM posts WHERE id = ?');
		$stmt->bindParam(1, $id, PDO::PARAM_INT);
	} else {
		$stmt = $db->prepare('SELECT * FROM posts');
	}
	$stmt->execute();
	return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function update($id, $title = '', $content = '') {
	global $app;
	$db = db();
	
	//echo PDO::ATTR_AUTOCOMMIT; //返回0可见PDO默认禁用自动提交事务.
	//echo $db->getAttribute(PDO::ATTR_AUTOCOMMIT); exit(); //返回1可见MySQL默认会自动提交事务.
	
	//SQLite不支持设置PDO::ATTR_AUTOCOMMIT:
	//SQLite: Uncaught exception 'PDOException' with message 'The auto-commit mode cannot be changed for this driver'
	$db->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
	$db->beginTransaction();

	//方法1(问号占位符)
	$stmt = $db->prepare('UPDATE posts SET post_title = ?, post_content = ? WHERE id = ?');
	$stmt->execute(array($title,$content,$id)); //所有值视作PDO::PARAM_STR处理
	
	//方法1(命名占位符)
	//$stmt = $db->prepare('UPDATE posts SET post_title = :title, post_content = :content WHERE id = :id');
	//$stmt->execute(array(':title' => $title,':content' => $content,':id' => $id)); //所有值视作PDO::PARAM_STR处理
	
	//方法2(问号占位符)
	//$stmt = $db->prepare('UPDATE posts SET post_title = ?, post_content = ? WHERE id = ?');
	//$stmt->bindParam(1, $title,   PDO::PARAM_STR);
	//$stmt->bindParam(2, $content, PDO::PARAM_STR);
	//$stmt->bindParam(3, $id,      PDO::PARAM_INT);
	//$stmt->execute();
	
	//方法2(命名占位符)
	//$stmt = $db->prepare('UPDATE posts SET post_title = :title, post_content = :content WHERE id = :id');
	//$stmt->bindParam(':title',   $title,   PDO::PARAM_STR);
	//$stmt->bindParam(':content', $content, PDO::PARAM_STR);
	//$stmt->bindParam(':id',      $id,      PDO::PARAM_INT);
	//$stmt->execute();
	
	//MySQLi只有一种写法(MySQLi不支持命名占位符)
	//$stmt = $db->prepare('UPDATE posts SET post_title = ?, post_content = ? WHERE id = ?');
	//$stmt->bind_param('ssi', $title, $content, $id);
	
	echo 'sleep(3);'."\n";
	sleep(3);
	
	$db->commit();
	$db->setAttribute(PDO::ATTR_AUTOCOMMIT, true); //commit提交事务后autocommit记得重新设为true
	return ($stmt->rowCount() !== 0) ? true : false;
}

function delete($id) {
	global $app;
	$db = db();
	return ($db->query('DELETE FROM posts WHERE id = '.intval($id))->rowCount() !== 0) ? true : false;
}

function delete_v2($id) {
	global $app;
	$db = db();
	$stmt = $db->prepare('DELETE FROM posts WHERE id = ?');
	$stmt->bindParam(1, $id, PDO::PARAM_INT);
	$stmt->execute();
	return ($stmt->rowCount() !== 0) ? true : false;
}

header('Content-Type: text/plain; charset=utf-8');

$app = array(
	'db_host' => '127.0.0.1',
	'db_user' => 'tux',
	'db_pass' => '913dab0c6788bb8f0',
	'db_name' => 'tuxbase',
	'db_port' => 3306
);

$mysql = "CREATE TABLE IF NOT EXISTS posts (
	id           int(10) unsigned NOT NULL AUTO_INCREMENT,
	post_title   varchar(255)     NOT NULL DEFAULT '',
	post_content text             NOT NULL DEFAULT '',
	PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";

$sqlite = "CREATE TABLE IF NOT EXISTS posts (
	id           INTEGER PRIMARY KEY,
	post_title   VARCHAR(255) NOT NULL,
	post_content TEXT         NOT NULL
)";

db()->query('DROP TABLE IF EXISTS posts;') or exit();
db()->query($mysql) or exit();

//并发时,SQLite在insert时因为库文件被其他请求锁住而导致阻塞
echo "var_export(insert('标题1', '内容1'));\n";
var_export(insert('标题1', '内容1'));
echo "\n\n";

echo "var_export(insert('标题2', '内容2'));\n";
var_export(insert('标题2', '内容2'));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

echo "var_export(update(2, '标题2_更新','内容2_更新'));\n";
var_export(update(2, '标题2_更新','内容2_更新'));
echo "\n\n";

echo "var_export(select(2));\n";
var_export(select(2));
echo "\n\n";

echo "var_export(delete(2));\n";
var_export(delete(2));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

PHP PDO_SQLite:

<?php

function db() {
	global $app;
	static $db;
	if ($db) {
		return $db;
	} else {
		/* MySQL 
		try {
			$dsn = "mysql:dbname=$app[db_name];host=$app[db_host];port=$app[db_port];charset=utf8";
			$db = new PDO($dsn, $app['db_user'], $app['db_pass'], array(
				PDO::ATTR_PERSISTENT => false,
				PDO::ATTR_EMULATE_PREPARES => false,
				PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
			));
		} catch (PDOException $e) {
			echo $e->getMessage();
			exit();
		}
		*/
		/* SQLite */
		try {
			$db = new PDO('sqlite:'.dirname(__FILE__).'/data.db3');
		} catch (PDOException $e) {
			echo $e->getMessage();
			exit();
		}
		
	}
	return $db;
}

function insert($title = '', $content = '') {
	global $app;
	$db = db();
	$stmt = $db->prepare('INSERT INTO posts (post_title, post_content) VALUES (?, ?)');
	$stmt->bindParam(1, $title,   PDO::PARAM_STR);
	$stmt->bindParam(2, $content, PDO::PARAM_STR);
	$stmt->execute();
	return ($stmt->rowCount() !== 0) ? 
		array(true,  'lastInsertId' => $db->lastInsertId()) : 
		array(false, 'lastInsertId' => $db->lastInsertId());
}

function select($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		return $db->query('SELECT * FROM posts WHERE id = '.intval($id))->fetchAll(PDO::FETCH_ASSOC);
	} else {
		return $db->query('SELECT * FROM posts')->fetchAll(PDO::FETCH_ASSOC);
	}
}

function select_v2($id = '') {
	global $app;
	$db = db();
	if (!empty($id)) {
		$stmt = $db->prepare('SELECT * FROM posts WHERE id = ?');
		$stmt->bindParam(1, $id, PDO::PARAM_INT);
	} else {
		$stmt = $db->prepare('SELECT * FROM posts');
	}
	$stmt->execute();
	return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function update($id, $title = '', $content = '') {
	global $app;
	$db = db();
	
	//echo PDO::ATTR_AUTOCOMMIT; //返回0可见PDO默认禁用自动提交事务.
	//echo $db->getAttribute(PDO::ATTR_AUTOCOMMIT); exit(); //返回1可见MySQL默认会自动提交事务.
	
	//SQLite不支持设置PDO::ATTR_AUTOCOMMIT:
	//SQLite: Uncaught exception 'PDOException' with message 'The auto-commit mode cannot be changed for this driver'
	//$db->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
	$db->beginTransaction();
	$stmt = $db->prepare('UPDATE posts SET post_title = ?, post_content = ? WHERE id = ?');
	
	$stmt->execute(array($title,$content,$id)); //所有值视作PDO::PARAM_STR处理
	//$stmt->execute(array(':title' => $title,':content' => $content,':id' => $id));
	//$stmt->bind_param('ssi', $title, $content, $id); //对比mysqli
	
	echo 'sleep(3);'."\n";
	sleep(3);
	
	$db->commit();
	//$db->setAttribute(PDO::ATTR_AUTOCOMMIT, true); //commit提交事务后autocommit记得重新设为true
	return ($stmt->rowCount() !== 0) ? true : false;
}

function delete($id) {
	global $app;
	$db = db();
	return ($db->query('DELETE FROM posts WHERE id = '.intval($id))->rowCount() !== 0) ? true : false;
}

function delete_v2($id) {
	global $app;
	$db = db();
	$stmt = $db->prepare('DELETE FROM posts WHERE id = ?');
	$stmt->bindParam(1, $id, PDO::PARAM_INT);
	$stmt->execute();
	return ($stmt->rowCount() !== 0) ? true : false;
}

header('Content-Type: text/plain; charset=utf-8');

$app = array(
	'db_host' => '127.0.0.1',
	'db_user' => 'tux',
	'db_pass' => '913dab0c6788bb8f0',
	'db_name' => 'tuxbase',
	'db_port' => 3306
);

$mysql = "CREATE TABLE IF NOT EXISTS posts (
	id           int(10) unsigned NOT NULL AUTO_INCREMENT,
	post_title   varchar(255)     NOT NULL DEFAULT '',
	post_content text             NOT NULL DEFAULT '',
	PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;";

$sqlite = "CREATE TABLE IF NOT EXISTS posts (
	id           INTEGER PRIMARY KEY,
	post_title   VARCHAR(255) NOT NULL,
	post_content TEXT         NOT NULL
)";

db()->query('DROP TABLE IF EXISTS posts;') or exit();
db()->query($sqlite) or exit();

//并发时,SQLite在insert时因为库文件被其他请求锁住而导致阻塞
echo "var_export(insert('标题1', '内容1'));\n";
var_export(insert('标题1', '内容1'));
echo "\n\n";

echo "var_export(insert('标题2', '内容2'));\n";
var_export(insert('标题2', '内容2'));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

echo "var_export(update(2, '标题2_更新','内容2_更新'));\n";
var_export(update(2, '标题2_更新','内容2_更新'));
echo "\n\n";

echo "var_export(select(2));\n";
var_export(select(2));
echo "\n\n";

echo "var_export(delete(2));\n";
var_export(delete(2));
echo "\n\n";

echo "var_export(select());\n";
var_export(select());
echo "\n\n";

 

© 著作权归作者所有

共有 人打赏支持
eechen

eechen

粉丝 975
博文 107
码字总数 55962
作品 1
深圳
加载中

评论(8)

qycms_cn
qycms_cn
@ eechen +1024
eechen
eechen
@陨落人间
连mysql和mysqli两套函数都分不清的人就不要自以为是了.http://php.net/manual/zh/mysqli.overview.php 官方文档的建议: mysqli(首选) pdo_mysql(建议) mysql(不建议) 还有phpMyAdmin用的也是mysqli操作MySQL.对于MySQL而言,mysqli远比PDO合适.

全局数组多么方便的东西,用来传递参数再合适不过,去特么狗屁的设计模式.Discuz!的全局数组$_G你不知道?哈哈.一个static静态变量就已经能够避免多次connect数据库,就是这么简单.不服,写一篇博文来PK呀,别特么光说不练眼高手低呀.哈哈.
陨落人间
陨落人间
而且如果是连接几个不同数据库,连工厂模式也不用,。。照上面的兄弟说的,槽点一堆。@彩虹糖tang , @eechen
陨落人间
陨落人间
@eechen , 大神代码,果断差评,$app,居然用全局 global变量,$db连接没有使用单例模式,

$db居然还用mysql函数,还用了@符号
eechen
eechen

引用来自“彩虹糖tang”的评论

你这代码质量确实不咋滴啊,第一个函数就不少槽点(感谢在osc社区为推广php做出的莫大努力)
那就请你写一篇更咋滴的博文让大家学习学习你的写法嘛,看看是你的XX模式好用还是我的全局变量好用.
游走的鱼
彩虹糖tang 。。。。
彩虹糖tang
彩虹糖tang
你这代码质量确实不咋滴啊,第一个函数就不少槽点(感谢在osc社区为推广php做出的莫大努力)
修改IT资产库存管理(ITDB)使用mysql数据库

ITDB默认使用Sqlite作为数据库,本次修改的版本为官方网站1.14版本 1、修改步骤: 将数据库转换到mysql数据库中 修改ITDB程序代码使用mysql数据库 2、转换sqlite数据库到mysql数据库 下载并安...

Tevisky
2015/02/12
0
0
osc上一位哥们的 php编译参数

Ubuntu 12.04, GCC 4.6.3, i5-3230M 编译安装 PHP 5.5.8 耗时6分40多秒time sh -c "./configure.sh && make && make install" > configure.log configure.sh !/bin/bash ./configure --prefi......

渔樵耕读
2014/05/03
0
0
写一个“特殊”的查询构造器 - (一、程序结构,基础封装)

程序的结构 本篇开始,正式进入编码实践中。首先,简单的规划下程序的结构。 如上一篇所说的,我们需要一个基类 PDODriver 用来封装 PDO 的一些公用的方法,Mysql 等每个数据库都新建一个类 ...

MrQ被抢注了
05/11
0
0
Linux(CentOS6.5)上 PHP PDO扩展库的安装

下面给大家分享PDO扩展在CentOS6.5上面的安装(黄色字体为命令) cd php-7.2.0/ext/pdo_mysql // 具体路径自行修改 /usr/local/php/bin/phpize // 建立PHP的外挂模块 ./configure --with-php...

我只爱庄宝贝
05/16
0
0
加速开发的最轻量的PHP数据库框架 Medoo

为什么选择 Medoo? -非常的轻量 只有 15KB,只需include即可。 -简单 非常的容易学习,快速上手。 -强大 支持各种常见的SQL查询。 -兼容 支持各种数据:MySQL, MSSQL, SQLite, MariaDB, Orac...

40岁的青春
2015/05/25
0
0
教大家如何在Linux(CentOS6.5)上安装PHP PDO扩展库

下面给大家分享PDO扩展如何在CentOS6.5上安装(蓝色字体为命令) 1.cd php-7.2.0/ext/pdo_mysql //具体路径自行修改 2./usr/local/php/bin/phpize//建立PHP的外挂模块 3../configure --with...

问题终结者
07/07
0
0
Medoo入门:安装和配置-Medoo使用指南

Medoo是什么呢?看看官方是怎么写的: The Lightest PHP database framework to accelerate development! //译: 加速开发的最轻量的PHP数据库框架! Medoo的口号还是喊得很响的,实际上是否真...

Veekit
2014/04/20
0
0
Install Nginx/PHP-FPM on CentOS/RHEL

Install Nginx, PHP 5.5.15 and PHP-FPM on Fedora 20/19/18/17, CentOS 7/6.5/5.10, Red Hat (RHEL) 7/6.5/5.10 1. Change to root user. su 2. Install needed repositories CentOS 7/6.5/......

linuxjd
2014/08/17
0
0
PHP configure --help说明

配置帮助表: --help 显示帮助信息 display this help and exit --version 显示版本 display version information and exit --quiet, --silent 不显示checking……信息 do not print`checkin......

熊代码蜀黍
2014/10/20
0
0
YUDBModel【绿色插件】-对象序列化、反序列化、对象一键增删改查

一、YUDBModel 介绍 架构: 使用runtime和Sqlite实现NSObject扩展类YUDBModel,直接实现(json反序列化对象-对象增删改查数据库-对象序列化) 易用: 无需继承,直接实现序列化、反序列化、一行代...

BruceYu的博客
2015/08/21
0
4

没有更多内容

加载失败,请刷新页面

加载更多

下一页

崛起于Springboot2.X之开发拦截器(21)

序言:几乎所有项目都需要拦截器,所以小伙伴们必须要掌握这门技术哦,不然只会mybaits增删改查那是实习生干的活呀。 1、创建拦截器类,implements HandlerInterceptor public class MyInce...

木九天
16分钟前
1
0
(转)SQL语句的执行顺序

(7) SELECT (8) DISTINCT <select_list> (1) FROM <left_table> (3) <join_type> JOIN <right_table> (2) ON <join_condition> (4) WHERE <where_condition> (5) GROUP BY <group_by_list> (......

Avner
26分钟前
0
0
1.14 救援模式

确保开机启动时连接镜像文件,如果是真机服务器,就需要:U盘或光盘镜像启动进入BIOS 不同主板进入bios按键不同,一般是F12或Esc 光标:移动到Boot(开机启动项) 减号移动:光标选中行,按-...

小丑鱼00
33分钟前
0
0
ES11-全文检索

高级别全文检索通常用于在全文本字段(如电子邮件正文)上运行全文检索。 他们了解如何分析被查询的字段,并在执行之前将每个字段的分析器(或search_analyzer)应用于查询字符串。 1.term查...

贾峰uk
36分钟前
0
0
java 复制对象有哪些方式

java 复制对象有哪些方式 Apache的 Common beanutils库 org.apache.commons.beanutils.BeanUtils.copyProperties(dest,origin); Springframework 的BeanUtil 依赖: <dependency> ......

黄威
52分钟前
2
0
jstack的简单使用

公司测试反应, 一个java应用的机器, 即使不做交易, cpu始终是30%多, 于是想到了jstack, 实践步骤记录一下: 1, 找出java应用的进程号 ps -ef|grep 应用名|grep -v grep 2, 找出pid下的cpu占用...

零二一七
59分钟前
1
0
导入CSV文件就行数据整理分析

#-*-coding:utf-8-*-import csv,os,re,mathlocalPath=input("请输入所有群文件的根目录:") #所有QQ群文件的物理根目录路径def info(): info_dic=[] dirList=os.listdi...

Kefy
今天
5
0
CoreText进阶(六)-内容大小计算和自动布局

CoreText进阶(六)-内容大小计算和自动布局 其它文章: CoreText 入门(一)-文本绘制 CoreText入门(二)-绘制图片 CoreText进阶(三)-事件处理 CoreText进阶(四)-文字行数限制和显示更...

aron1992
今天
1
0
一个Unity高人的博客,涉猎范围很广,深度也很深。

https://blog.csdn.net/ecidevilin/article/list/

爽歪歪ES
今天
0
0
Spring Cloud Config-Git后端

EnvironmentRepository的默认实现使用Git后端,这对于管理升级和物理环境以及审核更改非常方便。要更改存储库的位置,可以在Config Server中设置“spring.cloud.config.server.git.uri”配置...

itcloud
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部