Skip to content

Instantly share code, notes, and snippets.

@tadasuke
tadasuke / file0.php
Created July 16, 2015 06:30
DateTimeオブジェクトのコンストラクタにUNIX_TIMEを渡した時の謎挙動 ref: http://qiita.com/tadasuke/items/07d95f5dac3d9dfeae68
$dateTime = new DateTime( '@' . time() );
@tadasuke
tadasuke / file0.php
Created July 15, 2015 09:12
PDOで取得したデータ型がDATETIMEだったら、DateTimeオブジェクトに入れる ref: http://qiita.com/tadasuke/items/523fa31caf13a112aacd
// SELECT実行
$sth -> execute();
// DATETIME型のカラム名配列を作成する
$datetimeColumnNameArray = array();
for ($i = 0; $i < $sth -> columncount(); ++$i ) {
// カラムのメタ情報を取得
$columnMeta = $sth -> getColumnMeta( $i );
// DATETIME型の場合
@tadasuke
tadasuke / file0.php
Created June 22, 2015 06:26
配列の値が数値だったら文字列にする(多次元配列対応) ref: http://qiita.com/tadasuke/items/68bfd47ee7b2e1deb175
public static function int2stringByArray( array $array ) {
$responseArray = array();
foreach ( $array as $key => $value ) {
// 値が配列の場合
if ( is_array( $value ) === TRUE ) {
$responseArray[$key] = self::int2stringByArray( $value );
// 値がintの場合
} else if ( is_int( $value ) === TRUE ) {
@tadasuke
tadasuke / file0.html
Last active August 29, 2015 14:23
faviconのurlを指定する。 ref: http://qiita.com/tadasuke/items/978c4d393ed9b101a00a
<link rel="shortcut icon" href="faviconのURL">
@tadasuke
tadasuke / file0.txt
Created June 17, 2015 01:18
SHOW PROCESSLISTの結果をソート ref: http://qiita.com/tadasuke/items/4716ce0d70c878389726
SELECT * FROM information_schema.PROCESSLIST ORDER BY TIME;
@tadasuke
tadasuke / file0.txt
Last active July 28, 2017 06:21
DbNinjaをCentOS6.6にインストールする ref: http://qiita.com/tadasuke/items/11c88e64c2c1c2085ae5
wget http://www.dbninja.com/download/dbninja.zip
@tadasuke
tadasuke / file0.php
Last active August 29, 2015 14:23
2次元配列の2次元目の配列の値でソートをする ref: http://qiita.com/tadasuke/items/e7be0d214e02105ab6d8
$array = array(
array(
'id' => 10,
'name' => 'hoge',
),
array(
'id' => 3,
'name' => 'fuga',
),
@tadasuke
tadasuke / file1.txt
Created June 11, 2015 09:30
Eclipse PDOで配列内のオブジェクトをコード補完する ref: http://qiita.com/tadasuke/items/e5d9072dbae5677ed234
/**
* hogeオブジェクト配列
* @var array
*/
private $hogeArray = array();
public function getHogeArray() {
return $this -> hogeArray;
}
@tadasuke
tadasuke / file0.sh
Created June 11, 2015 08:35
シェルスクリプトでsudoを実行する ref: http://qiita.com/tadasuke/items/fcf563bbce33aa93c4c7
echo "パスワード" | sudo -S /etc/rc.d/init.d/httpd restart
@tadasuke
tadasuke / file0.txt
Created May 29, 2015 08:58
Memcacheでセットした値をMemcachedで取得しようとして、ハマる。 ref: http://qiita.com/tadasuke/items/dd36f4862c471d2d999f
Memcache