技術情報

[Laravel]バッチ処理のタスクスケジュール

今回はLaravelでバッチ処理をタスクスケジュールで実行する方法を紹介します。

続きを読む

[SQL]年齢による条件抽出

データベースレコードには「生年月日」のカラムがありますが、「年齢」のカラムはありません。そのような場合に年齢によるSQLの条件抽出をおこなうためにはどのようにSQLを組み立てていけばいいのでしょうか。

続きを読む

Common Aggregate Functions in SQL

Today I will talk about some common aggregate functions that are widely used in SQL programming language.

Count

if we want to get the count of all records or specific where condition records, we can get by using count function.

SELECT COUNT(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name WHERE condition;

AVG

For average rate calculations, we can use this.

SELECT AVG(column_name) FROM table_name;
SELECT AVG(column_name) FROM table_name WHERE condition;

SUM

For sum results of all records, we can use this.

SELECT SUM(column_name) FROM table_name 
SELECT SUM(column_name) FROM table_name WHERE condition;

MIN

For specific minimum result of a column, we can use this.

SELECT MIN(column_name) FROM table_name;
SELECT MIN(column_name) FROM table_name WHERE condition;

Likewise min, we can use max to get maximum result.

SELECT MAX(column_name) FROM table_name;
SELECT MAX(column_name) FROM table_name WHERE condition;

By Yuuma



[Laravel] ルーティングについて

ルーティングとは「ブラウザで入力されたURL」(リクエストURL)と、Laravelのコントローラを紐付ける方法です。

続きを読む

PHP Json

Today I will talk about how to operate Json data in PHP especially using json_encode & json_decode.

So, Lets get started. We have an array like this.

<?php
$months = array("Jan"=>"01","Feb"=>"02","March"=>"03","April"=>"04");
?>

If we want to change that array to json format, we can do like this.

<?php
$months = array("Jan"=>"01","Feb"=>"02","March"=>"03","April"=>"04");

echo json_encode($months);
?>

So What about decoding, decoding the also similar with encoding.

<?php
$json = '{"Jan":"01","Feb":"02","March":"03","April":"04"}';

//we can treat the decoded data in two ways (object & array)
//treating like an object.
$obj = json_decode($json);
echo $obj->Jan;

// treating like an array
$array = json_decode($json,true);
echo $array['Jan'];
?>

The sample concept if you want to loop through the decoded json.

<?php
$json = '{"Jan":"01","Feb":"02","March":"03","April":"04"}';

$array = json_decode($jsonobj, true);

foreach($array as $key => $value) {
  echo $key . " => " . $value . "<br>";
}
<?php
$json = '{"Jan":"01","Feb":"02","March":"03","April":"04"}';

$obj = json_decode($jsonobj);

foreach($obj as $key => $value) {
  echo $key . " => " . $value . "<br>";
}

By Yuuma




アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム