Home > Database > Mysql Tutorial > How to store json data in php to mysql?

How to store json data in php to mysql?

little bottle
Release: 2020-09-15 13:09:42
Original
8119 people have browsed it

I saw some netizens saying that using PHP is a suitable solution to save Qujiang json data into mysql. I would like to ask how to save json format data into mysql.

How to store json data in php to mysql?

If you want to store json data in PHP into a mysql database, you must first use PHP to serialize and filter it, and then store it in the database

The specific code is as follows:

$data = json_encode($array);// 过滤
$data = addslashes($data);// 入库
$db->insert(
$table_name,array(    
'field' => $data,
));
Copy after login

The above is the detailed content of How to store json data in php to mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template