Is there a way I could retrieve data from a mysql db table and save them in a binary file?
My table looks like this
id domain_name isAuth
1 www.yah.com 1
2 www.go.com 0
3 www.goo.com 1
4 www.foo.com 1
Since performance seems to be the issue here, assuming $data
is the result of a call to PDOStatement::fetchAll
or mysqli_fetch_all
, I suggest serialize
and unserialize
:
/* fetch $data */
file_put_contents('my_file.dat', serialize($data));
/* do some other stuff */
$data = unserialize(file_get_contents('my_file.dat'));
/* use $data */
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.