calderawp/caldera-db

WordPress自定义表抽象

0.2.0 2019-04-22 17:38 UTC

This package is auto-updated.

Last update: 2024-09-23 07:05:42 UTC


README

👀🌋 这是Caldera框架的一个模块:Caldera Framework

安装

  • 添加到您的包中
    • composer require calderawp/http
  • 开发安装
    • git clone git@github.com:CalderaWP/http.git && composer install

概述

此包提供数据库表创建和基本查询。

使用YAML定义表架构。目前,仅支持WPDB集成。

Caldera Forms表

V1表

V2表

从属性创建表

use calderawp\DB\Factory;
use calderawp\interop\Attribute;

//id column
$attributeData = [
    'name' => 'id',
    'sqlDescriptor' => 'int(11) unsigned NOT NULL AUTO_INCREMENT',
    'format' => '%d',
];

//name column
$attribute2Data = [
    'name' => 'name',
    'sqlDescriptor' => 'varchar(256) NOT NULL',
    'format' => '%s',
];

//name of table
$tableName = 'cf_whatever';
//name of primary key(s)
$primaryKey = 'id';
//name of index(es)
$indexes = ['name'];

//Create factory
$factory = new Factory();
//Create Table schema
$attributes = [$attributeData, $attribute2Data];
$tableSchema = $factory->tableSchema($attributes, $tableName, $primaryKey, $indexes);
//Create table using WordPress' wpdb
$table = $factory->wordPressDatabaseTable($tableSchema,$wpdb);

许可证、版权等。

版权所有 2018+ CalderaWP LLC,并按GNU GPL许可证条款授权。请与您的邻居分享。