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

How to quickly modify columns in batches in Yiyou CMS?

How to quickly modify columns in batches in Yiyou CMS?

After downloading the Yiyou template, you'll notice that many sections need to be modified. However, I only want to change the section names, descriptions, and keywords; everything else should remain unchanged. How can I do this?

PHPscript

<?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());
}

// 查询数据库中的数据
$sqlQuery = "SELECT * FROM `ey_arctype` WHERE `tempview` != ' ' AND `is_part` = 0 AND `is_del` = 0";
$result = mysqli_query($conn, $sqlQuery);

if (mysqli_num_rows($result) > 0) {
  // 输出数据
  while ($row = mysqli_fetch_assoc($result)) {
      // 读取文件中的一行内容
      $str = readOneLine($filePath);
      $arr = explode("|", $str);

      // 更新数据库中的记录
      $newSeoDescription = $arr[1];
      $newTypeName = $arr[0];
      $seo_keywords = str_replace("句子", '', $arr[0]);

      $updateSql = "UPDATE `ey_arctype` SET `seo_description` = ?, `seo_keywords` = ?, `typename` = ? WHERE `id` = ?";
      $stmt = mysqli_prepare($conn, $updateSql);
      mysqli_stmt_bind_param($stmt, "sssi", $newSeoDescription, $seo_keywords, $newTypeName, $row['id']);
      
      if (mysqli_stmt_execute($stmt)) {
        echo "记录 ID " . $row['id'] . " 更新成功<br>";
      } else {
        echo "Error 更新记录: " . mysqli_error($conn);
      }
  }
} else {
  echo "0 结果";
}

// 关闭数据库连接
mysqli_close($conn);

function readOneLine($filePath) {
    // 读取文件内容
    $fileContent = file($filePath);

    // 获取第一行内容
    $firstLine = $fileContent[0];

    // 删除第一行
    array_shift($fileContent);

    // 将剩余内容重新写入文件
    file_put_contents($filePath, implode('', $fileContent));

    // 返回第一行内容
    return $firstLine;
}
?>

txttext

浪漫句子|【浪漫句子】栏目为您提供关于【浪漫的句子】分享,浪漫而唯美的文字,让你感受到爱情的魅力和美好。如果您觉得浪漫句子栏目不错,请多多支持!我们将持续分享更好的浪漫句子。
温暖句子|【温暖句子】栏目为您提供关于【温暖的句子】分享,温暖人心的言辞,给人带来温馨和舒适的感觉。如果您觉得温暖句子栏目不错,请多多支持!我们将持续分享更好的温暖句子。
温柔句子|【温柔句子】栏目为您提供关于【温柔的句子】分享,柔情款款的句子,传递温柔与关怀的情感。如果您觉得温柔句子栏目不错,请多多支持!我们将持续分享更好的温柔句子。
微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

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

Author homepage View home page →

Related articles

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 scrolling photo album website template 0194

Responsive scrolling photo album website template 0194 Practical Collection Yiyou template

An EYO CMS responsive website template designed for the scrolling gallery and photo album industry. Its creative visual design and full-screen scrolling effect vividly showcase photographic works and brand stories. This template helps photography agencies present their premium brand image online and attract customers. 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...
👁 52
(PC + WAP) Income-Generating App Software – Download pbootCMS Website Templates; Official App Download Source Code – 0094

(PC + WAP) Income-Generating App Software – Download pbootCMS Website Templates; Official App Download Source Code – 0094 Practical Collection pbootcms Template

This PbootCMS template is ideal for official websites dedicated to earning money through mobile apps or software downloads, supporting both PC and WAP access. Its modern, tech-driven design effectively showcases app features, software highlights, and download guidance, helping software developers or monetization platforms create branded official websites and app download pages with high conversion rates. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin...
👁 41
Children's Education and Training Institution Website Template 0856

Children's Education and Training Institution Website Template 0856 Practical Collection Yiyou template

An EyouCMS website template designed specifically for children's educational and training institutions. Its vibrant and educational design enables effective presentation of children's training programs, teaching environments, faculty expertise, and student achievements. This template helps children's education institutions attract parents online and enhance their brand image. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 51
(Adaptive mobile version) Responsive indoor architectural design engineering company website – PBootCMS template; Download source code for interior design company websites – 0728

(Adaptive mobile version) Responsive indoor architectural design engineering company website – PBootCMS template; Download source code for interior design company websites – 0728 Practical Collection pbootcms Template

A responsive website template for interior design firms using PbootCMS, compatible with both PC and WAP devices. Featuring a professional and artistic design style, this template is ideal for interior design companies to showcase their commercial and residential space projects. It helps design agencies attract high-end clients and secure project collaborations online. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn – Related...
👁 38
Responsive, marketing-oriented automotive parts website template – 0195

Responsive, marketing-oriented automotive parts website template – 0195 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the automotive parts marketing sector, featuring a professional marketing design style that effectively showcases automotive parts products, technical specifications, brand advantages, and after-sales support. It enables automotive parts enterprises to showcase their products online and attract targeted customers. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 33
(PC+WAP) Art Stone Carving – PbootCMS Corporate Website Template; Classical Ink Wash Style Website Source Code Download – 0095

(PC+WAP) Art Stone Carving – PbootCMS Corporate Website Template; Classical Ink Wash Style Website Source Code Download – 0095 Practical Collection pbootcms Template

An enterprise PbootCMS website template featuring artistic stone carving designs and classical ink-wash aesthetics, compatible with both PC and WAP devices. Its design embodies the charm of Eastern art, making it ideal for showcasing stone carvings, garden landscaping stones, and cultural and creative products. This template enables stone carving companies to showcase their exquisite craftsmanship and aesthetic designs online, thereby enhancing their brand value. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin...
👁 48