关于如何的正确自建表

超级版主 沉冰浮水 9月前 452

完整插件下载: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);
    }
  }
}


沉冰浮水.tk  ←_←我大概率能够解答你所实际面临的问题,然而问题往往是你提出的问题根本无从回答

最新回复 (1)
全部楼主
  • 用户 17cat 9月前 0
    引用 2
    可行,但并不完全正确。🤭

    有问题联系QQ 8769298

    • ZBlogger技术交流中心
      3
          
返回