mailgun

Transactional Email API Service for Developersと書いてある。
APIベースのメール配信サービスとのこと。
Mailgunでは、毎月10,000通までのメール送信が無料で使えるとのこと。
Google Cloud PlatformのCompute Engineのサードパーティメールサービスとしても提供。

DNSを設定して、Laravelに導入するのね。
うむ、これはテストしないとあかんやつやね。

Laravelでindexを作成、追加する方法

Schma::create('books', function(Blueprint $table){
	$table->increments('id');
	$table->string('title')->index();
	$table->string('isbn')->unique();
	$table->integer('price');
	$table->integer('author_id');
	$table->timestamps();
});


Schema::table('books', function(Blueprint $table){
	$table->index('title');
});

Schema::table('author_book', function(Blueprint $table){
	$table->index(['author_id', 'book_id']);
});

$table->dropIndex('books_title_index');

mysql: group by

mysql> select * from staff;
+——+——–+——–+
| id | name | deptid |
+——+——–+——–+
| 1 | yamada | 1 |
| 2 | honda | 4 |
| 3 | kudou | 6 |
| 4 | nishi | 1 |
| 5 | tagawa | 3 |
+——+——–+——–+
5 rows in set (0.00 sec)

mysql> select deptid, sum(id) from staff grop by deptid;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘by deptid’ at line 1
mysql> select deptid, sum(id) from staff group by deptid;
+——–+———+
| deptid | sum(id) |
+——–+———+
| 1 | 5 |
| 3 | 5 |
| 4 | 2 |
| 6 | 3 |
+——–+———+
4 rows in set (0.02 sec)

なるほど、あるカラムの値に重複がある場合に、group byでまとめて計算できるのね。

なんとなくわかってきた。

mysql select count: レコード数のカウント

mysql> select count(*) from kawasaki;
+———-+
| count(*) |
+———-+
| 69 |
+———-+
1 row in set (0.00 sec)

mysql> select * from staff;
+——+——–+——–+
| id | name | deptid |
+——+——–+——–+
| 1 | yamada | 1 |
| 2 | honda | 4 |
| 3 | kudou | 6 |
| 4 | nishi | 1 |
| 5 | tagawa | 3 |
+——+——–+——–+
5 rows in set (0.00 sec)

mysql> select count(deptid) from staff;
+—————+
| count(deptid) |
+—————+
| 5 |
+—————+
1 row in set (0.00 sec)

データ量なので、重複したデータも+1とカウントされるんですね。

mysql show index;

show indexは、indexが貼られているか確認

mysql> show index;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1

あれ、、

mysql> show index from staff;
Empty set (0.00 sec)

あら、fromが必要でしたね。

select distinct -> 重複データを取り除く

SELECT文を使ってデータを取得した時に、重複したデータを取り除いてデータを取得する

SELECT DISTINCT column name, ... from table name;

では、早速見てみましょう。
mysql> select * from staff
-> ;
+——+——–+——–+
| id | name | deptid |
+——+——–+——–+
| 1 | yamada | 1 |
| 2 | honda | 4 |
| 3 | kudou | 6 |
| 4 | nishi | 1 |
| 5 | tagawa | 3 |
+——+——–+——–+
5 rows in set (0.06 sec)

mysql> select distinct deptid from staff;
+——–+
| deptid |
+——–+
| 1 |
| 4 |
| 6 |
| 3 |
+——–+
4 rows in set (0.06 sec)

なるほど、deptidの重複が削除されますねー

php7.0とphp7.1の違い

1. 型宣言

function type_defined(int $argument) : string {
	return 'Hello';
}

あまり見ない気がしますが。。

$name_list = [
	'luna',
	'sunny',
	'star',
];

function type_defined(int $name_id) : string {
	return isset($name_list[$name_id]) ? $name_list[$name_id] : null; 
}

var_dump(get_name(4));