Skip to content

Instantly share code, notes, and snippets.

@PointerSoftware
PointerSoftware / php-find-replace-string-cli.php
Created July 5, 2024 16:31 — forked from rxnlabs/php-find-replace-string-cli.php
PHP - find and replace string from MySQL database. Look in all tables and replace text, even in serialized strings. Best to use from the PHP CLI (Command Line Interface) when working with large databases.
<?php
ini_set('memory_limit','3200M');
// This script is to solve the problem of doing database search and replace
// when developers have only gone and used the non-relational concept of
// serializing PHP arrays into single database columns. It will search for all
// matching data on the database and change it, even if it's within a serialized
// PHP array.
// The big problem with serialised arrays is that if you do a normal DB
// style search and replace the lengths get mucked up. This search deals with