PHP code example of as247 / wp-eloquent

1. Go to this page and download the library: Download as247/wp-eloquent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

as247 / wp-eloquent example snippets


use As247\WpEloquent\Application;

Application::bootWp();

use As247\WpEloquent\Application;

Application::boot([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => 'password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
]);

use As247\WpEloquent\Support\Facades\DB;
$users = DB::table('users')->where('votes', '>', 100)->get();

use As247\WpEloquent\Support\Facades\DB;
$results = DB::select('select * from users where id = ?', [1]);

use As247\WpEloquent\Support\Facades\Schema;
Schema::create('users', function ($table) {
    $table->increments('id');
    $table->string('email')->unique();
    $table->timestamps();
});

class User extends As247\WpEloquent\Database\Eloquent\Model {}

$users = User::where('votes', '>', 1)->get();