PHP code example of rockschtar / wordpress-database-fluent

1. Go to this page and download the library: Download rockschtar/wordpress-database-fluent 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/ */

    

rockschtar / wordpress-database-fluent example snippets


WPDB::insert()
    ->table('wp_my_table')
    ->data(['column1' => 'hello', 'column2' => 'world', 'column3' => 1])
    ->format(['%s', '%s', '%d'])
    ->execute();

WPDB::update()
    ->table('wp_my_table')
    ->data(['column1' => 'hello', 'column2' => 'world', 'column3' => 1])
    ->format(['%s', '%s', '%d'])
    ->where(['column4' => 5])
    ->whereFormat(['%d'])
    ->execute();

WPDB::delete()
    ->table('wp_my_table')
    ->where(['column4' => 5])
    ->whereFormat(['%d'])
    ->execute();

WPDB::query()
    ->query('SELECT * FROM wp_my_table WHERE column1=%d', [1]);

WPDB::results()
    ->query('SELECT * FROM wp_my_table WHERE column1=%s LIMIT 0, 10', ['abc']);

WPDB::getVar()
    ->query('SELECT COUNT(*) FROM wp_my_table WHERE column1=%d', [1]);

WPDB::getRow()
    ->query('SELECT column2, column3 FROM wp_my_table WHERE column1=%d', [1]);