<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dirty_pig</title>
    <description>The latest articles on DEV Community by dirty_pig (@huangcong12).</description>
    <link>https://dev.to/huangcong12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1161868%2F579272c5-1844-4a1f-92f9-89de0e78eb8d.png</url>
      <title>DEV Community: dirty_pig</title>
      <link>https://dev.to/huangcong12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/huangcong12"/>
    <language>en</language>
    <item>
      <title>How to Adjust Shopify Store Product Image Resolution</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Sun, 14 Apr 2024 02:55:10 +0000</pubDate>
      <link>https://dev.to/huangcong12/how-to-adjust-shopify-store-product-image-resolution-474h</link>
      <guid>https://dev.to/huangcong12/how-to-adjust-shopify-store-product-image-resolution-474h</guid>
      <description>&lt;p&gt;&lt;strong&gt;How to Adjust Shopify Store Product Image Resolution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you find that the product image resolution in your Shopify store's initial setup is not suitable, you can quickly adjust it to the ideal 1600 x 1600 resolution without any technical knowledge. We will use the &lt;a href="https://apps.shopify.com/image-precision-ai"&gt;LitaCat - Image Precision AI&lt;/a&gt; app to accomplish this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;First, install &lt;a href="https://apps.shopify.com/image-precision-ai"&gt;LitaCat - Image Precision AI&lt;/a&gt;, and you'll receive a $1 credit.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Finding Images with Resolution Less Than 1600
&lt;/h3&gt;

&lt;p&gt;You have two methods to find images that need resolution adjustment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the corresponding entry on the app's homepage to enter the search page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxkeoqqvt5r2760wtp19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxkeoqqvt5r2760wtp19.png" alt="Image description" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the "Optimization Filter" on the "Product Image Repair" page to search for images that meet the criteria.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FeaKS6Ed--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/04/01/660a7ac23e03f.png" alt="Search Images" width="800" height="450"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Selecting Images and Starting the Task
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Choose the images that need resolution adjustment and then click the "Confirm" button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iy2Fqh9l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/04/01/660a7abe465f1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iy2Fqh9l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/04/01/660a7abe465f1.png" alt="Confirm Images" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the secondary confirmation box, you can use the default parameters, but be sure to click "Download Selected Images" to download backups in case the old images are deleted by Shopify after replacement.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl89ijdjhdv6q7fx3r6wl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl89ijdjhdv6q7fx3r6wl.png" alt="Image description" width="800" height="815"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After confirming, click the "Submit" button. Then, in the pop-up window, select "View."&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk74qda0nwxf88ew15jxx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk74qda0nwxf88ew15jxx.png" alt="Image description" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Wait for the task to be completed.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--09gciqYs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/huangcong12/image_precision_ai_document/assets/2867782/07da1c13-a2f6-4978-acbe-937ec9ea78bf" alt="image" width="800" height="744"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Checking the Results
&lt;/h3&gt;

&lt;p&gt;You have several ways to check the results:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Directly click on the image on the task details page to confirm that the resolution has been changed to 1600.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Lr0wywta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/huangcong12/image_precision_ai_document/assets/2867782/cb88124f-76e2-4ac1-ba4d-0d5110a1ca82" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Lr0wywta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/huangcong12/image_precision_ai_document/assets/2867782/cb88124f-76e2-4ac1-ba4d-0d5110a1ca82" alt="image" width="800" height="563"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go back to the "Product Image Repair" page and check the resolution of the images.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nvauj4mkv67ktbjru0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nvauj4mkv67ktbjru0z.png" alt="Image description" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the product details page in your store to view the images.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--toXR1sEK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/huangcong12/image_precision_ai_document/assets/2867782/2b810574-f700-44be-9525-f5e690713826" alt="image" width="800" height="438"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;With this app, you can quickly and easily adjust the image resolution to the ideal 1600 x 1600. If you need to perform batch operations, you can select multiple images, and the background tasks will handle them one by one, saving you time and effort, making it a valuable tool for merchants.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring AI Tools for Shopify: A Review of Image Processing and Product Description Generation Apps</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Sun, 24 Mar 2024 09:16:12 +0000</pubDate>
      <link>https://dev.to/huangcong12/exploring-ai-tools-for-shopify-a-review-of-image-processing-and-product-description-generation-apps-48n6</link>
      <guid>https://dev.to/huangcong12/exploring-ai-tools-for-shopify-a-review-of-image-processing-and-product-description-generation-apps-48n6</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;AI technology is rapidly evolving, from being initially used exclusively by programmers to now penetrating various industries. Today, let's explore what AI tools in the Shopify App can actually help merchants and practically test the effectiveness of each tool.&lt;/p&gt;

&lt;p&gt;In the Shopify App Store, typing "AI" will bring up many apps. Although they label themselves as using AI technology, today we will only test two types of apps: product text generation and image optimization. We will only test apps that offer free trials.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoring Criteria
&lt;/h2&gt;

&lt;p&gt;Total score: 5 points&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;th&gt;Explanation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Excellent, worth having&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Good, depending on your needs, we suggest you give it a try&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Optional, no significant difference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Doesn't seem necessary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Strongly recommend not installing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  AI Image Processing
&lt;/h1&gt;

&lt;p&gt;Let's start with AI image processing, a category where AI technology has become quite mature. Image processing can be divided into two types: background removal and image enhancement.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://apps.shopify.com/photoroom-production"&gt;PhotoRoom: Background Remover&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Judging by the name and developer, it's possibly developed by &lt;a href="https://www.photoroom.com/"&gt;photoroom&lt;/a&gt;, a company specializing in background image editing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost
&lt;/h3&gt;

&lt;p&gt;No cost information provided, but inside the software, it's mentioned that there's a monthly free allowance of 100 images.&lt;/p&gt;

&lt;h3&gt;
  
  
  Actual Effect
&lt;/h3&gt;

&lt;p&gt;Let's randomly select an image of grapes from the package:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOwU6o1q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6faaa0c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZOwU6o1q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6faaa0c.png" alt="1711185196573.png" width="800" height="758"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ThCWD_aI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6fda5cb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ThCWD_aI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6fda5cb.png" alt="1711185200010.png" width="800" height="802"&gt;&lt;/a&gt;&lt;br&gt;
Then select an image of grass from the first row:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YB8PoJkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9da6c1e41.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YB8PoJkm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9da6c1e41.jpg" alt="微信图片_20240323171806.jpg" width="800" height="840"&gt;&lt;/a&gt;&lt;br&gt;
Let's see the result together, it's great, isn't it?&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X4rQdAQZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9b8104fd5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X4rQdAQZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9b8104fd5.jpg" alt="putao1.jpg" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
Since there's still quota left, let's try changing it to something else:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RcM6n6Nc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea04473b3e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RcM6n6Nc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea04473b3e.jpg" alt="b622eb31583d6383188a6c4bbf44e682 (1).jpg" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E5yGBg5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea04472626.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E5yGBg5t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea04472626.jpg" alt="b622eb31583d6383188a6c4bbf44e682.jpg" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
It feels perfect, giving the impression that it was made by a UI specialist.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rating
&lt;/h3&gt;

&lt;p&gt;5 points&lt;/p&gt;
&lt;h3&gt;
  
  
  Review
&lt;/h3&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions are too simple.&lt;/li&gt;
&lt;li&gt;The list page may display items without images as a blank option.&lt;/li&gt;
&lt;li&gt;It doesn't automatically add the processed images back to the package. After processing, you still need to download and then replace them manually. Hopefully, this will be improved in the future.
Despite the drawbacks, with 100 free images, everything is not a problem. If you have little demand in this area, installing this one will suffice, with perfect results.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  &lt;a href="https://apps.shopify.com/image-precision-ai?from=Shopify_AI_Sidekick1"&gt;LitaCat ‑ Image Precision Ai&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Unlike the previous one, this one is used to convert blurry images into clear ones.&lt;/p&gt;
&lt;h3&gt;
  
  
  Cost
&lt;/h3&gt;

&lt;p&gt;Pay-as-you-go, $1 upon installation, $0.1 per image, approximately allowing for 10 trial images.&lt;/p&gt;
&lt;h3&gt;
  
  
  Effect
&lt;/h3&gt;

&lt;p&gt;This app has internationalization, earning good reviews.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q9Xh0t-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea8b0463e6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q9Xh0t-R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fea8b0463e6.png" alt="1711188348587.png" width="800" height="382"&gt;&lt;/a&gt;&lt;br&gt;
It provides operation documentation, also receiving praise.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TaXyO-1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65feedd67d579.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TaXyO-1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65feedd67d579.png" alt="1711206052663.png" width="779" height="182"&gt;&lt;/a&gt;&lt;br&gt;
Without further ado, let's try it with an image. It has a task concept; each time starts from adding a new task. Within each task, you can select multiple images, probably designed for batch processing.&lt;br&gt;
Select "New Image Enhancement":&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FjJSGKM0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65feee0e72454.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FjJSGKM0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65feee0e72454.png" alt="1711206107572.png" width="800" height="57"&gt;&lt;/a&gt;&lt;br&gt;
Then select images:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c_T0AYKx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a2d2056.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c_T0AYKx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a2d2056.png" alt="1711268144741.png" width="800" height="117"&gt;&lt;/a&gt;&lt;br&gt;
Click "Confirm" in the upper right corner, there's a secondary confirmation pop-up, just leave it as default and click "Submit" directly.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WMcHKik3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a3606af.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WMcHKik3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a3606af.png" alt="1711268157590.png" width="800" height="732"&gt;&lt;/a&gt;&lt;br&gt;
The task is successful; it enters the task details page, the page will automatically refresh, and it's quite fast, only a moment.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MMOKUW1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a32350a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MMOKUW1J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a32350a.png" alt="1711268173849.png" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image appears enlarged and sharpened.&lt;br&gt;
Original image:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W5jJ-alL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a2e699a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W5jJ-alL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a2e699a.jpg" alt="zara-shahjahan-spring-embroidered-jacquard-3-piece-unstitched-suit-zsj24ss-2a-diya_2.jpg" width="800" height="1114"&gt;&lt;/a&gt;&lt;br&gt;
Processed image:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ScYslbc0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a31dd09.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ScYslbc0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/24/65ffe0a31dd09.jpg" alt="c_24_34163822133386_50.jpg" width="800" height="1114"&gt;&lt;/a&gt;&lt;br&gt;
Here, the difference doesn't seem apparent, but on the product page, there's a significant difference. It feels like the entire distance has been reduced, and the details of the clothes are more visible.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rating
&lt;/h3&gt;

&lt;p&gt;4 points&lt;/p&gt;
&lt;h3&gt;
  
  
  Review
&lt;/h3&gt;

&lt;p&gt;If your store images are provided by upstream suppliers and are not clear enough, it's worth trying this app. It might save you a lot of trouble.&lt;br&gt;
Cons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Products don't support fuzzy search&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  AI Generated Product Reviews
&lt;/h1&gt;
&lt;h2&gt;
  
  
  &lt;a href="https://apps.shopify.com/product-description-ai"&gt;AI ChatGPT description: ST&lt;/a&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Package
&lt;/h3&gt;

&lt;p&gt;Free&lt;/p&gt;
&lt;h3&gt;
  
  
  Effect
&lt;/h3&gt;

&lt;p&gt;This is an app that automatically generates product descriptions based on the product name. If your product name is in English, it generates an English description; if the product name is in Chinese, it generates a Chinese description. If it's a mixture of multiple languages, it chooses the first language to generate.&lt;br&gt;
Here's the generated description for The Collection Snowboard: Liquid. Take a look at the result:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5W2DKD06--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f958ce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5W2DKD06--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f958ce.png" alt="1711185160218.png" width="800" height="273"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The Collection Snowboard: Liquid
The Collection Snowboard: Liquid is the ultimate choice for snowboarders of all levels. This high-performance snowboard is designed with precision and durability in mind, making it the perfect companion for your next snowboarding adventure.

Featuring a sleek and modern design, the Liquid snowboard is not only visually appealing but also offers superior functionality. The board is made with top-quality materials, ensuring maximum strength and stability on the slopes.

With its advanced technology and expert craftsmanship, the Liquid snowboard provides excellent control and maneuverability, allowing you to effortlessly glide through the snow. Whether you're hitting the halfpipe or carving through fresh powder, this snowboard will exceed your expectations.

Don't settle for anything less than the best. Choose The Collection Snowboard: Liquid and experience the thrill of snowboarding like never before. Order yours today and get ready to take your snowboarding skills to the next level!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doesn't it also feel impressive? AI utilizes its imagination expertise based on the name to generate content. If done manually, it would require a significant amount of effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rating (Total 5 points)
&lt;/h3&gt;

&lt;p&gt;3 points&lt;/p&gt;

&lt;h3&gt;
  
  
  Review
&lt;/h3&gt;

&lt;p&gt;This is a very interesting app and easy to use, but I don't understand why it's not in the Shopify merchant dashboard and redirects to another page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QBVRqAju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f49df5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QBVRqAju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f49df5.png" alt="1711185167981.png" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need to add descriptions to your packages, you can use it to assist you. It's like having an intern to help you, but it leaves you feeling uneasy, as if it's an experimental product, making you unsure.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://apps.shopify.com/automated-description-writing"&gt;ChatGPT‑AI Product Description&lt;/a&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Packages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Free: 20 tokens per month&lt;/li&gt;
&lt;li&gt;$14.90/month: 2000 tokens per month&lt;/li&gt;
&lt;li&gt;$49.90/month: 10000 tokens per month&lt;/li&gt;
&lt;li&gt;$399.90/month: Unlimited&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Effect
&lt;/h3&gt;

&lt;p&gt;What's better about this one compared to the previous one is that you don't have to navigate to another page; you can operate directly in the Shopify merchant dashboard.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kVBB4MG_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9d4b4b18a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kVBB4MG_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9d4b4b18a.png" alt="1711185430873.png" width="800" height="550"&gt;&lt;/a&gt;&lt;br&gt;
It supports batch operations and has helpful documentation, which leaves a better impression.&lt;br&gt;
We have 20 free tokens; let's try a package to see the effect. Same operating habits: find the product you want and then click "Generate". After clicking, you'll enter the next page, with many parameters to adjust, but the main difference lies in the product description and language. This is where it differs from the previous one; it generates descriptions based on the product Title, the description we fill in, and the language we choose. These three parameters together add a bit of complexity, but it's more powerful than the previous one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HDibvt3u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f8dddc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HDibvt3u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f8dddc.png" alt="1711185177580.png" width="800" height="807"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The title remains unchanged, with additional details: "Made in Canada, World ski racing used to use the brand, The spokesperson is Gu Ailing", generating in English.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bhIH3aPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f3b758.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bhIH3aPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f3b758.png" alt="1711185180861.png" width="800" height="621"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking "Generate Deactription", three descriptions will appear on the right side of the page, provided for you to choose. Clicking the text will display a rich text input box for editing. Of the three descriptions for this product, only the first one has more text; the other two simply expand on the provided details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ASs56rll--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6fa7444.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ASs56rll--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6fa7444.png" alt="1711185183887.png" width="800" height="1191"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zLpRrBag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f17999.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zLpRrBag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f17999.png" alt="1711185186953.png" width="800" height="766"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the bottom of the page, there's also "History" and "Get Initial Descriptions". History likely saves the history of each generation, and "Get Initial Descriptions" may be the first item in the history? It offers a remedy feature.&lt;/p&gt;

&lt;p&gt;Let me show you the effect. I provided the title: "The Collection Snowboard: Hydrogen", Add more Product Details: "Made in Canada, World ski racing used to use the brand, The spokesperson is Gu Ailing".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Made in Canada for superior quality and craftsmanship
Trusted by world ski racing professionals
Endorsed by the renowned spokesperson Gu Ailing
Conquer the slopes with confidence and style with the Hydrogen snowboard from The Collection. Crafted in Canada with precision and expertise, this snowboard offers unmatched performance and durability. Trusted by world ski racing athletes, you can rely on the Hydrogen to deliver a smooth and exhilarating ride every time. With the endorsement of Gu Ailing, a symbol of excellence in snow sports, this snowboard is designed to elevate your experience on the slopes. Dominate the mountain and carve your path to success with The Collection Snowboard: Hydrogen.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shall we try copying it to &lt;a href="https://chat.openai.com/"&gt;https://chat.openai.com/&lt;/a&gt; to see the effect? It's not bad, especially since GPT 3.5 is free.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qyl0JKOS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f67ce3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qyl0JKOS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vip.helloimg.com/i/2024/03/23/65fe9c6f67ce3.png" alt="1711185190644.png" width="800" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, this tool can provide value through batch operations, but unlike other types of apps, the result of this app requires manual review. At $14.90 per month, what do you think?&lt;/p&gt;

&lt;h3&gt;
  
  
  Rating (Total 5 points)
&lt;/h3&gt;

&lt;p&gt;3 points. Although it performs well, it's expensive and doesn't have particularly strong output. I think it deserves only 3 points.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;You've seen the effects of image processing and text generation apps. The image app can be used in work, while the text app can only serve as an assistant for now. At this stage, I don't recommend using it.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Ways to View SQL in Laravel</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Sat, 16 Sep 2023 09:45:44 +0000</pubDate>
      <link>https://dev.to/huangcong12/ways-to-view-sql-in-laravel-9n1</link>
      <guid>https://dev.to/huangcong12/ways-to-view-sql-in-laravel-9n1</guid>
      <description>&lt;p&gt;After many years of experience in Laravel development, the author has compiled various methods to help you view SQL queries executed in Laravel. Hopefully, one of them will suit your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 1: Using Laravel's Built-In Logging System
&lt;/h2&gt;

&lt;p&gt;Laravel provides a powerful logging system. You can use the &lt;code&gt;DB::listen&lt;/code&gt; method to listen to database query events and log query information to log files. To use this method, you can add the following code to the &lt;code&gt;boot&lt;/code&gt; method of &lt;code&gt;AppServiceProvider&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="no"&gt;Illuminate\Support\Facades\DB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;boot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;\Log&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'bindings'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'time'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will log every executed SQL query, including the query statement, bound parameters, and execution time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 2: Using the Laravel Debugbar Extension
&lt;/h2&gt;

&lt;p&gt;Laravel Debugbar is a popular debugging tool that provides an easy-to-use interface for viewing various debugging information, including SQL queries. You can install Debugbar using Composer:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

composer require barryvdh/laravel-debugbar


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then, add &lt;code&gt;Barryvdh\Debugbar\ServiceProvider&lt;/code&gt; to the &lt;code&gt;providers&lt;/code&gt; array in your &lt;code&gt;config/app.php&lt;/code&gt; file. Afterward, you can view SQL queries and execution times for each request in your browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 3: Using Laravel Telescope
&lt;/h2&gt;

&lt;p&gt;Laravel Telescope is an official debugging and monitoring tool provided by Laravel. It allows you to view various operations performed by your application, including SQL queries. You can install Telescope using Composer:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

composer require laravel/telescope


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then, run Telescope's installation command and migrate:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

php artisan telescope:install
php artisan migrate


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After enabling Telescope, you can access its dashboard at the &lt;code&gt;/telescope&lt;/code&gt; endpoint to view SQL queries and other useful debugging information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 4: Using the &lt;code&gt;DB::getQueryLog&lt;/code&gt; Method
&lt;/h2&gt;

&lt;p&gt;You can use the &lt;code&gt;DB::getQueryLog&lt;/code&gt; method in your code to retrieve all SQL queries executed during the current request. For example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;

&lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;enableQueryLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// Perform some query operations&lt;/span&gt;
&lt;span class="nv"&gt;$queries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getQueryLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will return an array containing all executed SQL queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 5: Using the &lt;code&gt;toSql()&lt;/code&gt; Method
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;toSql&lt;/code&gt; method can convert a query builder instance into the corresponding SQL statement, but it does not execute the SQL statement. This method is mainly used for debugging purposes.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'votes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toSql&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;$query&lt;/code&gt; variable now contains the corresponding SQL statement, but the SQL statement itself is not executed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 6: Using External Tools
&lt;/h2&gt;

&lt;p&gt;If you prefer not to modify your code, the following two methods can help you view SQL queries:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Enabling MySQL Query Logging
&lt;/h3&gt;

&lt;p&gt;Simply add the following code to the &lt;code&gt;my.cnf&lt;/code&gt; file of your MySQL server to enable logging of all executed SQL queries:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# Log SQL queries
general_log = 1
general_log_file = /var/log/mysql/general_sql.log


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tsvpdnhsxkvqxho7h52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tsvpdnhsxkvqxho7h52.png" alt="MySQL Log"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use this method, you need permission to access the MySQL server and log in to it. If multiple users share a MySQL development server, it's best not to enable this feature as it can cause confusion. Additionally, since the logs contain a lot of information, it can be difficult to identify which queries are yours. Therefore, it is recommended to use this feature on a testing server and only enable it when needed to address significant issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;a href="https://plugins.jetbrains.com/plugin/22655-mysql-proxy/" rel="noopener noreferrer"&gt;Using the PHPStorm Plugin&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The PHPStorm plugin marketplace offers a plugin called &lt;a href="https://plugins.jetbrains.com/plugin/22655-mysql-proxy/" rel="noopener noreferrer"&gt;MySQL Proxy&lt;/a&gt; that, when installed, can display all SQL logs by configuring your database connection to proxy through it. This is the author's preferred tool, as it doesn't require code changes, doesn't need MySQL database server permissions, and offers convenient retrieval.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwig7przghnl3s3ttyn1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwig7przghnl3s3ttyn1.png" alt="MySQL Proxy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are some methods for viewing SQL queries executed in Laravel. You can choose the one that suits your project and requirements for debugging and monitoring database queries.&lt;/p&gt;

&lt;p&gt;We hope this article is helpful to you! If you have any questions or suggestions, please feel free to leave a comment.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Laravel 查看 SQL 的方式</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Sat, 16 Sep 2023 09:42:14 +0000</pubDate>
      <link>https://dev.to/huangcong12/laravel-cha-kan-sql-de-fang-shi-140i</link>
      <guid>https://dev.to/huangcong12/laravel-cha-kan-sql-de-fang-shi-140i</guid>
      <description>&lt;p&gt;在多年的 Laravel 開發經驗中，小編整理了多種方法，幫助您查看 Laravel 執行的 SQL 查詢。希望其中一種適合您的需求。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法一：使用 Laravel 的內建日誌系統
&lt;/h2&gt;

&lt;p&gt;Laravel 提供了強大的日誌系統，您可以使用 &lt;code&gt;DB::listen&lt;/code&gt; 方法監聽資料庫查詢事件並將查詢日誌記錄到日誌檔案中。要使用這種方法，您可以在 &lt;code&gt;AppServiceProvider&lt;/code&gt; 的 &lt;code&gt;boot&lt;/code&gt; 方法中添加以下程式碼：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="no"&gt;Illuminate\Support\Facades\DB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;boot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;\Log&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'bindings'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'time'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;這將把每個執行的 SQL 查詢記錄到日誌檔案中，包括查詢語句、綁定的參數和執行時間。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法二：使用 Laravel Debugbar 擴充套件
&lt;/h2&gt;

&lt;p&gt;Laravel Debugbar 是一個流行的調試工具，它提供了一個易於使用的介面，用於查看各種調試資訊，包括 SQL 查詢。您可以使用 Composer 安裝 Debugbar：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require barryvdh/laravel-debugbar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;然後，將 &lt;code&gt;Barryvdh\Debugbar\ServiceProvider&lt;/code&gt; 添加到您的 &lt;code&gt;config/app.php&lt;/code&gt; 的 &lt;code&gt;providers&lt;/code&gt; 陣列中。之後，您可以在瀏覽器中查看每個請求的 SQL 查詢以及執行時間。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法三：使用 Laravel Telescope
&lt;/h2&gt;

&lt;p&gt;Laravel Telescope 是 Laravel 官方提供的一個調試和監控工具，它允許您查看應用程式執行的各種操作，包括 SQL 查詢。您可以使用 Composer 安裝 Telescope：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require laravel/telescope
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;然後，執行 Telescope 的安裝命令並執行遷移：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan telescope:install
php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;啟用 Telescope 後，您可以在 &lt;code&gt;/telescope&lt;/code&gt; 路徑下訪問它的儀表板來查看 SQL 查詢和其他有用的調試資訊。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法四：使用 &lt;code&gt;DB::getQueryLog&lt;/code&gt; 方法
&lt;/h2&gt;

&lt;p&gt;您可以在程式碼中使用 &lt;code&gt;DB::getQueryLog&lt;/code&gt; 方法來獲取當前請求中執行的所有 SQL 查詢。例如：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;enableQueryLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// 執行一些查詢操作&lt;/span&gt;
&lt;span class="nv"&gt;$queries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getQueryLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;這將返回一個陣列，其中包含了執行的所有 SQL 查詢。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法五：使用 &lt;code&gt;toSql()&lt;/code&gt; 方法
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;toSql&lt;/code&gt; 方法可以將一個查詢建立器實例轉換為對應的 SQL 語句，但是它不會執行這條 SQL 語句。這個方法主要用於調試目的。&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'votes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toSql&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;這個 &lt;code&gt;$query&lt;/code&gt; 變數現在包含了對應的 SQL 語句，但是這個 SQL 語句並沒有被執行。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法六：使用外部工具
&lt;/h2&gt;

&lt;p&gt;如果您不想修改程式碼，以下兩種方法可以幫助您查看 SQL 查詢：&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 啟用 MySQL 的查詢日誌記錄功能
&lt;/h3&gt;

&lt;p&gt;只需在 MySQL 的 &lt;code&gt;my.cnf&lt;/code&gt; 檔案中添加以下程式碼，即可讓 MySQL 記錄所有執行的 SQL 查詢&lt;/p&gt;

&lt;p&gt;：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 記錄 SQL
general_log = 1
general_log_file = /var/log/mysql/general_sql.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15gunr0gft189calrxjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15gunr0gft189calrxjd.png" alt="啟用 MySQL 的查詢日誌記錄功能" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;要使用這種方法，您需要具備對 MySQL 伺服器的權限並登錄到伺服器上。如果多人共享一台 MySQL 開發伺服器，最好不要啟用此功能，因為會引起混亂。此外，由於記錄包含大量資訊，很難確定哪些查詢是您的，因此建議在測試伺服器上使用，只在需要解決重要問題時才啟用。&lt;/p&gt;

&lt;h3&gt;
  
  
  2. 使用 PHPStorm 插件
&lt;/h3&gt;

&lt;p&gt;PHPStorm 的插件市場提供了一個名為 MySQL Proxy 的插件，將程式碼中的資料庫配置更改為它代理的埠口，就能將所有的 SQL 記錄展示出來。這是小編目前使用的唯一方便的工具，不需要改動程式碼，不需要 MySQL 資料庫伺服器權限，並且檢索方便。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv04u1eh00eqhnxgihwnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv04u1eh00eqhnxgihwnr.png" alt="使用 PHPStorm 插件" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;以上是一些查看在 Laravel 中執行的 SQL 查詢的方法。您可以選擇適合您專案和需求的方法來進行調試和監控資料庫查詢。&lt;/p&gt;

&lt;p&gt;希望這篇文章對您有所幫助！如果您有任何問題或建議，請隨時留言告訴我們。&lt;/p&gt;

</description>
    </item>
    <item>
      <title>WordPress 查看 SQL 的方法</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Fri, 15 Sep 2023 09:45:15 +0000</pubDate>
      <link>https://dev.to/huangcong12/wordpress-cha-kan-sql-de-fang-fa-fil</link>
      <guid>https://dev.to/huangcong12/wordpress-cha-kan-sql-de-fang-fa-fil</guid>
      <description>&lt;p&gt;经過多年的WordPress開發經驗，我們的編輯為您整理了三種查看WordPress執行SQL查詢的方法，希望其中一種適合您的需求。&lt;/p&gt;

&lt;h2&gt;
  
  
  方法一：使用WordPress插件
&lt;/h2&gt;

&lt;p&gt;最簡單的方法是直接安裝WordPress插件，例如：&lt;strong&gt;Query Monitor&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OUt5VBHI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/banner-1544x500.png%3Frev%3D2870124" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OUt5VBHI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/banner-1544x500.png%3Frev%3D2870124" alt="Query Monitor" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DLBfWPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/screenshot-4.png%3Frev%3D1856844" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DLBfWPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/screenshot-4.png%3Frev%3D1856844" alt="Query Monitor範例" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;編輯評論：&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Query Monitor類似於ThinkPHP和Laravel內置的調試工具，對於偶爾查看SQL查詢來說還不錯。但是，在WordPress頁面包含數十甚至數百行SQL查詢的情況下，使用該工具可能會顯得不夠負責任。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;缺點：&lt;/strong&gt; 當開發API或代碼出現錯誤時，Query Monitor將無法顯示相關信息。它雖然可用，但並不是理想的選擇，有點像那種不可靠的人，總是在平時出現，但在關鍵時刻消失不見。而且它的菜單深藏不露，需要多次點擊才能找到。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;推薦評級：&lt;/strong&gt; 1顆星（滿分5顆星）&lt;/p&gt;

&lt;h2&gt;
  
  
  方法二：在WordPress代碼中添加記錄並打印SQL查詢
&lt;/h2&gt;

&lt;p&gt;通過編輯WordPress根目錄下的&lt;code&gt;wp-config.php&lt;/code&gt;文件，您可以啟用SQL查詢記錄。&lt;/p&gt;

&lt;p&gt;在文件中添加以下代碼：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SAVEQUERIES'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;然後在需要查看SQL查詢的地方添加以下代碼：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="nv"&gt;$wpdb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$wpdb&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;這將啟用WordPress記錄執行的每個SQL查詢，包括它們的執行時間，並將日誌保存在名為&lt;code&gt;queries&lt;/code&gt;的全局數組中。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;編輯評論：&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;想象一下，每次需要查看SQL查詢時，都要找到適當的位置添加代碼，查看完畢後再刪除代碼。如果問題仍未解決，您需要再次返回並把剛剛刪除的代碼補回來。這種循環會讓您感到非常疲憊。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;缺點：&lt;/strong&gt; 需要修改代碼，每天都要重複多次，即使將這幾行代碼定義為宏以避免手動輸入，精神上仍然非常耗費精力。疲勞可能導致將錯誤的代碼提交到線上環境的風險。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;推薦評級：&lt;/strong&gt; 2顆星（滿分5顆星）&lt;/p&gt;

&lt;h2&gt;
  
  
  方法三：使用外部工具
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. 啟用MySQL的查詢日誌記錄功能
&lt;/h3&gt;

&lt;p&gt;只需在MySQL的my.cnf文件中添加以下代碼，即可讓MySQL記錄所有執行的SQL查詢：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 記錄SQL
general_log = 1
general_log_file = /var/log/mysql/general_sql.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;編輯評論：&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;要使用這種方法，您需要具備對MySQL服務器的權限。如果多人共享一台MySQL開發服務器，最好不要啟用此功能，因為會引起混亂。此外，由於日誌包含大量信息，很難確定哪些查詢是您的，因此建議在測試服務器上使用，只在需要解決重要問題時才啟用。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;缺點：&lt;/strong&gt; 需要登錄到MySQL服務器才能查看日誌，如果MySQL出現問題，可能會受到懷疑。此外，由於記錄了所有SQL查詢，導致查詢量巨大，很難找到與您相關的查詢。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;推薦評級：&lt;/strong&gt; 3顆星（滿分5顆星）&lt;/p&gt;

&lt;h3&gt;
  
  
  2. 使用PHPStorm插件
&lt;/h3&gt;

&lt;p&gt;PHPStorm的插件市場提供了一個名為MySQL Proxy的插件，將代碼中的數據庫配置更改為它代理的端口，就能將所有的SQL日誌展示出來。是編輯目前用的唯一方便的工具，不用改代碼，不需要MySQL數據庫服務器權限，並且檢索方便。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8yG-xF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://upload-images.jianshu.io/upload_images/29317863-e38fd69faeab998d.png%3FimageMogr2/auto-orient/strip%257CimageView2/2/w/1240" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8yG-xF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://upload-images.jianshu.io/upload_images/29317863-e38fd69faeab998d.png%3FimageMogr2/auto-orient/strip%257CimageView2/2/w/1240" alt="PHPStorm MySQL Proxy插件" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;編輯評論：&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;這個工具類似於MyCAT，它可以代理並記錄SQL語句。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;缺點：&lt;/strong&gt; 尽管支持搜索功能，但不支持正则表达式搜索，只支持文本搜索。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;推薦評級：&lt;/strong&gt; 4顆星（滿分5顆星）&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Methods for Viewing SQL in WordPress</title>
      <dc:creator>dirty_pig</dc:creator>
      <pubDate>Fri, 15 Sep 2023 07:42:18 +0000</pubDate>
      <link>https://dev.to/huangcong12/methods-for-viewing-sql-in-wordpress-5d6p</link>
      <guid>https://dev.to/huangcong12/methods-for-viewing-sql-in-wordpress-5d6p</guid>
      <description>&lt;p&gt;After years of experience in WordPress development, our editor has compiled three methods for viewing SQL queries executed in WordPress. We hope one of them suits your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method One: Using WordPress Plugins
&lt;/h2&gt;

&lt;p&gt;The easiest method is to directly install a WordPress plugin, such as &lt;strong&gt;Query Monitor&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OUt5VBHI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/banner-1544x500.png%3Frev%3D2870124" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OUt5VBHI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/banner-1544x500.png%3Frev%3D2870124" alt="Query Monitor" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DLBfWPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/screenshot-4.png%3Frev%3D1856844" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DLBfWPE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://ps.w.org/query-monitor/assets/screenshot-4.png%3Frev%3D1856844" alt="Query Monitor Example" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Editor's Review:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Query Monitor is similar to the debugging tools built into ThinkPHP and Laravel, making it a decent choice for occasional SQL query viewing. However, when dealing with pages in WordPress that contain dozens or even hundreds of SQL queries, using this tool may seem less responsible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; When developing APIs or encountering code errors, Query Monitor may not display relevant information. While it is functional, it is not an ideal choice and can be compared to someone unreliable, always around during routine times but disappearing when needed most. Moreover, its menu is not very user-friendly and requires multiple clicks to access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended Rating:&lt;/strong&gt; 1 star (out of 5)&lt;/p&gt;

&lt;h2&gt;
  
  
  Method Two: Logging and Printing SQL Queries in WordPress Code
&lt;/h2&gt;

&lt;p&gt;You can enable SQL query logging by editing the &lt;code&gt;wp-config.php&lt;/code&gt; file located in the WordPress root directory.&lt;/p&gt;

&lt;p&gt;Add the following code to the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SAVEQUERIES'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in the place where you want to view SQL queries, add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="nv"&gt;$wpdb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;var_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$wpdb&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;queries&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will enable WordPress to log every executed SQL query, including their execution times, and store them in a global array named &lt;code&gt;queries&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Editor's Review:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine having to find the right place to add code every time you need to view SQL queries, then removing the code after checking, and potentially re-adding it if the problem remains unresolved. This repetitive process can be quite exhausting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; It requires code modification, which needs to be repeated daily. Even if you define these few lines of code as macros to avoid manual input, it can still be mentally draining. Fatigue may lead to the risk of accidentally submitting erroneous code to the production environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended Rating:&lt;/strong&gt; 2 stars (out of 5)&lt;/p&gt;

&lt;h2&gt;
  
  
  Method Three: Using External Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Enabling MySQL Query Logging
&lt;/h3&gt;

&lt;p&gt;You can make MySQL record all executed SQL queries by simply adding the following code to the my.cnf file in MySQL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Log SQL queries
general_log = 1
general_log_file = /var/log/mysql/general_sql.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0kxv8n89f0zp6jlmkqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0kxv8n89f0zp6jlmkqx.png" alt="sql view" width="800" height="412"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Editor's Review:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To use this method, you need permissions on the MySQL server. If multiple people share a MySQL development server, it's best not to enable this feature as it can cause confusion. Additionally, due to the extensive information in the logs, it's challenging to identify which queries are yours. Therefore, it is recommended for use on a test server and only enabled when crucial issues need to be resolved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; You need to log in to the MySQL server to view the logs. If MySQL encounters issues, it may raise suspicion. Moreover, since it logs all SQL queries, finding the queries relevant to you can be challenging due to the massive volume of logged queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended Rating:&lt;/strong&gt; 3 stars (out of 5)&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Using the PHPStorm Plugin
&lt;/h3&gt;

&lt;p&gt;PHPStorm's plugin marketplace offers a plugin called MySQL Proxy, which, when configured to proxy the database in your code, displays all SQL logs. It is the only convenient tool our editor currently uses, as it doesn't require code changes, doesn't need MySQL database server permissions, and offers easy retrieval.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8yG-xF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://upload-images.jianshu.io/upload_images/29317863-e38fd69faeab998d.png%3FimageMogr2/auto-orient/strip%257CimageView2/2/w/1240" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8yG-xF-X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://upload-images.jianshu.io/upload_images/29317863-e38fd69faeab998d.png%3FimageMogr2/auto-orient/strip%257CimageView2/2/w/1240" alt="PHPStorm MySQL Proxy Plugin" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Editor's Review:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This tool is similar to MyCAT as it can proxy and log SQL statements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drawback:&lt;/strong&gt; While it supports searching, it lacks support for regular expression search and only supports text search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended Rating:&lt;/strong&gt; 4 stars (out of 5)&lt;/p&gt;

&lt;p&gt;These are several methods to view executed SQL queries in WordPress. Which method do you prefer, or do you have a better alternative? Please share your thoughts in the comments so our editor can provide more information accordingly.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
