1. <?php
  2.  
  3. $config = include 'config.php'; //引入数据库配置文件
  4. $model = new Model($config);
  5. //测试案例
  6. // $saveData=['username'=>'张三','mobile'=>12334123];
  7. // echo $model->table('user')->insert($saveData);
  8. // var_dump($model->table('user')->where('id=5')->delete());
  9. // var_dump($model->table('user')->limit('0,6')->field('username,mobile')->where('id>1')->order('id desc')->select());
  10. // $updateData=['username'=>'张三'];
  11. // var_dump($model->table('user')->where('id=3')->update($updateData));
  12. // var_dump($model->table('user')->max('mobile'));
  13. // var_dump($model->table('user')->getByUserName('张三'));
  14. // var_dump($model->sql);
  15.  
  16. class Model
  17. {
  18. //主机名
  19. protected $host;
  20. //用户名
  21. protected $user;
  22. //密码
  23. protected $pwd;
  24. //数据库名
  25. protected $dbname;
  26. //字符集
  27. protected $charset;
  28. //数据库前缀
  29. protected $prefix;
  30.  
  31. //数据库连接资源
  32. protected $link;
  33. //数据表名 这里可以自己指定表名
  34. protected $tableName;
  35.  
  36. //sql语句
  37. protected $sql;
  38. //操作数组 存放的就是所有的查询条件
  39. protected $options;
  40.  
  41. /**
  42. * 构造方法,对成员变量进行初始化
  43. *
  44. * @param [type] $config
  45. */
  46. function __construct($config)
  47. {
  48. //对成员变量一一进行初始化
  49. $this->host = $config['DB_HOST'];
  50. $this->user = $config['DB_USER'];
  51. $this->pwd = $config['DB_PWD'];
  52. $this->dbname = $config['DB_NAME'];
  53. $this->charset = $config['DB_CHARSET'];
  54. $this->prefix = $config['DB_PREFIX'];
  55.  
  56. //连接数据库
  57. $this->link = $this->connect();
  58.  
  59. //得到数据表名 user===>UserModel
  60. $this->tableName = $this->getTableName();
  61.  
  62. //初始化option数组
  63. $this->initOptions();
  64. }
  65.  
  66. /**
  67. * 连接数据库
  68. *
  69. * @return void
  70. */
  71. protected function connect()
  72. {
  73. $link = mysqli_connect($this->host, $this->user, $this->pwd);
  74. if (!$link) {
  75. die('数据库连接失败');
  76. }
  77. //选择数据库
  78. mysqli_select_db($link, $this->dbname);
  79. //设置字符集
  80. mysqli_set_charset($link, $this->charset);
  81. //返回连接成功的资源
  82. return $link;
  83. }
  84.  
  85. /**
  86. * 得到数据表名
  87. *
  88. * @return void
  89. */
  90. protected function getTableName()
  91. {
  92. //第一种,如果设置了成员变量,那么通过成员变量来得到表名
  93. if (!empty($this->tableName)) {
  94. return $this->prefix . $this->tableName;
  95. }
  96. //第二种,如果没有设置成员变量,那么通过类名来得到表名
  97. //得到当前类名字符串
  98. $className = get_class($this);
  99. //user UserModel goods GoodsModel
  100. $table = strtolower(substr($className, 0, -5));
  101. return $this->prefix . $table;
  102. }
  103.  
  104. /**
  105. * 初始化option数组
  106. *
  107. * @return void
  108. */
  109. protected function initOptions()
  110. {
  111. $arr = ['where', 'table', 'field', 'order', 'group', 'having', 'limit'];
  112. foreach ($arr as $value) {
  113. //将options数组中这些键对应的值全部清空
  114. $this->options[$value] = '';
  115. if ($value === 'table') {
  116. $this->options[$value] = $this->tableName;
  117. } elseif ($value == 'field') {
  118. $this->options[$value] = '*';
  119. }
  120. }
  121. }
  122.  
  123. /**
  124. * field方法
  125. *
  126. * @param [type] $field
  127. * @return void
  128. */
  129. function field($field)
  130. {
  131. //如果不为空,再进行处理
  132. if (!empty($field)) {
  133. if (is_string($field)) {
  134. $this->options['field'] = $field;
  135. } elseif (is_array($field)) {
  136. $this->options['field'] = join(',', $field);
  137. }
  138. }
  139. return $this;
  140. }
  141.  
  142. /**
  143. * //table方法
  144. *
  145. * @param [type] $table
  146. * @return void
  147. */
  148. function table($table)
  149. {
  150. if (!empty($table)) {
  151. $this->options['table'] = $this->prefix . $table;
  152. }
  153. return $this;
  154. }
  155.  
  156. /**
  157. * where方法
  158. *
  159. * @param [type] $where
  160. * @return void
  161. */
  162. function where($where)
  163. {
  164. if (!empty($where)) {
  165. $this->options['where'] = 'where ' . $where;
  166. }
  167. return $this;
  168. }
  169.  
  170. /**
  171. * group方法
  172. *
  173. * @param [type] $group
  174. * @return void
  175. */
  176. function group($group)
  177. {
  178. if (!empty($group)) {
  179. $this->options['group'] = 'group by ' . $group;
  180. }
  181. return $this;
  182. }
  183.  
  184. /**
  185. * having方法
  186. *
  187. * @param [type] $having
  188. * @return void
  189. */
  190. function having($having)
  191. {
  192. if (!empty($having)) {
  193. $this->options['having'] = 'having ' . $having;
  194. }
  195. return $this;
  196. }
  197.  
  198. /**
  199. * order方法
  200. *
  201. * @param [type] $order
  202. * @return void
  203. */
  204. function order($order)
  205. {
  206. if (!empty($order)) {
  207. $this->options['order'] = 'order by ' . $order;
  208. }
  209. return $this;
  210. }
  211.  
  212. /**
  213. * limit方法
  214. *
  215. * @param [type] $limit
  216. * @return void
  217. */
  218. function limit($limit)
  219. {
  220. if (!empty($limit)) {
  221. if (is_string($limit)) {
  222. $this->options['limit'] = 'limit ' . $limit;
  223. } elseif (is_array($limit)) {
  224. $this->options['limit'] = 'limit ' . join(',', $limit);
  225. }
  226. }
  227. return $this;
  228. }
  229.  
  230. /**
  231. * select方法
  232. *
  233. * @return void
  234. */
  235. function select()
  236. {
  237. //先预写一个带占位符的sql语句
  238. $sql = 'select %FIELD% from %TABLE% %WHERE% %GROUP% %HAVING% %ORDER% %LIMIT%';
  239. //将options中对应的值依次的替换上面的占位符
  240. $sql = str_replace(
  241. ['%FIELD%', '%TABLE%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%'],
  242. [
  243. $this->options['field'], $this->options['table'], $this->options['where'], $this->options['group'],
  244. $this->options['having'], $this->options['order'], $this->options['limit']
  245. ],
  246. $sql
  247. );
  248. //保存一份sql语句
  249. $this->sql = $sql;
  250. //执行sql语句
  251. return $this->query($sql);
  252. }
  253.  
  254. /**
  255. * query
  256. *
  257. * @param [type] $sql
  258. * @return void
  259. */
  260. function query($sql)
  261. {
  262. //清空option数组中的值
  263. $this->initOptions();
  264. //执行sql语句
  265. $result = mysqli_query($this->link, $sql);
  266. //提取结果集存放到数组中
  267. if ($result && mysqli_affected_rows($this->link)) {
  268. while ($data = mysqli_fetch_assoc($result)) {
  269. $newData[] = $data;
  270. }
  271. }
  272. //返回结果集
  273. return $newData;
  274. }
  275.  
  276. /**
  277. * exec
  278. *
  279. * @param [type] $sql
  280. * @param boolean $isInsert
  281. * @return void
  282. */
  283. function exec($sql, $isInsert = false)
  284. {
  285. //清空option数组中的值
  286. $this->initOptions();
  287. //执行sql语句
  288. $result = mysqli_query($this->link, $sql);
  289. if ($result && mysqli_affected_rows($this->link)) {
  290. //判断是否是插入语句,根据不同的语句返回不同的结果
  291. if ($isInsert) {
  292. return mysqli_insert_id($this->link);
  293. } else {
  294. return mysqli_affected_rows($this->link);
  295. }
  296. }
  297. return false;
  298. }
  299.  
  300. function __get($name)
  301. {
  302. if ($name == 'sql') {
  303. return $this->sql;
  304. }
  305. return false;
  306. }
  307.  
  308. /**
  309. * insert函数
  310. * insert into 表名(字段) value(值)
  311. *
  312. * @param [type] $data 关联数组,键就是字段名,值是字段值
  313. * @return void
  314. */
  315. function insert($data)
  316. {
  317. //处理值是字符串问题,两边需要添加单或双引号
  318. $data = $this->parseValue($data);
  319. //提取所有的键,即就是所有的字段
  320. $keys = array_keys($data);
  321. //提取所有的值
  322. $values = array_values($data);
  323. //增加数据的sql语句
  324. $sql = 'insert into %TABLE%(%FIELD%) values(%VALUES%)';
  325. $sql = str_replace(['%TABLE%', '%FIELD%', '%VALUES%'], [$this->options['table'], join(',', $keys), join(',', $values)], $sql);
  326. $this->sql = $sql;
  327. return $this->exec($sql, true);
  328. }
  329.  
  330. /**
  331. * 传递进来一个数组,将数组中值为字符串的两边加上引号
  332. *
  333. * @param [type] $data
  334. * @return void
  335. */
  336. protected function parseValue($data)
  337. {
  338. //遍历数组,判断是否为字符串,若是字符串,将其两边添加引号
  339. foreach ($data as $key => $value) {
  340. if (is_string($value)) {
  341. $value = '"' . $value . '"';
  342. }
  343. $newData[$key] = $value;
  344. }
  345. //返回处理后的数组
  346. return $newData;
  347. }
  348.  
  349. /**
  350. * 删除函数
  351. *
  352. * @return void
  353. */
  354. function delete()
  355. {
  356. //拼接sql语句
  357. $sql = 'delete from %TABLE% %WHERE%';
  358. $sql = str_replace(['%TABLE%', '%WHERE%'], [$this->options['table'], $this->options['where']], $sql);
  359. //保存sql语句
  360. $this->sql = $sql;
  361. //执行sql语句
  362. return $this->exec($sql);
  363. }
  364.  
  365. /**
  366. * 更新函数
  367. * update 表名 set 字段名=字段值,字段名=字段值 where
  368. *
  369. * @param [type] $data
  370. * @return void
  371. */
  372. function update($data)
  373. {
  374. //处理$data数组中值为字符串加引号的问题
  375. $data = $this->parseValue($data);
  376. //将关联数组拼接为固定的格式 键=值,键=值
  377. $value = $this->parseUpdate($data);
  378. //准备sql语句
  379. $sql = 'update %TABLE% set %VALUE% %WHERE%';
  380. $sql = str_replace(['%TABLE%', '%VALUE%', '%WHERE%'], [$this->options['table'], $value, $this->options['where']], $sql);
  381. //保存sql语句
  382. $this->sql = $sql;
  383. //执行sql语句
  384. return $this->exec($sql);
  385. }
  386.  
  387. /**
  388. * 将关联数组拼接为固定的格式
  389. *
  390. * @param [type] $data
  391. * @return void
  392. */
  393. protected function parseUpdate($data)
  394. {
  395. foreach ($data as $key => $value) {
  396. $newData[] = $key . '=' . $value;
  397. }
  398. return join(',', $newData);
  399. }
  400.  
  401. /**
  402. * max函数
  403. *
  404. * @param [type] $field
  405. * @return void
  406. */
  407. function max($field)
  408. {
  409. //通过调用自己封装的方法进行查询
  410. $result = $this->field('max(' . $field . ') as max')->select();
  411. //select方法返回的是一个二维数组
  412. return $result[0]['max'];
  413. }
  414.  
  415. /**
  416. * 析构方法
  417. */
  418. function __destruct()
  419. {
  420. mysqli_close($this->link);
  421. }
  422.  
  423. /**
  424. * getByName getByAge
  425. *
  426. * @param [type] $name
  427. * @param [type] $args
  428. * @return void
  429. */
  430. function __call($name, $args)
  431. {
  432. //获取前5个字符
  433. $str = substr($name, 0, 5);
  434. //获取后面的字段名
  435. $field = strtolower(substr($name, 5));
  436. //判断前五个字符是否是getby
  437. if ($str === 'getBy') {
  438. return $this->where($field . '="' . $args[0] . '"')->select();
  439. }
  440. return false;
  441. }
  442. }

confing数据库配置文件,confing.php

  1. <?php
  2. return [
  3. 'DB_HOST'=>'localhost',
  4. 'DB_USER'=>'root',
  5. 'DB_PWD'=>'123456',
  6. 'DB_NAME'=>'test',
  7. 'DB_CHARSET'=>'utf8',
  8. 'DB_PREFIX'=>'t_',
  9. ];
<?php
$config = include 'config.php'; //引入数据库配置文件
$model = new Model($config);
//测试案例
// $saveData=['username'=>'张三','mobile'=>12334123];
// echo $model->table('user')->insert($saveData);
// var_dump($model->table('user')->where('id=5')->delete());
// var_dump($model->table('user')->limit('0,6')->field('username,mobile')->where('id>1')->order('id desc')->select());
// $updateData=['username'=>'张三'];
// var_dump($model->table('user')->where('id=3')->update($updateData));
// var_dump($model->table('user')->max('mobile'));
// var_dump($model->table('user')->getByUserName('张三'));
// var_dump($model->sql);
class Model
{
//主机名
protected $host;
//用户名
protected $user;
//密码
protected $pwd;
//数据库名
protected $dbname;
//字符集
protected $charset;
//数据库前缀
protected $prefix;
//数据库连接资源
protected $link;
//数据表名 这里可以自己指定表名
protected $tableName;
//sql语句
protected $sql;
//操作数组 存放的就是所有的查询条件
protected $options;
/**
* 构造方法,对成员变量进行初始化
*
* @param [type] $config
*/
function __construct($config)
{
//对成员变量一一进行初始化
$this->host = $config['DB_HOST'];
$this->user = $config['DB_USER'];
$this->pwd = $config['DB_PWD'];
$this->dbname = $config['DB_NAME'];
$this->charset = $config['DB_CHARSET'];
$this->prefix = $config['DB_PREFIX'];
//连接数据库
$this->link = $this->connect();
//得到数据表名 user===>UserModel
$this->tableName = $this->getTableName();
//初始化option数组
$this->initOptions();
}
/**
* 连接数据库
*
* @returnvoid
*/
protected function connect()
{
$link = mysqli_connect($this->host, $this->user, $this->pwd);
if (!$link) {
die('数据库连接失败');
}
//选择数据库
mysqli_select_db($link, $this->dbname);
//设置字符集
mysqli_set_charset($link, $this->charset);
//返回连接成功的资源
return $link;
}
/**
* 得到数据表名
*
* @returnvoid
*/
protected function getTableName()
{
//第一种,如果设置了成员变量,那么通过成员变量来得到表名
if (!empty($this->tableName)) {
return $this->prefix . $this->tableName;
}
//第二种,如果没有设置成员变量,那么通过类名来得到表名
//得到当前类名字符串
$className = get_class($this);
//user UserModel goods GoodsModel
$table = strtolower(substr($className, , -));
return $this->prefix . $table;
}
/**
* 初始化option数组
*
* @returnvoid
*/
protected function initOptions()
{
$arr = ['where', 'table', 'field', 'order', 'group', 'having', 'limit'];
foreach ($arr as $value) {
//将options数组中这些键对应的值全部清空
$this->options[$value] = '';
if ($value === 'table') {
$this->options[$value] = $this->tableName;
} elseif ($value == 'field') {
$this->options[$value] = '*';
}
}
}
/**
* field方法
*
* @param [type] $field
* @returnvoid
*/
function field($field)
{
//如果不为空,再进行处理
if (!empty($field)) {
if (is_string($field)) {
$this->options['field'] = $field;
} elseif (is_array($field)) {
$this->options['field'] = join(',', $field);
}
}
return $this;
}
/**
* //table方法
*
* @param [type] $table
* @returnvoid
*/
function table($table)
{
if (!empty($table)) {
$this->options['table'] = $this->prefix . $table;
}
return $this;
}
/**
* where方法
*
* @param [type] $where
* @returnvoid
*/
function where($where)
{
if (!empty($where)) {
$this->options['where'] = 'where ' . $where;
}
return $this;
}
/**
* group方法
*
* @param [type] $group
* @returnvoid
*/
function group($group)
{
if (!empty($group)) {
$this->options['group'] = 'group by ' . $group;
}
return $this;
}
/**
* having方法
*
* @param [type] $having
* @returnvoid
*/
function having($having)
{
if (!empty($having)) {
$this->options['having'] = 'having ' . $having;
}
return $this;
}
/**
* order方法
*
* @param [type] $order
* @returnvoid
*/
function order($order)
{
if (!empty($order)) {
$this->options['order'] = 'order by ' . $order;
}
return $this;
}
/**
* limit方法
*
* @param [type] $limit
* @returnvoid
*/
function limit($limit)
{
if (!empty($limit)) {
if (is_string($limit)) {
$this->options['limit'] = 'limit ' . $limit;
} elseif (is_array($limit)) {
$this->options['limit'] = 'limit ' . join(',', $limit);
}
}
return $this;
}
/**
* select方法
*
* @returnvoid
*/
function select()
{
//先预写一个带占位符的sql语句
$sql = 'select %FIELD% from %TABLE% %WHERE% %GROUP% %HAVING% %ORDER% %LIMIT%';
//将options中对应的值依次的替换上面的占位符
$sql = str_replace(
['%FIELD%', '%TABLE%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%'],
[
$this->options['field'], $this->options['table'], $this->options['where'], $this->options['group'],
$this->options['having'], $this->options['order'], $this->options['limit']
],
$sql
);
//保存一份sql语句
$this->sql = $sql;
//执行sql语句
return $this->query($sql);
}
/**
* query
*
* @param [type] $sql
* @returnvoid
*/
function query($sql)
{
//清空option数组中的值
$this->initOptions();
//执行sql语句
$result = mysqli_query($this->link, $sql);
//提取结果集存放到数组中
if ($result && mysqli_affected_rows($this->link)) {
while ($data = mysqli_fetch_assoc($result)) {
$newData[] = $data;
}
}
//返回结果集
return $newData;
}
/**
* exec
*
* @param [type] $sql
* @paramboolean $isInsert
* @returnvoid
*/
function exec($sql, $isInsert = false)
{
//清空option数组中的值
$this->initOptions();
//执行sql语句
$result = mysqli_query($this->link, $sql);
if ($result && mysqli_affected_rows($this->link)) {
//判断是否是插入语句,根据不同的语句返回不同的结果
if ($isInsert) {
return mysqli_insert_id($this->link);
} else {
return mysqli_affected_rows($this->link);
}
}
return false;
}
function __get($name)
{
if ($name == 'sql') {
return $this->sql;
}
return false;
}
/**
* insert函数
* insert into 表名(字段) value(值)
*
* @param [type] $data 关联数组,键就是字段名,值是字段值
* @returnvoid
*/
function insert($data)
{
//处理值是字符串问题,两边需要添加单或双引号
$data = $this->parseValue($data);
//提取所有的键,即就是所有的字段
$keys = array_keys($data);
//提取所有的值
$values = array_values($data);
//增加数据的sql语句
$sql = 'insert into %TABLE%(%FIELD%) values(%VALUES%)';
$sql = str_replace(['%TABLE%', '%FIELD%', '%VALUES%'], [$this->options['table'], join(',', $keys), join(',', $values)], $sql);
$this->sql = $sql;
return $this->exec($sql, true);
}
/**
* 传递进来一个数组,将数组中值为字符串的两边加上引号
*
* @param [type] $data
* @returnvoid
*/
protected function parseValue($data)
{
//遍历数组,判断是否为字符串,若是字符串,将其两边添加引号
foreach ($data as $key => $value) {
if (is_string($value)) {
$value = '"' . $value . '"';
}
$newData[$key] = $value;
}
//返回处理后的数组
return $newData;
}
/**
* 删除函数
*
* @returnvoid
*/
function delete()
{
//拼接sql语句
$sql = 'delete from %TABLE% %WHERE%';
$sql = str_replace(['%TABLE%', '%WHERE%'], [$this->options['table'], $this->options['where']], $sql);
//保存sql语句
$this->sql = $sql;
//执行sql语句
return $this->exec($sql);
}
/**
* 更新函数
* update 表名 set 字段名=字段值,字段名=字段值 where
*
* @param [type] $data
* @returnvoid
*/
function update($data)
{
//处理$data数组中值为字符串加引号的问题
$data = $this->parseValue($data);
//将关联数组拼接为固定的格式 键=值,键=值
$value = $this->parseUpdate($data);
//准备sql语句
$sql = 'update %TABLE% set %VALUE% %WHERE%';
$sql = str_replace(['%TABLE%', '%VALUE%', '%WHERE%'], [$this->options['table'], $value, $this->options['where']], $sql);
//保存sql语句
$this->sql = $sql;
//执行sql语句
return $this->exec($sql);
}
/**
* 将关联数组拼接为固定的格式
*
* @param [type] $data
* @returnvoid
*/
protected function parseUpdate($data)
{
foreach ($data as $key => $value) {
$newData[] = $key . '=' . $value;
}
return join(',', $newData);
}
/**
* max函数
*
* @param [type] $field
* @returnvoid
*/
function max($field)
{
//通过调用自己封装的方法进行查询
$result = $this->field('max(' . $field . ') as max')->select();
//select方法返回的是一个二维数组
return $result[]['max'];
}
/**
* 析构方法
*/
function __destruct()
{
mysqli_close($this->link);
}
/**
* getByName getByAge
*
* @param [type] $name
* @param [type] $args
* @returnvoid
*/
function __call($name, $args)
{
//获取前5个字符
$str = substr($name, , );
//获取后面的字段名
$field = strtolower(substr($name, ));
//判断前五个字符是否是getby
if ($str === 'getBy') {
return $this->where($field . '="' . $args[] . '"')->select();
}
return false;
}
}

php学习之Model类的更多相关文章

  1. (转)Qt Model/View 学习笔记 (三)——Model类

    Model类 基本概念 在model/view构架中,model为view和delegates使用数据提供了标准接口.在Qt中,标准接口QAbstractItemModel类中被定义.不管数据在底层以 ...

  2. Yaf零基础学习总结5-Yaf类的自动加载

    Yaf零基础学习总结5-Yaf类的自动加载 框架的一个重要功能就是类的自动加载了,在第一个demo的时候我们就约定自己的项目的目录结构,框架就基于这个目录结构来自动加载需要的类文件. Yaf在自启动的 ...

  3. django学习之Model(二)

    继续(一)的内容: 1-跨文件的Models 在文件头部import进来,然后用ForeignKey关联上: from django.db import models from geography.m ...

  4. mvc中动态给一个Model类的属性设置验证

    原文:mvc中动态给一个Model类的属性设置验证 在mvc中有自带的验证机制,比如如果某个字段的类型是数字或者日期,那么用户在输入汉字或者英文字符时,那么编译器会自动验证并提示用户格式不正确,不过这 ...

  5. python入门学习:8.类

    python入门学习:8.类 关键点:类 8.1 创建和使用类8.2 使用类和实例8.3 继承8.4 导入类 8.1 创建和使用类   面向对象编程是最有效的软件编写方法之一.在面向对象编程中,你编写 ...

  6. python学习(十)元类

    python 可以通过`type`函数创建类,也可通过type判断数据类型 import socket from io import StringIO import sys class TypeCla ...

  7. 新建一个Model类的注意事项

    昨天在工作中新建了一个Model类在测试环境测试一点问题也没有,到了生产环境就报错了,由于调用的是分页类,报错说:在520行 _count() 函数不存在. 我的思路是:先到生产环境查看了具体的报错文 ...

  8. 第15.25节 PyQt(Python+Qt)入门学习:Model/View开发实战--使用QTableView展示Excel文件内容

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.概述 在前面的订阅专栏<第十九章.Model/View开发:QTableView的功能及属 ...

  9. 第15.23节 PyQt(Python+Qt)入门学习:Model/View架构中QListView视图配套Model的开发使用

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 一.概述 QListView理论上可以和所有QAbstractItemModel派生的类如QStri ...

随机推荐

  1. printPreviewControl1怎么刷新文档

    printPreviewControl1.InvalidatePreview(); 调用printPreviewControl1控件的  InvalidatePreview() 这个方法即可.

  2. 高射炮打蚊子,杀鸡用绝世好剑:在SAP Kyma上运行UI5应用

    国人在表述"大材小用"这个场景时,总喜欢用一些实物来类比,比如:高射炮打蚊子. 英国QF 3.7英寸(94mm)高射炮,战斗全重超过9.3吨,全长近5米,最大射程约18公里,最大射 ...

  3. vue组件间的传值方式及方法调用汇总

    1.传值 a.父组件传子组件 方法一: 父页面: <myReportContent v-if="contentState==1" :paramsProps='paramsPr ...

  4. CentOS7安装CDH 第二章:CentOS7各个软件安装和启动

    相关文章链接 CentOS7安装CDH 第一章:CentOS7系统安装 CentOS7安装CDH 第二章:CentOS7各个软件安装和启动 CentOS7安装CDH 第三章:CDH中的问题和解决方法 ...

  5. python读取图像后变换通道顺序

    直接通过python矩阵操作变换,简单高效 org_img = cv2.imread('cat.jpg') img = org_img[:, :, ::-1] 其中,[::-1] 表示顺序相反操作 , ...

  6. mac使用sourcetree跳过注册

    转自https://blog.csdn.net/qq_32890891/article/details/89216954 打开sourcetree 关闭sourcetree 命令终端输入default ...

  7. Linux下zookeeper集群搭建

    Linux下zookeeper集群搭建 部署前准备 下载zookeeper的安装包 http://zookeeper.apache.org/releases.html 我下载的版本是zookeeper ...

  8. Educational Codeforces Round 76 (Rated for Div. 2) D

    D题 原题链接 题意:就是给你n个怪兽有一个属性(攻击力),m个英雄,每个英雄有两种属性(分别为攻击力,和可攻击次数),当安排最好的情况下,最少的天数(每选择一个英雄出战就是一天) 思路:因为怪兽是不 ...

  9. uhd镜像重新安装

    USRP LW-X300连接网口,设置IP地址:192.168.10.1,子网验码:255.255.255.0 连接后uhd_usrp_probe提示更新镜像. 终端输入: uhd_image_loa ...

  10. The "web.xml" is called web application deployment descriptor

    3.3  Configure the Application Deployment Descriptor - "web.xml" A web user invokes a serv ...