1. Go to this page and download the library: Download hollisho/wp-orm 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/ */
hollisho / wp-orm example snippets
use WPOrm\Model\Model;
class Post extends Model
{
protected static string $table = 'posts';
public function author()
{
return $this->belongsTo(User::class, 'post_author');
}
}
// Query
$posts = Post::where('post_status', 'publish')
->orderBy('post_date', 'desc')
->limit(10)
->get();
// Find by ID
$post = Post::find(1);
// Relationships
$author = $post->author;
// Automatically uses the correct table prefix for the current site
$posts = Post::onSite(2)->where('post_status', 'publish')->get();
// Or use global tables
$users = User::global()->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.