public/wordpress/wp-content/plugins/backupbuddy/destinations/live/live_continuous.php
/* _render_insert()
	 *
	 * Takes the stored table, column update data, and creates an SQL insert statement.
	 *
	 */
_render_insert()
Takes the stored table, column update data, and creates an SQL insert statement.
_render_insert () Takes the stored table column update data and creates an SQL insert statement .
private static function _render_insert( $table_no_prefix, $column, $value ) {
		global $wpdb;
		$table = $wpdb->prefix . $table_no_prefix;
		$query = "SELECT * FROM `$table` WHERE $column = %s";
		$table_query = $wpdb->get_results( $wpdb->prepare( $query, array( $value ) ), ARRAY_N );
		if ( $table_query === false ) {
			pb_backupbuddy::status( 'error', 'ERROR #237273. Unable to retrieve data from table `' . $table . '`. This table may be corrupt (try repairing the database) or too large to hold in memory (increase mysql and/or PHP memory). Check your PHP error log for further errors which may provide further information. Not continuing database dump to insure backup integrity.' );
			return false;
		}
		$tableCount = count( $table_query );
		$insert_sql = $wpdb->prepare( "DELETE FROM `$table` WHERE $column = %s", array( $value ) ) . ";\n"; 
		$columns = $wpdb->get_col_info();
		$num_fields = count( $columns );
		foreach( $table_query as $fetch_row ) {
			$insert_sql .= "INSERT INTO `$table` VALUES(";
			for ( $n=1; $n<=$num_fields; $n++ ) {
				$m = $n - 1;
				if ( $fetch_row[$m] === NULL ) {
					$insert_sql .= "NULL, ";
				} else {
					$insert_sql .= "'" . backupbuddy_core::dbEscape( $fetch_row[$m] ) . "', ";
				}
			}
			$insert_sql = substr( $insert_sql, 0, -2 );
			$insert_sql .= ");\n";
		} 
		return $insert_sql;
	}
private static function _render_insert ( $ table_no_prefix , $ column , $ value ) { global $ wpdb ; $ table = $ wpdb -> prefix . $ table_no_prefix ; $ query = " SELECT * FROM ` $ table ` WHERE  $ column  = %s " ; $ table_query = $ wpdb -> get_results ( $ wpdb -> prepare ( $ query , array ( $ value ) ) , ARRAY_N ) ; if ( $ table_query === false ) { pb_backupbuddy :: status ( 'error' , 'ERROR #237273. Unable to retrieve data from table `' . $ table . '`. This table may be corrupt (try repairing the database) or too large to hold in memory (increase mysql and/or PHP memory). Check your PHP error log for further errors which may provide further information. Not continuing database dump to insure backup integrity.' ) ; return false ; } $ tableCount = count ( $ table_query ) ; $ insert_sql = $ wpdb -> prepare ( " DELETE FROM ` $ table ` WHERE  $ column  = %s " , array ( $ value ) ) . " ; \n " ; $ columns = $ wpdb -> get_col_info ( ) ; $ num_fields = count ( $ columns ) ; foreach ( $ table_query as $ fetch_row ) { $ insert_sql .= " INSERT INTO ` $ table ` VALUES( " ; for ( $ n = 1 ; $ n <= $ num_fields ; $ n ++ ) { $ m = $ n - 1 ; if ( $ fetch_row [ $ m ] === NULL ) { $ insert_sql .= " NULL,  " ; } else { $ insert_sql .= " ' " . backupbuddy_core :: dbEscape ( $ fetch_row [ $ m ] ) . " ',  " ; } } $ insert_sql = substr ( $ insert_sql , 0 , - 2 ) ; $ insert_sql .= " ); \n " ; } return $ insert_sql ; }
_render_insert()
 Takes the stored table, column update data, and creates an SQL insert statement.
_render_insert () Takes the stored table column update data and creates an SQL insert statement .
//error_log( 'Render insert. Table: `' . $table_no_prefix . '`, Column: `' . $column . '`, Value: `' . $value . '`.' ); //pb_backupbuddy::status( 'details', 'Got `' . $tableCount . '` rows from `' . $table . '`.' ); // Initially delete everything that matches this query to get ready for insert. // end foreach table row.