PHP code example of wenprise / wp-db-base

1. Go to this page and download the library: Download wenprise/wp-db-base 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/ */

    

wenprise / wp-db-base example snippets


class OpenAuth extends WPDBase\Database
{

    /**
     * 定义主题路径命名空间
     */
    public function setTables()
    {

        return [

            // 用户每日成就
            "CREATE TABLE `{$this->wpdb->prefix}open_auths` (
		id bigint(20) NOT NULL AUTO_INCREMENT,
		user_id bigint(20) NOT NULL,
		provider varchar(200) DEFAULT NULL,
		open_id varchar(200) DEFAULT NULL,
		union_id varchar(200) DEFAULT NULL,
		access_token varchar(200) DEFAULT NULL,
		refresh_token varchar(200) DEFAULT NULL,
		nickname varchar(20) DEFAULT NULL,
		avatar varchar(200) DEFAULT NULL,
		province varchar(20) DEFAULT NULL,
		city varchar(20) DEFAULT NULL,
		gender varchar(20) DEFAULT NULL,
		created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
		updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
		deleted_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
		PRIMARY KEY  (id)
	    ) $this->collate;",

        ];
    }
}

new OpenAuth();