https://codereview.stackexchange.com/questions/80080/aggregate-array-values-into-ranges
// Output: // Array ( // [0] => Array ( [0] => 1, [1] => 2, [2] => 3, [3] => 4, [4] => 5, [5] => 6 ) // [1] => Array ( [0] => 10, [1] => 11, [2] => 12, [3] => 13 ) // [2] => Array ( [0] => 20 ) // [3] => Array ( [0] => 24 ) // ) static function GetRanges1( $aNumbers ) { $aNumbers = array_unique( $aNumbers ); sort( $aNumbers ); $aGroups = array(); for( $i = 0; $i < count( $aNumbers ); $i++ ) { if( $i > 0 && ( $aNumbers[$i-1] == $aNumbers[$i] - 1 )) array_push( $aGroups[count($aGroups)-1], $aNumbers[$i] ); else array_push( $aGroups, array( $aNumbers[$i] )); } return $aGroups; } // Output: Array ( [0] => 1-6, [1] => 10-13, [2] => 20, [3] => 24 ) static function GetRanges2( $aNumbers ) { $aNumbers = array_unique( $aNumbers ); sort( $aNumbers ); $aGroups = array(); for( $i = 0; $i < count( $aNumbers ); $i++ ) { if( $i > 0 && ( $aNumbers[$i-1] == $aNumbers[$i] - 1 )) array_push( $aGroups[count($aGroups)-1], $aNumbers[$i] ); else array_push( $aGroups, array( $aNumbers[$i] )); } $aRanges = array(); foreach( $aGroups as $aGroup ) { if( count( $aGroup ) == 1 ) $aRanges[] = $aGroup[0]; else $aRanges[] = $aGroup[0] .
https://m.facebook.com/story.php?story_fbid=10216824504164331&id=1815507975
《 PHP RFC: Remove support for libmysql from mysqli 》
» https://wiki.php.net/rfc/mysqli_support_for_libmysql
PHP 核心開發團隊投票通過移除 mysqli 的 libmysql 支援,將於 PHP 8.2 正式生效。這項討論從農曆年前關注到年後,最終於 2022/2/5 全數投票通過。
對於一般 PHP 開發者是好事,不用再考慮 MySQL 是選擇 libmysql 還是 mysqlnd;面試時也減少面試官詢問兩者差異的比較 (不過現在很多面試官也不知道了)。
如果想瞭解 libmysql / mysqlnd 的優缺點,官方 RFC 也貼心地條列整理了。不過 RFC 裡沒提關於「License (授權)」的考量,特別在商業上。這也是 PHP 與 Python 及 Ruby 等社群有著不太一樣的生態考量。
Python 要連結 MySQL,通常選用 MySQL Connector 或 MySQLdb,但這兩者底層都依賴 libmysqlclient (MySQL C Library),而 libmysqlclient 的授權 [1] 主要採用 GPL-2.0,進而連帶影響了整體產品/專案的授權。
Ruby 要連結 MySQL,通常選用 mysql2,而其底層同樣依賴 libmysqlclient,有著同樣的潛在商業問題。
https://github.com/freescout-helpdesk/freescout
When juse livewire at blade.php
Must have Div At first. <div style="text-align: center"> <button wire:click="increment">+</button> <h1>{{ $count }}</h1> </div> +{{ $count }}
App/Http/Livewire/Orders.php```
namespace App\Http\Livewire;
use Gate;
use Livewire\Component;
use Symfony\Component\HttpFoundation\Response;
class Orders extends Component
{
public function render()
{
abort_if(Gate::denies(‘order_access’), Response::HTTP_FORBIDDEN, ‘403 Forbidden’);
return view('livewire.order'); } }
resources/views/livewire/order.blade.php
@extends(‘layouts.app’)
@section(‘content’)
@livewire(‘order.show’)
@endsection
App/Http/Livewire/Order/Show.php namespace App\Http\Livewire\Order;
public function render() { abort_if(Gate::denies('order_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $this->orders = Order::all(); // Order::where('owner_id', auth()->id())->get(); // 只能看自己 return view('livewire.order.show'); } resources/views/livewire/order/show.blade.php
{{ virables }}
[one to one]
Table: User, Phone
Model: User
Relation: return $this->hasOne(‘App\Phone’);
Talbe Phone need have user_id. Auto use User id -> Phone user_id
Table: User, Phone
Model: Phone
Relaion: return $this->belongsTo(‘App\User’);
Table Phone need have user_id. Auto use User id -> User user_id
[one to many]
Table: Post, Comment
Model: Post
Relation: return $this->hasMany(‘App\Comment’);
Table Comment need have post_id. Auto use Post id -> Comment post_id
Table: Post, Comment
larvel 8 remove Providers/RouteServiceProvider.php namespace. Maybe you add back again.
protected $namespace = 'App\Http\Controllers'; ... $this->routes(function () { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); }); Add backup namespace then get problem for livewire. Every route just use App\Http|controllers ooxxooxxooxx.
OLD Way web.php Route::resource('users', 'UsersController'); Route::delete('users/destroy', 'UsersController@massDestroy'); Get Error Route::resource('orders', 'livewire.order'); Route::resource('orders', 'livewire@order'); Route::view('orders', [\App\Http\Livewire\Order::class, 'render']); Maybe Way web.php Route::view('orders', 'livewire.order'); Files: \app\Http\Livewire\Order.php inside use return view('livewire.order'); \resources\views\livewire\order.blade.php Get Error Undefined variable: orders or other ooxxooxx Alwasy get this Error.