Hongmu Notes
Home Program Notes How to quickly add columns in batches in Yiyou CMS? Add 1000 columns at once!
Program Notes Yiyoucms

How to quickly add columns in batches in Yiyou CMS? Add 1000 columns at once!

How to quickly add columns in batches in Yiyou CMS? Add 1000 columns at once!

Since I had a specific need, I wrote some PHP code.

PHP code

<?php
$filePath = './sort.txt';

// 包含数据库配置文件
$dbSet = require('../application/database.php');

// 连接数据库
$conn = mysqli_connect($dbSet['hostname'], $dbSet['username'], $dbSet['password'], $dbSet['database']);

// 检查连接是否成功
if (!$conn) {
  die("数据库连接失败:" . mysqli_connect_error());
}

// 读取文本文件
$file = fopen($filePath, "r") or die("无法打开文件!");
// 逐行处理文件内容
while(!feof($file)) {
  $line = fgets($file);
  $line = str_replace("\n",'',$line);
  $arr =explode('|',$line);
  // 将每行数据拆分成数组
  $data = array(
    'typename' => $arr[0],
    'channeltype' => '1',
    'current_channel' => '1',
    'parent_id' => '0',
    'topid' => '0',
    'dirname' => $arr[2],//栏目url
    'dirpath' => '/'.$arr[2],
    'englist_name' => '',
    'grade' => '0',
    'typelink' => '',
    'litpic' => '',
    'templist' => 'lists_article.htm',
    'tempview' => 'view_article.htm',
    'seo_title' => "{$arr[0]}歌曲歌单推荐 - 分享最新最全的{$arr[0]}歌曲歌单",
    'seo_keywords' => $arr[0],
    'seo_description' => $arr[1],
    'sort_order' => '100',
    'is_hidden' => '0',
    'is_part' => '0',
    'admin_id' => '1',
    'is_del' => '0',
    'del_method' => '0',
    'status' => '1',
    'is_release' => '0',
    'weapp_code' => '',
    'lang' => 'cn',
    'add_time' => time(),
    'update_time' => time()
  );

    
  // 构建插入数据库的SQL语句
  $keys = implode(", ", array_keys($data));
  $values = "'" . implode("', '", array_values($data)) . "'";
  $sql = "INSERT INTO `ey_arctype` ($keys) VALUES ($values)";
// echo $sql."<br>";die;
  if (mysqli_query($conn, $sql)) {
    echo "记录插入成功<br>";
  } else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  }
}
fclose($file);
mysqli_close($conn);
?>

TXT Column – Text

女生|【女生歌曲歌单推荐】栏目为您提供关于【女生歌曲歌单推荐】的分享,精选适合女生的甜美、温柔和可爱的歌曲,陪伴你的时光。如果您觉得女生歌曲歌单推荐栏目不错,请多多支持!我们将持续分享更好的女生歌曲歌单推荐。|Girls
音乐|【音乐歌曲歌单推荐】栏目为您提供关于【音乐歌曲歌单推荐】的分享,为你推荐最新、最热的各类音乐歌曲,满足你对音乐的不同需求。如果您觉得音乐歌曲歌单推荐栏目不错,请多多支持!我们将持续分享更好的音乐歌曲歌单推荐。|music
英文|【英文歌曲歌单推荐】栏目为您提供关于【英文歌曲歌单推荐】的分享,精选优美动听的英文歌曲,让你感受英语世界的魅力。如果您觉得英文歌曲歌单推荐栏目不错,请多多支持!我们将持续分享更好的英文歌曲歌单推荐。|English

Those who understand will naturally understand.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

How to quickly modify columns in batches in Yiyou CMS?

How to quickly modify columns in batches in Yiyou CMS? Program Notes Yiyoucms

After downloading the Yiyou template, you will find that there are many columns that need to be modified, but I only want to modify the column name, column description, column keywords, and keep the others unchanged. How to do this? PHP script&lt;?php $filePath = './sort.txt'; // Contains database configuration file $dbSet = require('../application/data…
👁 2349
Yiyoucms batch modification of published articles

Yiyoucms batch modification of published articles Program Notes Yiyoucms

After downloading the Yiyou template, I am used to modifying articles directly, so I wrote a php to batch modify Yiyou articles! Including: article title, article content, article description, article keywords (word segmentation of the title) article tag, article release time, etc.! The published article comes from the self-created API interface of Empire CMS! The interface code is very simple: &lt;?php header("content-type:applicati…
👁 321
Yiyou cms php remotely obtains article data and publishes articles regularly

Yiyou cms php remotely obtains article data and publishes articles regularly Program Notes Yiyoucms

PHP remotely obtains article data and then publishes it to your own website! Comes with optimized dual titles, comes with keyword segmentation, automatically inserts pictures into the article, comes with tag aggregation, automatically updates the homepage cache, and cooperates with the pagoda plan task to realize automatic update code: 🔒 Hidden content: View after comment&lt;?php // token verification $token = md5('Your key'); // echo $token; …
👁 194
Summary of common problems in Yiyou CMS installation

Summary of common problems in Yiyou CMS installation Program Notes Yiyoucms

As an enterprise website building system developed based on PHP+MySQL, EyouCMS often encounters various problems during the actual installation and deployment process due to differences in server environments and improper operating procedures. This article summarizes the 7 most common installation errors and their solutions for your reference. Question 1: The installation error "Please carefully check the database account and password" error phenomenon: During the installation process, it prompts "Database connection failed, please try again..."
👁 72
EyouCMS (EyouCms) system installation tutorial

EyouCMS (EyouCms) system installation tutorial Program Notes Yiyoucms

1. System Overview Eyou Content Management System (EyouCms) is an enterprise-level open source website building system developed based on PHP+MySQL architecture, using ThinkPHP 5.0 as the underlying framework. 2. Environmental requirements Before installing EyouCms, please ensure that the server environment meets the following requirements: Project requirements operating system Linux/Unix/WindowsWeb server Nginx/…
👁 58
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 197

Recommended reading

Responsive Early Childhood Education Institution Website Template 0853

Responsive Early Childhood Education Institution Website Template 0853 Practical Collection Yiyou template

This EYO CMS responsive template is ideal for early childhood education institutions. Its vibrant and playful design effectively showcases early education programs, the teaching environment, faculty expertise, and educational philosophy. It helps these institutions attract parents online and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EYO CMS | EYO CMS (Eyo...
👁 50
Responsive Photo Gallery Website Template 0192

Responsive Photo Gallery Website Template 0192 Practical Collection Yiyou template

An eYouCMS responsive website template designed for photo albums, photo books, and the photography industry. Its visual art-inspired design is perfect for showcasing photographic works, photo book collections, album designs, and photography services. It helps photography studios display their portfolio online and attract clients. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eYouCMS | eYouCMS (...
👁 51
(Adaptive mobile version) PBootCMS template for micro-business supply chain websites – Download e-commerce and micro-business agency website templates – 0726

(Adaptive mobile version) PBootCMS template for micro-business supply chain websites – Download e-commerce and micro-business agency website templates – 0726 Practical Collection pbootcms Template

A PbootCMS website template designed for WeChat business suppliers and online store agents, compatible with both PC and WAP devices. Its practical information-flow design is ideal for showcasing WeChat business products, agent policies, and supply chain information. This template helps WeChat business platforms or supplier websites attract agents and distributors online. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 50
(PC + WAP) Green Marketing-Driven Universal Corporate Website – PBootCMS Template; Industrial Paper Pipe and Paper Manufacturing Website Source Code Download – 0093

(PC + WAP) Green Marketing-Driven Universal Corporate Website – PBootCMS Template; Industrial Paper Pipe and Paper Manufacturing Website Source Code Download – 0093 Practical Collection pbootcms Template

A PbootCMS green marketing template designed for industrial paper tube manufacturers, paper manufacturing companies, and general enterprises; supports both PC and WAP devices. Its clean and practical design is ideal for showcasing industrial packaging products and manufacturing capabilities. This template helps paper companies demonstrate their production scale and product range online, thereby enhancing their competitiveness in the industry. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: w...
👁 55
Responsive professional children's education and training website template – 0854

Responsive professional children's education and training website template – 0854 Practical Collection Yiyou template

An eyouCMS responsive website template designed for the professional children's education and training industry. Its vibrant and educational design effectively showcases children's training courses, faculty expertise, teaching environments, and student achievements. This template helps children's educational institutions attract parents online and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Installation Questions for YouyouCMS...
👁 47
Responsive Digital Website Template 0193

Responsive Digital Website Template 0193 Practical Collection Yiyou template

This set of eyoucms responsive templates is suitable for the digital electronics industry. The design style is scientific and fashionable, and it can display digital products, electronic equipment, technical parameters and brand image. It is helpful for digital brands to display their products online and attract technology enthusiasts and consumers. Template Display Installation Instructions Website Background: /login.php Account: admin Password: admin Related Articles Easy CMS Installation FAQ Summary Easy CMS…
👁 35