关于如何的正确自建表

超级版主 沉冰浮水 2018-9-8 2510

完整插件下载:https://we.tl/t-fHdIlGQsAE

<?php
//注册插件
RegisterPlugin("Order", "ActivePlugin_Order");
function ActivePlugin_Order()
{
  Add_Filter_Plugin('Filter_Plugin_Admin_LeftMenu', 'Order_Mng');
}
function Order_Mng(&$leftmenus){
  global $zbp;
  $leftmenus['nav_order'] = MakeLeftMenu("3", "订单管理", $zbp->host . "zb_users/plugin/Order/main.php", "nav_order", "aOrderMng", "");
}
function InstallPlugin_Order()
{
  Order::CreateTable();
}
function UninstallPlugin_Order()
{
}
//数据测试
function Order_test($n = 0)
{
  if ($n > 0)
    Order_test($n - 1);
  $article = new Post();
  $article->LoadInfoByID(15);
  if ($article->ID == 0)
    return false;
  $Count      = 2;
  $Usr        = "usr";
  $Tel        = "10086";
  $Add        = "Add";
  $Note       = "Note";
  $ord        = new Order();
  $ord->LogID = $article->ID;
  $ord->Name  = $article->Title;
  $ord->Count = $Count;
  $ord->Price = $article->Metas->price * $Count;
  $ord->Usr   = $Usr;
  $ord->Add   = $Add;
  $ord->Tel   = $Tel;
  $ord->Note  = $Note;
  return $ord->Save();
}
class Order extends Base
{
  public static $tableX = '%pre%plugin_order';
  public static $datainfoX = array(
    'ID' => array('ord_ID', 'integer', '', 0),
    'Send' => array('ord_Send', 'boolean', '', false),
    'Open' => array('ord_Open', 'boolean', '', true),
    'LogID' => array('ord_LogID', 'integer', '', 0),
    'Time' => array('ord_Time', 'integer', '', 0),
    'Name' => array('ord_Name', 'string', 50, ''),
    'Count' => array('ord_Count', 'integer', '', 1),
    'Price' => array('ord_Price', 'integer', '', 1),
    'Usr' => array('ord_Usr', 'string', 50, ''),
    'Add' => array('ord_Add', 'string', '', ''),
    'Tel' => array('ord_Tel', 'string', 50, ''),
    'Note' => array('ord_Note', 'string', 255, ''),
    'Mail' => array('ord_Mail', 'string', 50, ''),
    'IP' => array('ord_IP', 'string', 50, '')
  );
  public function __construct()
  {
    parent::__construct(self:😉tableX, self:😉datainfoX, __CLASS__);
    $this->Time = time();
    $this->IP   = GetGuestIP();
  }
  // Order::CreateTable()
  public static function CreateTable()
  {
    global $zbp;
    if (!$zbp->db->ExistTable(self:😉tableX)) {
      $sql = $zbp->db->sql->CreateTable(self:😉tableX, self:😉datainfoX);
      $zbp->db->QueryMulit($sql);
    }
  }
}


「QQ群:我的咸鱼心」「「水坑」系列教程索引
我大概率能够解决你实际面临的问题(收费),只是”你提出的问题“要如何回答则可能是另一个问题。

返回