Skip to content

Instantly share code, notes, and snippets.

View arvindsvt's full-sized avatar

Arvind Shrivastwa arvindsvt

  • Ahmedabad
View GitHub Profile
@arvindsvt
arvindsvt / wpsearchreplace.php
Created June 8, 2016 17:15 — forked from djaney/wpsearchreplace.php
Used when transferring WP sites. Replace database entries.
<?php
// Safe Search and Replace on Database with Serialized Data v1.0.1
// 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.
@arvindsvt
arvindsvt / wp-modifydb.php
Created June 8, 2016 17:16 — forked from jcanfield/wp-modifydb.php
Serialized PHP Search and Replace
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* 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.
@arvindsvt
arvindsvt / safesearchreplace.php
Created June 8, 2016 17:18 — forked from marke123/safesearchreplace.php
safe search and replace
<?php
// Safe Search and Replace on Database with Serialized Data v2.0.0
// 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.
@arvindsvt
arvindsvt / find-replace-sql-wp.sql
Created June 8, 2016 17:18 — forked from celsofabri/find-replace-sql-wp.sql
SQL Query para fazer um simples localizar e substituir / SQL Query to do a simple find and replace
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_url = replace(link_url, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_image = replace(link_image, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
/*UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';*/
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com');
@arvindsvt
arvindsvt / List.md
Created June 19, 2016 09:38 — forked from msurguy/List.md
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):

spl_autoload_register(function($class) {
$ns = explode('\\', strtolower($class));
$class = array_pop($ns);
$ns = implode('\\', $ns) . '\\';
require_once __DIR__ . '\\' . $ns . 'class.' . $class . '.php';
});
@arvindsvt
arvindsvt / array_flatten.php
Last active February 5, 2018 15:12 — forked from SeanCannon/array_flatten.php
PHP array_flatten() function. Convert a multi-dimensional array into a single-dimensional array.
<?php function array_flatten($array, $prefix = '') {
$result = array();
foreach($array as $key=>$value) {
if(is_array($value)) {
$result = $result + array_flatten($value, $prefix . $key . '.');
}
else {
$result[$prefix.$key] = $value;
}
}
@arvindsvt
arvindsvt / php-pdo-mysql-crud.md
Last active February 4, 2018 05:52 — forked from odan/php-pdo-mysql-crud.md
Basic CRUD operations with PDO and MySQL

Basic CRUD operations with PDO

CRUD = Create, Read, Update, Delete

Open a database connection

$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
/**
* A custom function that automatically constructs a multi insert statement.
*
* @param string $tableName Name of the table we are inserting into.
* @param array $data An "array of arrays" containing our row data.
* @param PDO $pdoObject Our PDO object.
* @return boolean TRUE on success. FALSE on failure.
*/
function pdoMultiInsert($tableName, $data, $pdoObject){
<?php
/*
* DB Class
* This class is used for database related (connect, insert, update, and delete) operations
* with PHP Data Objects (PDO)
*/
class DB{
private $dbHost = "localhost";