• laravel8 クエリービルダー サブクエリ 複数条件 算術演算 groupBy複数 orderBy DESC混在 生のSQL chank

    サブクエリ 変数はたいていグローバル化しないと渡せ […]

    
        サブクエリ
        変数はたいていグローバル化しないと渡せない
    
        $ranks_tags = DB::table('ranks_tags')->where('label',$this->range_w);
    
            DB::table('post_tags as p')->select(
                DB::raw(   //この中の''は1セット。最初と最後のみで全体を囲む
                'p.fave_id , p.tag_id, f.name , f.cnt_cheer , s.before_cnt_cheer
                , f.cnt_cheer - s.before_cnt_cheer AS incre_cheer 
                , f.cnt_post, s.before_cnt_post
                , f.cnt_post - s.before_cnt_post AS incre_post
                , cnt_share
                , s.id as ranktag_id'
                )
            )
            ->LeftJoin( 'tags as t' , 'p.tag_id' ,'t.id')
            ->LeftJoin( 'faves as f', 'p.fave_id','f.id')
            ->LeftJoinSub($ranks_tags, 's', function ($join) {
                $join->on('s.tag_id' , 'p.tag_id' );
                $join->on('p.fave_id' , 's.fave_id');
            })
            ->groupBy('p.tag_id' , 'p.fave_id' , 'incre_cheer' , 'ranktag_id' )
            ->orderBy('p.tag_id' ,'asc')
            ->orderBy('incre_cheer' ,'DESC')
            ->orderBy('cnt_post' ,'DESC')
            ->limit(999999)
            // ->toSql(); ←素のSQL文を書き出せる
            ->chunk( $this->max_lows, function ($tag_fave) {
                foreach ($tag_fave as $key => $row) {
                    // DB::table('tags')
                    //     ->where('id', $tags->id)
                    //     ->update(['created_at' => $this->ranges['day']]);
                    var_dump($key, $row );
    							
    			}
                return false; //← これで終わる
    		});
    
  • wsl2 Apache バーチャルホスト設定

    Windowsのhosts ファイルに追加 172 […]

    Windowsのhosts ファイルに追加

     
      172.25.29.190       sample.org
    
    

    ※↑ipアドレスはUbuntu起動時のもの、127。0。0.1 ではないことに注意

    
    
    <VirtualHost *:80>
        ServerAdmin webmaster@sample.org
        ServerName sample.org
        ServerAlias sample.org
        DocumentRoot /var/www/web/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
       <Directory /var/www/web/public>
            AllowOverride All
            Options All
            Require all granted
        </Directory>
    </VirtualHost>
    
    
    
  • ページを遷移する前に unloadイベント

    window.addEventListener(‘ […]

    
       window.addEventListener('beforeunload', (event) => {
            event.preventDefault();
            // このページを去る前にローカルストレージを削除;
            localStorage.removeItem('interValId');
        });
    
    
  • lalavel8 サブクエリー (クエリビルダー)

    $sql = “SELECT ←普通のSQL文 F […]

    
     $sql = "SELECT ←普通のSQL文
     FROM
     WHERE " ; 
     
    
     DB::table('app_user_user AS uu')
            ->select( ~ ~ 
    
        ) ->leftJoin( DB::raw("( $sql  ) AS sc ") , 'uu.id', '=', 'sc.user_id')
    
    
    
    	$juhuku = DB::table('issuers')
    		->orWhere(function($query) {
    			$query->where('tel', $this->tel[$this->j])
    			->where('user_id', '!=', $this->user_id);
    		})
    		->orWhere(function($query) {
    		$query->where('email', $this->email[$this->j])
    		->where('user_id', '!=', $this->user_id);
    	})->exists() ;
    
    



    select exists( select * from `issuers` where ( `tel` = '230-0234-5432' and `user_id` != 4604 ) or ( `email` = 'izumo@reqw.wer' and `user_id` != 4604) ) as `exists`

  • localStorage 配列の保存方法

    そのまま保存するとデータ構造が書き換えられて配列が […]

    そのまま保存するとデータ構造が書き換えられて配列がcsv形式になってしまう。

    
    localStorage.setItem('stockoutData', JSON.stringify(stockoutData)); //保存
    
    let stockoutData = localStorage.getItem('stockoutData'); //取得
         let stockouts = JSON.parse(stockoutData);  //変換
    
    
  • wordpress マルチサイト サブディレクトリ 表示されない

    投稿記事に過去1ヶ月よりも前の日付があると出てこな […]

    投稿記事に過去1ヶ月よりも前の日付があると出てこないので、SQL文で一括で昨日とかにする

    
    update `wp_posts` set post_date='2022-01-01 12:12:12'
    ,post_date_gmt = '2022-01-01 03:12:12'
    
    
  • Notice: ob_end_flush(): failed to send buffer of zlib output compression

    対処方法 # vi /etc/php.ini __ […]

    対処方法

    
     # vi /etc/php.ini
    _________________________
    
     zlib.output_compression = Off ← こうする
    _________________________
     # systemctl restart httpd
    
    

    透過的なページ圧縮を行うかどうかを指定します。

    Onを指定した場合、ブラウザが”Accept-Encoding: gzip”または”deflate”ヘッダを送信する際に、ページが圧縮されます。

  • WSL2でUbuntuの初回起動時に0x800701bcが出る

    Linux カーネル更新パッケージのダウンロード […]


    Linux カーネル更新パッケージのダウンロード

    手順 4 – Linux カーネル更新プログラム パッケージをダウンロードする

    最新のパッケージをダウンロードします。

    x64 マシン用 WSL2 Linux カーネル更新プログラム パッケージ
    をいれてたぶん解決。