0%

version

1
2
3
4
5
6
7
8
$ tr --version
tr (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering.
阅读全文 »

环境:

  • CentOS Linux release 7.4.1708
  • php-7.2.13

操作步骤

源码编译PHP,添加OpenSSL支持
先看一下:

1
2
3
4
$ ./configure -h | grep openssl
--with-openssl=DIR Include OpenSSL support (requires OpenSSL >= 1.0.1)
--with-openssl-dir=DIR FTP: openssl install prefix
--with-openssl-dir=DIR SNMP: openssl install prefix
阅读全文 »

事务

事务是数据库很常见且必须的特性,具体是指将多个普通的数据库操视为一个原子操作。最好的解释事务的例子是银行转账,账户A要给账户B转200元,具体步骤:

  1. 判断账户A是否有200元,若有,则扣除200元
  2. 在账户B上加200元

原子性的必要,若步骤1成功,步骤2失败,则用户账户金额丢失,用户肯定不答应。 若步骤1执行失败,却继续执行步骤2,成功了,则银行亏损200元,老板肯定不答应。
通常若步骤1执行失败,那么我们不继续向下执行了步骤2,这个很好理解。若步骤1执行成功,步骤2执行失败,此时则需要回滚步骤1到之前的状态,保证数据的一致性。

阅读全文 »

Trait

Traits are a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

Trait 是一种代码重用的机制,由于PHP语言本身并不像C++等语言一样支持类的多继承,PHP用trait来实现“多继承”。用户可以用Trait声明一个包含属性和方法的对象,类可以引入多个trait并继承其中的属性和方法,以此来实现多继承

Note

  • trait 对象不能实例化
阅读全文 »

示意图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

[h] ----[ ] ---------------------------------------------------> [N]
| | (a)
[h] --> [ ] --> [ ] ----------> [ ] ---------------------------> [N]
| (a) | | |
[h] --> [ ] --> [ ] --> [ ] --> [ ] ----------> [ ] -----------> [N]
| | | | | |
[h] --> [ ] --> [ ] --> [ ] --> [ ] ----------> [ ] ---> [ ] --> [N]
| | | | | |
[1] <=> [3] <=> [5] <=> [7] <=> [9] <=> [10] <=> [11]

// h: header 头指针
// N: NIL
// a: 长度(跨越几个节点)
// 1 ~ 11: 节点分数
阅读全文 »

创建用户

  • CREATE USER 创建用户

    1
    mysql> CREATE USER 'test'@'localhost' IDENTIFIED BY 'aA1!bB2@';
  • GRANT 创建用户并赋予权限

    1
    mysql> GRANT ALL PRIVILEGES ON item TO 'test'@'localhost' IDENTIFIED BY 'aA1!bB2@';

PASSWORD() 会被自动应用在密码字段,用于对密码加密

阅读全文 »

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local _M = {}

function _M.print(a, b)
print(a, b)
end

function _M:echo(a, b)
print(a, b)
end

local m = _M

-- 正常调用
m.print("a", "b")
m:echo("a", "b")
-- 交叉调用
m:print("a", "b")
m.echo("a", "b")
阅读全文 »