[毎日自分に問いかけるべき6つの質問 ?]
- 目標に近づくための仕事ができたか?
- やめるべき悪い習慣はないか?
- 今日私のモチベーションを高めてくれたのは何か?
- 今日1日、なりたい自分だったか?
- 今日どんな失敗をして、そこから何が学べたか?
- 今日感謝することは何か?
今からでも遅くない、1日の終わりの自分への質問。
#!/bin/sh
# ====================================================================
# $Id$
#
# Description:
# 郵政省郵便番号(zip_codes) を最新化します。
#
# Usage:
# ./renew_zipcodes.sh
#
# Date Author Description
# --------------------------------------------------------------------
# 2014-10-05 Seiji Hojo 新規作成
#
# ====================================================================
# 設定ファイル読み込み
. "./config/renew_zipcodes.ini"
# ====================================================================
# 前処理
# ====================================================================
# clean
find ${TMP_DIR} \( -name "KEN_ALL.CSV" -o -name "ken_all.zip" \) -print0 | \
xargs -0 --no-run-if-empty rm 2>/dev/null
# ====================================================================
# 本処理
# ====================================================================
# zip ファイル取得
wget ${ZIP_ALL_URL} -P ${TMP_DIR}
# zip 解凍
cd ${TMP_DIR}
unzip $(basename ${ZIP_ALL_URL})
# テーブル再作成
${MYSQL_CMD} < ${SQL_DIR}"/drop-create-zipcodes.sql"
# データ投入
${MYSQL_CMD} <<SQL
-- Shift_JIS ファイルを読み込む
SET character_set_database=sjis;
-- 郵政省郵便番号(zip_codes) に最新データ投入
LOAD DATA INFILE "/tmp/KEN_ALL.CSV"
INTO TABLE zip_codes
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES
TERMINATED BY '\r\n'
IGNORE 0 LINES
;
-- 「以下に掲載がない場合」は消す
UPDATE zip_codes
SET address = NULL
WHERE address = '以下に掲載がない場合'
;
SQL
# ====================================================================
# 後処理
# ====================================================================
# clean
find ${TMP_DIR} \( -name "KEN_ALL.CSV" -o -name "ken_all.zip" \) -print0 | \
xargs -0 --no-run-if-empty rm 2>/dev/null
# end
exit 0
class DomainController extends AppController {
/**
* コンストラクタ
*
* @see Controller::__construct()
*/
public function __construct($request = null, $response = null) {
// uses, components をマージ
$this->uses = am($this->uses, array(
'User',
'Label',
));
$this->components = am($this->components, array(
'Me.AuthTest',
));
}
// 以下、共通ロジックなど ...
}
class MyController extends DomainController {
public $uses = array('Employee');
public $components = array('Search.Prg');
public function index() {
debug($this->uses); // User, Label, Employee + AppController::uses
debug($this->components); // AuthTest, Search + AppController::components
}
}
class Shop extends AppModel {
public $useDbConfig = 'commons';
}
class Report extends AppModel {
public $useDbConfig = 'sub-a-systems';
public $belongsTo = array(
'Shop' => array('type' => 'INNER'),
);
}
class ReportsController extends AppController {
public $uses = array('Report');
public function index() {
$model = $this->{$this->modelClass};
$reports = $model->find('all', array(
'fields' => array(
'Report.*',
'Shop.name AS shop_name',
),
'joins' => array(
array(
'type' => 'INNER',
'tables' => 'commons.shops',
'alias' => 'Shop',
'conditions' => 'Report.shop_id = Shop.id'
),
),
'recursive' => -1,
);
}
}
そう、ただ joins オプションの tables プロパティの値にテーブル名を入れれば出来るようでしたwww