1. Go to this page and download the library: Download maksimer/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/ */
maksimer / wp-eloquent example snippets
$db = \Maksimer\ORM\Eloquent\Database::instance();
var_dump( $db->table('users')->find(1) );
var_dump( $db->select('SELECT * FROM wp_users WHERE id = ?', [1]) );
var_dump( $db->table('users')->where('user_login', 'john')->first() );
// OR with DB facade
use \Maksimer\ORM\Eloquent\Facades\DB;
var_dump( DB::table('users')->find(1) );
var_dump( DB::select('SELECT * FROM wp_users WHERE id = ?', [1]) );
var_dump( DB::table('users')->where('user_login', 'john')->first() );
$users = $db->table('users')->get();
foreach ($users as $user) {
var_dump($user->display_name);
}
use \Maksimer\ORM\Eloquent\Model as Model;
class Employee extends Model {
}
var_dump( Employee::all()->toArray() ); // gets all employees
var_dump( Employee::find(1) ); // find employee with ID 1
use Maksimer\ORM\WP\Post as Post;
var_dump( Post::all() ); //returns only posts with WordPress post_type "post"
use Maksimer\ORM\WP\Post as Post;
var_dump(Post::type('page')->get()->toArray()); // get pages
var_dump(Post::status('publish')->get()->toArray()); // get posts with publish status
var_dump(Post::type('page')->status('publish')->get()->toArray()); // get pages with publish status
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.