Microsoft Kaizalaをインストールします。
https://play.google.com/store/apps/details?id=com.microsoft.mobile.polymer&hl=ja
なんじゃこりゃ? よー判りません。。
随机应变 ABCD: Always Be Coding and … : хороший
Microsoft Kaizalaをインストールします。
https://play.google.com/store/apps/details?id=com.microsoft.mobile.polymer&hl=ja
なんじゃこりゃ? よー判りません。。
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> 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(*) 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とカウントされるんですね。
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文を使ってデータを取得した時に、重複したデータを取り除いてデータを取得する
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の重複が削除されますねー
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));
debuggerはlaravel開発に役立つらしい
ただし、パスワードも丸見えになるらしい。
[vagrant@localhost tea]$ php composer.phar require barryvdh/laravel-debugbar
Using version ^3.2 for barryvdh/laravel-debugbar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
– Installing maximebf/debugbar (v1.15.0): Downloading (100%) – Installing barryvdh/laravel-debugbar (v3.2.4): Downloading (100%)
maximebf/debugbar suggests installing kriswallsmith/assetic (The best way to manage assets)
maximebf/debugbar suggests installing predis/predis (Redis storage)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover –ansi
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
LaravelのファイルストレージとS3を連携させるには、専用のパッケージを導入する必要があるとのこと。
composer.json
"require": { "php": "^7.1.3", "barryvdh/laravel-dompdf": "^0.8.4", "fideloper/proxy": "^4.0", "laravel/framework": "5.8.*", "laravel/tinker": "^1.0" },
ここに、league/flysystem-aws-s3-v3を追加する。
laravel/config/filesystem
's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), ],
env(${})となっているので、.envファイルで編集します。
AWS_KEY=[アクセスキー] AWS_SECRET=[シークレットキー] AWS_REGION=[リージョン(東京ならap-northeast-1)] AWS_BUCKET=[バケット名]
そういうことかー
まずtestコードを書きます。
class Test { private $t = 1; public function test(){ echo $this->t; $test = 2; } }
で、テストします。
[vagrant@localhost app]$ vendor/phpmd/phpmd/src/bin/phpmd test.php text unusedcode,naming
/home/vagrant/local/app/test.php:5 Avoid variables with short names like $t. Configured minimum length is 3.
/home/vagrant/local/app/test.php:7 Classes should not have a constructor method with the same name as the class
/home/vagrant/local/app/test.php:9 Avoid unused local variables such as ‘$test’.
ぎゃあああああああああああああああああああああ
修正します。
class Test { private $test1 = 1; public function index(){ echo $this->test1; $test2 = 2; echo $test2; } }
で、再度テストすると。。
[vagrant@localhost app]$ vendor/phpmd/phpmd/src/bin/phpmd test.php text unusedcode,naming
おおおおおおおおお、こういうことか~