转载请注明:转载自 Yuansir-web菜鸟 | LAMP学习笔记

本文链接地址: 50分钟学会Laravel 50个小技巧

原文链接:《 50 Laravel Tricks in 50 Minutes by willroth 》
Eloquent
1.Automatic model validation

class Post extends Eloquent
    {
        public static $autoValidate = true;
        protected static $rules = array();
     
        protected static function boot()
        {
            parent::boot();
            // You can also replace this with static::creating or static::updating
            static::saving(function ($model) {
                if($model::$autoValidate) {
     
                    return $model->validate();
                }
            });
        }
     
        public function validate() { }
    }

2.Prevent updating

class Post extends Eloquent
     
    {
        protected static function boot()
        {
            parent::boot();
            static::updating(function ($model) {
                return false;
            });
        }
    }

3.Conditional relationships

class myModel extents Model
    {
         public function category()
         {
             return $this->belongsTo('myCategoryModel', 'categories_id')->where('users_id', Auth::user()->id);
         }
    }

4.Expressive where syntax

$products = Product::where('category', '=', 3)->get();
$products = Product::where('category', 3)->get();
$products = Product::whereCategory(3)->get();

5.Query builder:having raw

SELECT *, COUNT(*) FROM products GROUP BY category_id HAVING count(*) > 1;

DB::table('products')
    ->select('*', DB::raw('COUNT(*) as products_count'))
    ->groupBy('category_id')
    ->having('products_count', '>', 1)
    ->get();
Product::groupBy('category_id')->havingRaw('COUNT(*) > 1')->get();

6.Simple date filtering

$q->whereDate('created_at', date('Y-m-d'));
$q->whereDay('created_at', date('d'));
$q->whereMonth('created_at', date('m'));
$q->whereYear('created_at', date('Y'));

7.Save options

//src/Illuminate/Database/Eloquent/Model.php
    public function save(array $options = array());
     
     //src/Illuminate/Database/Eloquent/Model.php
    protected function performUpdate(Builder $query, array $options = [])
    {
        if($this->timestamps && array_get($options, 'timestamps', true)) {
            $this->updateTimestamps();
        }
     
     
        $product = Product::find($id);
        $product->updated_at = '2015 -01-01 10:00:00';
        $product->save(['timestamps' => false]);

8.Multilingual support

// database/migrations/create_articles_table.php
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->boolean('online');
            $table->timestamps();
        });
    }
     
    //database/migrations/create_articles_table.php
    public function up()
    {
        $table->increments('id');
        $table->integer('article_id')->unsigned();
        $table->string('locale')->index();
        $table->string('name');
        $table->text('text');
        $table->unique(['article_id', 'locale']);
        $table->foreign('article_id')->references('id')->on('articles')->onDelete('cascade');
     
    }
     
    // app/Article.php
    class Article extends Model
    {
        use \Dimsav\Translatable\Translatable;
        public $translatedAttributes = ['name', 'text'];
    }
     
    // app/ArticleTranslation.php
    class ArticleTranslation extends Model
    {
        public $timestamps = false;
    }
     
    // app/http/routes.php
     
    Route::get('{locale}', function ($locale) {
        app()->setLocale($locale);
        $article = Article::first();
        return view('article')->with(compact('article'));
    });
     
    // resources/views/article.blade.php
     
    <h1>{{ $article->name }}</h1>
     
    {{ $article->text }}

9.Retrieve random rows

$questions = Question::orderByRaw('RAND()')->take(10)->get();

10.uuid model primary key

use Ramsey\Uuid\Uuid;
     trait UUIDModel
     {
         public $incrementing = false;
         protected static function boot()
         {
             parent::boot();
             static::creating(function ($model) {
                 $key = $model->getKeyName();
                 if(empty($model->{$key})) {
                     $model->{$key} = (string)$model->generateNewId();
                 }
             });
         }
     
         public function generateNewUuid()
         {
             return Uuid::uuid4();
         }
     }

11.Ordered relationships

class Category extends Model
 {
     public function products()
     {
         return $this->hasMany('App\Product')->orderBy('name');
     }
 }

12.Simple incrementing & Decrementing

$customer = Customer::find($customer_id);
    $loyalty_points = $customer->loyalty_points + 50;
    $customer->update(['loyalty_points' => $loyalty_points]);
     
    // adds one loyalty point
     
    Customer::find($customer_id)->increment('loyalty_points', 50);
    // subtracts one loyalty point
     
    Customer::find($customer_id)->decrement('loyalty_points', 50);

13.List with mutations

$employees = Employee::where('branch_id', 9)->lists('name', 'id');
    return view('customers . create', compact('employees'));
     
     {!! Form::select('employee_id', $employees, '') !!}
     
     public function getFullNameAttribute() {
         return $this->name . ' ' . $this->surname;
     }
     
     
     [2015-07-19 21:47:19] local.ERROR: exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found:
     1054 Unknown column 'full_name' in 'field list'' in
     ...vendor\laravel\framework\src\Illuminate\Database\Connection.php:288
     
     
    $employees = Employee::where('branch_id', 9)->get()->lists('full_name', 'id');

14.Appending mutated properties

function getFullNameAttribute()
    {
        return $this->first_name . ' ' . $this->last_name;
    }
     
     
    {
        "id":1,
        "first_name":"Povilas",
        "last_name":"Korop",
        "email":"[email protected]

", "created_at":"2015-06-19 08:16:58", "updated_at":"2015-06-19 19:48:09" } class User extends Model { protected $appends = ['full_name']; { "id":1, "first_name":"Povilas", "last_name":"Korop", "email":" [email protected]

", "created_at":"2015-06-19 08:16:58", "updated_at":"2015-06-19 19:48:09", "full_name":"Povilas Korop" }
15.Filter only rows with child rows

class Category extends Model
    {
        public function products()
        {
            return $this->hasMany('App\Product');
        }
    }
     
    public function getIndex()
    {
        $categories = Category::with('products')->has('products')->get();
        return view('categories.index', compact('categories'));
    }

16.Return relations on model save

public function store()
    {
        $post = new Post;
        $post->fill(Input::all());
        $post->user_id = Auth::user()->user_id;
        $post->user;
        return $post->save();
     }

Blade
17.Dynamic with

// eloquent
    Post::whereSlug('slug')->get();
     
    // instead of
    View::make('posts.index')->with('posts', $posts);
     
    // do this
    View::make('posts.index')->withPosts($posts);

18.First/last array element

//hide all but the first item

@foreach ($menu as $item)

<div @if ($item != reset($menu)) class="hidden" @endif>

<h2>{{ $item->title }}</h2>

</div>

@endforeach

//apply css to last item only

@foreach ($menu as $item)

<div @if ($item == end($menu)) class="no_margin" @endif>

<h2>{{ $item->title }}</h2>

</div>

@endforeach

Collections
19.Arrays as collections

$devs = [
        ['name' => 'Anouar Abdessalam', 'email' => '[email protected]

'], ['name' => 'Bilal Ararou', 'email' => '[email protected]'] ]; $devs = new Illuminate\Support\Collection($devs); $devs->first(); $devs->last(); $devs->push(['name' => 'xroot', 'email' => ' [email protected]

']);
20.Collection filters

$customers = Customer::all();
    $us_customers = $customers->filter(function ($customer) {
        return $customer->country == 'United States';
    });
     
    $non_uk_customers = $customers->reject(function ($customer) {
        return $customer->country == 'United Kingdom';
    });

21.find()

//    returns a single row as a collection
    $collection = App\Person::find([1]);
     
    //    can return multiple rows as a collection
    $collection = App\Person::find([1, 2, 3]);

22.where()

$collection = App\Person::all();
$programmers = $collection->where('type', 'programmer');
$critic = $collection->where('type', 'critic');
$engineer = $collection->where('type', 'engineer');

23.implode()

$collection = App\Person::all();
$names = $collection->implode('first_name', ',');

24.where() & list()

// returns a collection of first names
     
    $collection = App\Person::all()->where('type', 'engineer')->lists('first_name');
     
    // returns all the meta records for user 1
    $collection = App\WP_Meta::whereUserId(1)->get();
     
    // returns the first & last name meta values
     
    $first_name = $collection->where('meta_key', 'first_name')->lists('value')[0];
    $last_name = $collection->where('meta_key', 'last_name')->lists('value')[0];

25.order belongs-to-many by pivot table

class Link extends Model
     
     {
         public function users()
         {
             return $this->belongsToMany('Phpleaks\User')->withTimestamps();
         }
     }
     
     
    @if ($link->users->count() > 0)
    <strong>Recently Favorited By</strong>
     @foreach ($link->users()->orderBy('link_user.created_at', 'desc')->take(15)->get() as $user)
     
     
            <a href="{{ URL::Route('user.show', array('id' => $user->id)) }}">{{ $user->name }}</a>
         
     
     @endforeach
    @endif

26.sorting with closures

$collection = collect([
        ['name' => 'Desk'],
        ['name' => 'Chair'],
        ['name' => 'Bookcase']
    ]);
     
    $sorted = $collection->sortBy(function ($product, $key) {
        return array_search($product['name'], [1 => 'Bookcase', 2 => 'Desk', 3 => 'Chair']);
    });

27.keying arrays

$library = $books->keyBy('title');
     
    [
        'Lean Startup' => ['title' => 'Lean Startup', 'price' => 10],
        'The One Thing' => ['title' => 'The One Thing', 'price' => 15],
        'Laravel: Code Bright' => ['title' => 'Laravel: Code Bright', 'price' => 20],
        'The 4-Hour Work Week' => ['title' => 'The 4-Hour Work Week', 'price' => 5],
    ]

28.grouped collections

$collection = App\Person::all();
$grouped = $collection->groupBy('type');

29.collection unions

// the point is to actually combine results from different models
    $programmers = \App\Person::where('type', 'programmer')->get();
    $critic = \App\Person::where('type', 'critic')->get();
    $engineer = \App\Person::where('type', 'engineer')->get();
     
    $collection = new Collection;
     
    $all = $collection->merge($programmers)->merge($critic)->merge($engineer);

30.collection lookaheads

$collection = collect([1 => 11, 5 => 13, 12 => 14, 21 => 15])->getCachingIterator();
    foreach ($collection as $key => $value) {
        dump($collection->current() . ':' . $collection->getInnerIterator()->current());
    }

Routing
31.nested route groups

Route::group(['prefix' => 'account', 'as' => 'account.'], function () {
     
        Route::get('login', ['as' => 'login', 'uses' => 'AccountController@getLogin']);
        Route::get('register', ['as' => 'register', 'uses' => 'AccountController@getRegister']);
     
        Route::group(['middleware' => 'auth'], function () {
            Route::get('edit', ['as' => 'edit', 'uses' => 'AccountController@getEdit']);
        });
     
    });
     
    <a href="{{ route('account.login') }}">Login</a>
    <a href="{{ route('account.register') }}">Register</a>
    <a href="{{ route('account.edit') }}">Edit Account</a>

32.catch-all view route

// app/Http/routes.php
     
    Route::group(['middleware' => 'auth'], function () {
        Route::get('{view}', function ($view) {
            try {
                return view($view);
            } catch (\Exception $e) {
                abort(404);
            }
        })->where('view', '.*');
    });

33.internal dispatch

// api controller
     
    public function show(Car $car)
    {
        if(Input::has('fields')) {
            // do something
        }
    }
     
    // internal request to api - fields are lost
     
    $request = Request::create('/api/cars/' . $id . '?fields=id,color', 'GET');
    $response = json_decode(Route::dispatch($request)->getContent());
     
    // internal request to api - with fields $originalInput = Request::input();
     
    $request = Request::create('/api/cars/' . $id . '?fields=id,color', 'GET');
    Request::replace($request->input());
    $response = json_decode(Route::dispatch($request)->getContent());
    Request::replace($originalInput);

Testing
34.evironmental varlables

// phpunit.xml

<php>
    <env name="APP_ENV" value="testing"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="SESSION_DRIVER" value="array"/>
    <env name="QUEUE_DRIVER" value="sync"/>
    <env name="DB_DATABASE" value=":memory:"/>
    <env name="DB_CONNECTION" value="sqlite"/>
    <env name="TWILIO_FROM_NUMBER" value="+15005550006"/>
</php>

//    .env.test – add to .gitignore
TWILIO_ACCOUNT_SID = fillmein
TWILIO_ACCOUNT_TOKEN = fillmein

//    access directly from your tests using helper function
env('TWILIO_ACCOUNT_TOKEN');

// tests/TestCase.php <?php class TestCase extends Illuminate\Foundation\Testing\TestCase { /** * The base URL to use while testing the application. * * @var string */ protected $baseUrl = 'http://localhost'; /** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { $app = require __DIR__ . '/../bootstrap/app.php'; if(file_exists(dirname(__DIR__) . '/.env.test')) { Dotenv::load(dirname(__DIR__), '.env.test'); } $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
         return $app;
     }
 }

35.run tests automatically

// gulpfile.js
     
     var elixir = require('laravel-elixir');
     
     mix.phpUnit();
     
     $ gulp tdd

36.share cookie between domains

// app/Http/Middleware/EncryptCookies.php
    protected $except = [
        'shared_cookie'
     
    ];
     
    Cookie::queue('shared_cookie', 'my_shared_value', 10080, null, '.example.com');

37.Easy model & migrations stubs

$ artisan make:model Books -m

38.add spark to existing project

$ composer require genealabs/laravel-sparkinstaller --dev

Laravel\Spark\Providers\SparkServiceProvider::class, GeneaLabs\LaravelSparkInstaller\Providers\LaravelSparkInstallerServiceProvider::class,

//    do not run php artisan spark:install
 $ php artisan spark:upgrade

//    backup /resources/views/home.blade.php or it will be overwritten
 $ php artisan vendor:publish --tag=spark-full

39.customize the default error page

<?php namespace App\Exceptions; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer; class Handler extends ExceptionHandler { protected function convertExceptionToResponse(Exception $e) { $debug = config('app.debug', false); if($debug) { return (new SymfonyDisplayer($debug))->createResponse($e);
        }

return response()->view('errors.default', ['exception' => $e], 500);
    }
}

40.conditional service providers

// app/Providers/AppServiceProvider.php
    public function register()
    {
        $this->app->bind('Illuminate\Contracts\Auth\Registrar', 'App\Services\Registrar');
     
        if($this->app->environment('production')) {
            $this->app->register('App\Providers\ProductionErrorHandlerServiceProvider');
        } else {
            $this->app->register('App\Providers\VerboseErrorHandlerServiceProvider');
        }
    }

43.extending the application

//    bootstrap/app.php
     
    //    replace this:
    $app = new Illuminate\Foundation\Application(realpath(__DIR__ . '/../'));
     
    // with this:
    $app = new Fantabulous\Application(realpath(__DIR__ . '/../'));
     
    <?php namespace Fantabulous; class Application extends \Illuminate\Foundation\Application { /** * Get the path to the storage directory. * * @return string */ public function storagePath() { return $this->basePath . '/FantabulousStorage';
        }
    }

44.simple chching microservice

class fakeApiCaller
     {
         public function getResultsForPath($path)
         {
             return [
                 'status' => 200,
                 'body' => json_encode([
                     'title' => "Results for path [$path]"
                 ]),
                 'headers' => [
                     "Content-Type" => "application/json"
                 ]
             ];
         }
     }
     
     $app->get('{path?}', function ($path) {
         $result = Cache::remember($path, 60, function () use ($path) {
             return (new fakeApiCaller)->getResultsForPath($path);
         });
     
         return response($result['body'], $result['status'], array_only($result['headers'], [
                 'Content-Type',
                 'X-Pagination'
             ]));
     })->where('path', '.*');

45.use bleeding edge version

$ composer create - project laravel / laravel your-project-name-here dev-develop
     
     // composer.json
     {
         "require": {
         "php": ">=5.5.9", "laravel/framework": "5.2.*"
        },
        "minimum-stability": "dev"
     }
     
    $ composer update

46.capture queries

Event::listen('illuminate.query', function ($query) {
        var_dump($query);
     
    });
     
     
    \DB::listen(function ($query, $bindings, $time) {
        var_dump($query);
     
        var_dump($bindings);
        var_dump($time);
     
    });

47.authorization without models

//    app/Policies/AdminPolicy.php
    class AdminPolicy
    {
        public function managePages($user)
        {
            return $user->hasRole(['Administrator', 'Content Editor']);
        }
    }
     
    //    app/Providers/AuthServiceProvider.php
     
    public function boot(\Illuminate\Contracts\Auth\Access\GateContract $gate)
    {
        foreach (get_class_methods(new \App\Policies\AdminPolicy) as $method) {
            $gate->define($method, "App\Policies\AdminPolicy@{$method}");
        }
        $this->registerPolicies($gate);
    }
     
     
    $this->authorize('managePages'); // in Controllers
    @can('managePages') // in Blade Templates
    $user->can('managePages'); // via Eloquent

48.efficient file transfer with streams

$disk = Storage::disk('s3');

$disk->put($targetFile, file_get_contents($sourceFile));

$disk = Storage::disk('s3');
$disk->put($targetFile, fopen($sourceFile, 'r+'));

$disk = Storage::disk('s3');

$stream = $disk->getDriver()->readStream($sourceFileOnS3);
file_put_contents($targetFile, stream_get_contents($stream), FILE_APPEND);

$stream = Storage::disk('s3')->getDriver()->readStream($sourceFile);
Storage::disk('sftp')->put($targetFile, $stream)

49.avoid overflowing log files

$schedule->call(function () {
        Storage::delete($logfile);
    })->weekly();

50.pipeling

$result = (new Illuminate\Pipeline\Pipeline($container)
        ->send($something)
        ->through('ClassOne', 'ClassTwo', 'ClassThree')
        ->then(function ($something) {
            return 'foo';
        });

51.command handler dispatch

class PurchasePodcastCommand extends Command
    {
        public $user;
        public $podcast;
        public function __construct(User $user, Podcast $podcast)
        {
            $this->user = $user;
            $this->podcast = $podcast;
        }
    }
     
    class PurchasePodcastCommandHandler
    {
        public function handle(BillingGateway $billing)
        {
            // Handle the logic to purchase the podcast...
     
            event(new PodcastWasPurchased($this->user, $this->podcast));
        }
    }
     
    class PodcastController extends Controller
    {
        public function purchasePodcastCommand($podcastId)
        {
            $this->dispatch(
                new PurchasePodcast(Auth::user(), Podcast::findOrFail($podcastId))
            );
        }
    }

52.self handling commands

class PurchasePodcast extends Command implements SelfHandling
    {
        protected $user;
        protected $podcast;
     
        public function __construct(User $user, Podcast $podcast)
        {
            $this->user = $user;
            $this->podcast = $podcast;
        }
     
        public function handle(BillingGateway $billing)
        {
            // Handle the logic to purchase the podcast...
     
            event(new PodcastWasPurchased($this->user, $this->podcast));
        }
     
    }
     
    class PodcastController extends Controller
    {
        public function purchasePodcast($podcastId)
        {
            $this->dispatch(
                new PurchasePodcast(Auth::user(), Podcast::findOrFail($podcastId))
            );
        }
    }

53.automatic dispatch from requests

class PodcastController extends Controller
{
    public function purchasePodcast(PurchasePodcastRequest $request)
    {
        $this->dispatchFrom('Fantabulous\Commands\PurchasePodcastCommand', $request);
    }

}

class PodcastController extends Controller
{
    public function purchasePodcast(PurchasePodcastRequest $request)
    {
        $this->dispatchFrom('Fantabulous\Commands\PurchasePodcastCommand', $request, [
            'firstName' => 'Taylor',
        ]);
    }
}

54.queued commands

class PurchasePodcast extends Command implements ShouldBeQueued, SerializesModels
    {
        public $user;
        public $podcast;
     
        public function __construct(User $user, Podcast $podcast)
        {
            $this->user = $user;
            $this->podcast = $podcast;
        }
    }

55.commands pipeline

// App\Providers\BusServiceProvider::boot
    $dispatcher->pipeThrough(['UseDatabaseTransactions', 'LogCommand']);
     
    class UseDatabaseTransactions
    {
        public function handle($command, $next)
        {
            return DB::transaction(function () use ($command, $next) {
                return $next($command);
            });
        }
    }
     
     
    // App\Providers\BusServiceProvider::boot
    $dispatcher->pipeThrough([
        function ($command, $next) {
            return DB::transaction(function () use ($command, $next) {
                return $next($command);
            });
        }
    ]);

Laravel 5.2
56.implicit model binding

// app/http/routes.php
     
    Route::get('/api/posts/{post}', function (Post $post) {
        return $post;
    });
     
    // behind the scenes
    Post::findOrFail($post);

57.append scheduler autput to a file

$schedule->command('emails:send')->hourly()->appendOutputTo($filePath);

58.collections wildcard

// returns titles for all posts

$titles = $posts->pluck(‘posts .*.title’);

59.formarray validation

<input type="text" name="person[1][id]">
     <input type="text" name="person[1][name]">

<input type="text" name="person[2][id]"> <input type="text" name="person[2][name]">

$v = Validator:: make($request->all(), [
    'person.*.id' => 'exists:users.id',
    'person.*.name' => 'required:string',

]);

60.easily clear user sessions

// included in database session driver
user_id
ip_address

转载请注明:转载自 Yuansir-web菜鸟 | LAMP学习笔记

原文:https://blog.csdn.net/qq_15766181/article/details/71082129

50分钟学会Laravel 50个小技巧(基于laravel5.2,仅供参考)的更多相关文章

  1. 50分钟学会Laravel 50个小技巧

    50分钟学会Laravel 50个小技巧 时间 2015-12-09 17:13:45  Yuansir-web菜鸟 原文  http://www.yuansir-web.com/2015/12/09 ...

  2. 关于Http的小常识(转载,仅供参考)

    HTTP请求头提供了关于请求,响应或者其他的发送实体的信息.HTTP的头信息包括通用头.请求头.响应头和实体头四个部分.每个头域由一个域名,冒号(:)和域值三部分组成. 通用头标:即可用于请求,也可用 ...

  3. VSS的运用小内容(针对于vs2008版本)(小的问题都是,仅供参考--只针对于菜鸟级的)

    自己开始接触vss 的时候有些小的习惯没有很好的养成,下面的有关VSS内容都是简单的迁入迁出的问题,(仅供参考) 1.文件的迁入迁出:(.txt..xlsx..doc) a:文件的覆盖问题: 对于文件 ...

  4. 学会这些 pycharm 编程小技巧,编程效率提升 10 倍

    PyCharm 是一款非常强大的编写 python 代码的工具.掌握一些小技巧能成倍的提升写代码的效率,本篇介绍几个经常使用的小技巧. 一.分屏展示 当你想同时看到多个文件的时候: 1.右击标签页: ...

  5. SQL 数据快速查询优化小技巧(仅供参考)

    .应尽量避免在where子句中使用!=或<>操作符 .应尽量避免在where子句中使用or来连接条件 如: 可以这样查询 Union all .in 和not in 也要慎用,否则会导致全 ...

  6. [IOI2008/BZOJ1791 岛屿](处理基环树的小技巧&基于bfs树形DP)

    IOI2008/BZOJ1791 岛屿 题目大意是在一个基环树森林里求每一棵基环树的直径①的和. 其实就是树的直径的基环树升级版.我们先把环找出来,然后从环上的每一个节点x出发,并且不经过环上其他节点 ...

  7. laravel获取checkbox值的小技巧

    以前老是用三元运算符来判断,现在有了更好的方法: 1.html代码 <input type="hidden" name="approved" value= ...

  8. CSS 黑魔法小技巧,让你少写不必要的JS,代码更优雅

    首页   登录注册         CSS 黑魔法小技巧,让你少写不必要的JS,代码更优雅 阅读 8113 收藏 927 2017-09-26 原文链接:github.com 腾讯云容器服务CSS,立 ...

  9. 【温故知新】——CSS黑魔法小技巧可以少些不必要的js

    前言:这篇文章是转载[前端开发博客]的一篇技术文章,并非本人所写.只是个人觉得很实用,所以分享给大家.原文链接:github.com 1.利用 CSS 的 content 属性 attr 抓取资料需求 ...

随机推荐

  1. 在win7下python的xlrd和xlwt的安装于应用

    1. http://pypi.python.org/pypi/xlwt 和http://pypi.python.org/pypi/xlrd下载xlwt-0.7.4.tar.gz和xlrd-0.7.7. ...

  2. 前端数据库——WebSQL和IndexedDB

    一.WebSQL WebSQL是前端的一个独立模块,是web存储方式的一种,我们调试的时候会经常看到,只是一般很少使用.并且,当前只有谷歌支持,ie和火狐均不支持. 我们对数据库的一般概念是后端才会跟 ...

  3. SpringMVC handleMapping映射过程

    初始化IOC容器 Spring初始化的时候会优先初始化自定义的类,下面这个就是 org.springframework.web.servlet.mvc.method.annotation.Reques ...

  4. [ZJOI2012]灾难

    嘟嘟嘟 偶尔翻到的一道题. 50分暴力很好想,对于每一个点进行一次拓扑排序,然后每一次别memset,只清空走过的点,能拿到70分. 正解好像也挺好想,是一个叫"灭绝树"的东西. ...

  5. Mybatis基础核心类说明

    1:  org.apache.ibatis.mapping.ParameterMapping 为Mybatis参数的抽象表示,包括Java类型与数据库类型以及类型处理器属性名字等等!! 例如: 其中i ...

  6. ActiveMQ发布订阅模式 转发 https://www.cnblogs.com/madyina/p/4127144.html

    ActiveMQ的另一种模式就SUB/HUB即发布订阅模式,是SUB/hub就是一拖N的USB分线器的意思.意思就是一个来源分到N个出口.还是上节的例子,当一个订单产生后,后台N个系统需要联动,但有一 ...

  7. direct path read temp的处理方法

    Examine the SQL statement currently being run by the session experiencing waits to see what is causi ...

  8. Debian 8.9 搭建wordpress个人博客

    想自己搭个博客玩玩,就搭建了此博客,过程可谓艰辛啊! 先在阿里云买了个  轻量应用服务器 1个月10块钱,好贵.... 用 windows sever 下载不了phpstudy,也不知道怎么回事... ...

  9. Android自动化测试学习路线

    最近在整理Android自动化测试的相关资料,大体上把一些知识点梳理了,这里做一个简单的分享! Android里面测试相关的工具和框架太多了.你应该从以下几个方面入手. 编程语言的选择 如果你要学习的 ...

  10. (admin.E108) The value of 'list_display[4]'报错解决方案

    参考资料:虫师-<web接口开发与自动化测试:基于python语言> 日常学习Django框架中,创建了用户模型,但是页面功能验证时候,提示不能进行列表字段操作,debug好久,才找到问题 ...