pronamic/wp-db 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pronamic/wp-db

Composer 安装命令:

composer require pronamic/wp-db

包简介

Database library for WordPress.

README 文档

README

Examples

<?php

$database = new Database();

$payments_table = new Table(
	'mollie_payments',
	[
		new Column( 'id', 'BIGINT(16) UNSIGNED NOT NULL AUTO_INCREMENT', '%d' ),
		new Column( 'created', 'TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP', '%s' ),
		new Column( 'account_post_id', 'BIGINT(16) UNSIGNED DEFAULT NULL', '%s' ),
		new Column( 'mollie_id', 'VARCHAR(20) DEFAULT NULL', '%s' ),
		new Column( 'mode', 'VARCHAR(20) DEFAULT NULL', '%s' ),
		new Column( 'created_at', 'DATETIME DEFAULT NULL', '%s' ),
		new Column( 'status', 'VARCHAR(20) DEFAULT NULL', '%s' ),
		new Column( 'is_cancelable', 'BOOL DEFAULT NULL', '%d' ),
		new Column( 'paid_at', 'DATETIME DEFAULT NULL', '%s' ),
		new Column( 'amount', 'NUMERIC(15,2) DEFAULT NULL', '%s' ),
		new Column( 'description', 'VARCHAR(200) DEFAULT NULL', '%s' ),
		new Column( 'method', 'VARCHAR(20) DEFAULT NULL', '%s' ),
		new Column( 'json', 'TEXT DEFAULT NULL', '%s' ),
	],
	'
	PRIMARY KEY  (id),
	UNIQUE KEY mollie (mollie_id)
	'
);

$payments_table->primary_key    = 'id';
$payments_table->updated_at_key = null;
$payments_table->created_at_key = null;

$database->register_table( $payments_table );

$database->install();
<?php

$payments_table = $database->get_table( 'mollie_payments' );

$condition = [
	'mollie_id' => $payment->id,
];

$data = [

];

$payment_row = $payments_table->first_row( $condition );

if ( null !== $payment_row ) {
	$payments_table->update( $values, $payment_row->id );
}

if ( null === $payment_row ) {
	$id = $payments_table->insert( $data );
}

Resources

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2022-11-01