Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: class-wpdb.php
$message = '<h1>' . __( 'Error establishing a database connection' ) . "</h1>\n";
[2000] Fix | Delete
[2001] Fix | Delete
$message .= '<p>' . sprintf(
[2002] Fix | Delete
/* translators: 1: wp-config.php, 2: Database host. */
[2003] Fix | Delete
__( 'This either means that the username and password information in your %1$s file is incorrect or that contact with the database server at %2$s could not be established. This could mean your host&#8217;s database server is down.' ),
[2004] Fix | Delete
'<code>wp-config.php</code>',
[2005] Fix | Delete
'<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
[2006] Fix | Delete
) . "</p>\n";
[2007] Fix | Delete
[2008] Fix | Delete
$message .= "<ul>\n";
[2009] Fix | Delete
$message .= '<li>' . __( 'Are you sure you have the correct username and password?' ) . "</li>\n";
[2010] Fix | Delete
$message .= '<li>' . __( 'Are you sure you have typed the correct hostname?' ) . "</li>\n";
[2011] Fix | Delete
$message .= '<li>' . __( 'Are you sure the database server is running?' ) . "</li>\n";
[2012] Fix | Delete
$message .= "</ul>\n";
[2013] Fix | Delete
[2014] Fix | Delete
$message .= '<p>' . sprintf(
[2015] Fix | Delete
/* translators: %s: Support forums URL. */
[2016] Fix | Delete
__( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress support forums</a>.' ),
[2017] Fix | Delete
__( 'https://wordpress.org/support/forums/' )
[2018] Fix | Delete
) . "</p>\n";
[2019] Fix | Delete
[2020] Fix | Delete
$this->bail( $message, 'db_connect_fail' );
[2021] Fix | Delete
[2022] Fix | Delete
return false;
[2023] Fix | Delete
} elseif ( $this->dbh ) {
[2024] Fix | Delete
if ( ! $this->has_connected ) {
[2025] Fix | Delete
$this->init_charset();
[2026] Fix | Delete
}
[2027] Fix | Delete
[2028] Fix | Delete
$this->has_connected = true;
[2029] Fix | Delete
[2030] Fix | Delete
$this->set_charset( $this->dbh );
[2031] Fix | Delete
[2032] Fix | Delete
$this->ready = true;
[2033] Fix | Delete
$this->set_sql_mode();
[2034] Fix | Delete
$this->select( $this->dbname, $this->dbh );
[2035] Fix | Delete
[2036] Fix | Delete
return true;
[2037] Fix | Delete
}
[2038] Fix | Delete
[2039] Fix | Delete
return false;
[2040] Fix | Delete
}
[2041] Fix | Delete
[2042] Fix | Delete
/**
[2043] Fix | Delete
* Parses the DB_HOST setting to interpret it for mysqli_real_connect().
[2044] Fix | Delete
*
[2045] Fix | Delete
* mysqli_real_connect() doesn't support the host param including a port or socket
[2046] Fix | Delete
* like mysql_connect() does. This duplicates how mysql_connect() detects a port
[2047] Fix | Delete
* and/or socket file.
[2048] Fix | Delete
*
[2049] Fix | Delete
* @since 4.9.0
[2050] Fix | Delete
*
[2051] Fix | Delete
* @param string $host The DB_HOST setting to parse.
[2052] Fix | Delete
* @return array|false {
[2053] Fix | Delete
* Array containing the host, the port, the socket and
[2054] Fix | Delete
* whether it is an IPv6 address, in that order.
[2055] Fix | Delete
* False if the host couldn't be parsed.
[2056] Fix | Delete
*
[2057] Fix | Delete
* @type string $0 Host name.
[2058] Fix | Delete
* @type string|null $1 Port.
[2059] Fix | Delete
* @type string|null $2 Socket.
[2060] Fix | Delete
* @type bool $3 Whether it is an IPv6 address.
[2061] Fix | Delete
* }
[2062] Fix | Delete
*/
[2063] Fix | Delete
public function parse_db_host( $host ) {
[2064] Fix | Delete
$socket = null;
[2065] Fix | Delete
$is_ipv6 = false;
[2066] Fix | Delete
[2067] Fix | Delete
// First peel off the socket parameter from the right, if it exists.
[2068] Fix | Delete
$socket_pos = strpos( $host, ':/' );
[2069] Fix | Delete
if ( false !== $socket_pos ) {
[2070] Fix | Delete
$socket = substr( $host, $socket_pos + 1 );
[2071] Fix | Delete
$host = substr( $host, 0, $socket_pos );
[2072] Fix | Delete
}
[2073] Fix | Delete
[2074] Fix | Delete
/*
[2075] Fix | Delete
* We need to check for an IPv6 address first.
[2076] Fix | Delete
* An IPv6 address will always contain at least two colons.
[2077] Fix | Delete
*/
[2078] Fix | Delete
if ( substr_count( $host, ':' ) > 1 ) {
[2079] Fix | Delete
$pattern = '#^(?:\[)?(?P<host>[0-9a-fA-F:]+)(?:\]:(?P<port>[\d]+))?#';
[2080] Fix | Delete
$is_ipv6 = true;
[2081] Fix | Delete
} else {
[2082] Fix | Delete
// We seem to be dealing with an IPv4 address.
[2083] Fix | Delete
$pattern = '#^(?P<host>[^:/]*)(?::(?P<port>[\d]+))?#';
[2084] Fix | Delete
}
[2085] Fix | Delete
[2086] Fix | Delete
$matches = array();
[2087] Fix | Delete
$result = preg_match( $pattern, $host, $matches );
[2088] Fix | Delete
[2089] Fix | Delete
if ( 1 !== $result ) {
[2090] Fix | Delete
// Couldn't parse the address, bail.
[2091] Fix | Delete
return false;
[2092] Fix | Delete
}
[2093] Fix | Delete
[2094] Fix | Delete
$host = ! empty( $matches['host'] ) ? $matches['host'] : '';
[2095] Fix | Delete
// MySQLi port cannot be a string; must be null or an integer.
[2096] Fix | Delete
$port = ! empty( $matches['port'] ) ? absint( $matches['port'] ) : null;
[2097] Fix | Delete
[2098] Fix | Delete
return array( $host, $port, $socket, $is_ipv6 );
[2099] Fix | Delete
}
[2100] Fix | Delete
[2101] Fix | Delete
/**
[2102] Fix | Delete
* Checks that the connection to the database is still up. If not, try to reconnect.
[2103] Fix | Delete
*
[2104] Fix | Delete
* If this function is unable to reconnect, it will forcibly die, or if called
[2105] Fix | Delete
* after the {@see 'template_redirect'} hook has been fired, return false instead.
[2106] Fix | Delete
*
[2107] Fix | Delete
* If `$allow_bail` is false, the lack of database connection will need to be handled manually.
[2108] Fix | Delete
*
[2109] Fix | Delete
* @since 3.9.0
[2110] Fix | Delete
*
[2111] Fix | Delete
* @param bool $allow_bail Optional. Allows the function to bail. Default true.
[2112] Fix | Delete
* @return bool|void True if the connection is up.
[2113] Fix | Delete
*/
[2114] Fix | Delete
public function check_connection( $allow_bail = true ) {
[2115] Fix | Delete
if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
[2116] Fix | Delete
return true;
[2117] Fix | Delete
}
[2118] Fix | Delete
[2119] Fix | Delete
$error_reporting = false;
[2120] Fix | Delete
[2121] Fix | Delete
// Disable warnings, as we don't want to see a multitude of "unable to connect" messages.
[2122] Fix | Delete
if ( WP_DEBUG ) {
[2123] Fix | Delete
$error_reporting = error_reporting();
[2124] Fix | Delete
error_reporting( $error_reporting & ~E_WARNING );
[2125] Fix | Delete
}
[2126] Fix | Delete
[2127] Fix | Delete
for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) {
[2128] Fix | Delete
/*
[2129] Fix | Delete
* On the last try, re-enable warnings. We want to see a single instance
[2130] Fix | Delete
* of the "unable to connect" message on the bail() screen, if it appears.
[2131] Fix | Delete
*/
[2132] Fix | Delete
if ( $this->reconnect_retries === $tries && WP_DEBUG ) {
[2133] Fix | Delete
error_reporting( $error_reporting );
[2134] Fix | Delete
}
[2135] Fix | Delete
[2136] Fix | Delete
if ( $this->db_connect( false ) ) {
[2137] Fix | Delete
if ( $error_reporting ) {
[2138] Fix | Delete
error_reporting( $error_reporting );
[2139] Fix | Delete
}
[2140] Fix | Delete
[2141] Fix | Delete
return true;
[2142] Fix | Delete
}
[2143] Fix | Delete
[2144] Fix | Delete
sleep( 1 );
[2145] Fix | Delete
}
[2146] Fix | Delete
[2147] Fix | Delete
/*
[2148] Fix | Delete
* If template_redirect has already happened, it's too late for wp_die()/dead_db().
[2149] Fix | Delete
* Let's just return and hope for the best.
[2150] Fix | Delete
*/
[2151] Fix | Delete
if ( did_action( 'template_redirect' ) ) {
[2152] Fix | Delete
return false;
[2153] Fix | Delete
}
[2154] Fix | Delete
[2155] Fix | Delete
if ( ! $allow_bail ) {
[2156] Fix | Delete
return false;
[2157] Fix | Delete
}
[2158] Fix | Delete
[2159] Fix | Delete
wp_load_translations_early();
[2160] Fix | Delete
[2161] Fix | Delete
$message = '<h1>' . __( 'Error reconnecting to the database' ) . "</h1>\n";
[2162] Fix | Delete
[2163] Fix | Delete
$message .= '<p>' . sprintf(
[2164] Fix | Delete
/* translators: %s: Database host. */
[2165] Fix | Delete
__( 'This means that the contact with the database server at %s was lost. This could mean your host&#8217;s database server is down.' ),
[2166] Fix | Delete
'<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>'
[2167] Fix | Delete
) . "</p>\n";
[2168] Fix | Delete
[2169] Fix | Delete
$message .= "<ul>\n";
[2170] Fix | Delete
$message .= '<li>' . __( 'Are you sure the database server is running?' ) . "</li>\n";
[2171] Fix | Delete
$message .= '<li>' . __( 'Are you sure the database server is not under particularly heavy load?' ) . "</li>\n";
[2172] Fix | Delete
$message .= "</ul>\n";
[2173] Fix | Delete
[2174] Fix | Delete
$message .= '<p>' . sprintf(
[2175] Fix | Delete
/* translators: %s: Support forums URL. */
[2176] Fix | Delete
__( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress support forums</a>.' ),
[2177] Fix | Delete
__( 'https://wordpress.org/support/forums/' )
[2178] Fix | Delete
) . "</p>\n";
[2179] Fix | Delete
[2180] Fix | Delete
// We weren't able to reconnect, so we better bail.
[2181] Fix | Delete
$this->bail( $message, 'db_connect_fail' );
[2182] Fix | Delete
[2183] Fix | Delete
/*
[2184] Fix | Delete
* Call dead_db() if bail didn't die, because this database is no more.
[2185] Fix | Delete
* It has ceased to be (at least temporarily).
[2186] Fix | Delete
*/
[2187] Fix | Delete
dead_db();
[2188] Fix | Delete
}
[2189] Fix | Delete
[2190] Fix | Delete
/**
[2191] Fix | Delete
* Performs a database query, using current database connection.
[2192] Fix | Delete
*
[2193] Fix | Delete
* More information can be found on the documentation page.
[2194] Fix | Delete
*
[2195] Fix | Delete
* @since 0.71
[2196] Fix | Delete
*
[2197] Fix | Delete
* @link https://developer.wordpress.org/reference/classes/wpdb/
[2198] Fix | Delete
*
[2199] Fix | Delete
* @param string $query Database query.
[2200] Fix | Delete
* @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows
[2201] Fix | Delete
* affected/selected for all other queries. Boolean false on error.
[2202] Fix | Delete
*/
[2203] Fix | Delete
public function query( $query ) {
[2204] Fix | Delete
if ( ! $this->ready ) {
[2205] Fix | Delete
$this->check_current_query = true;
[2206] Fix | Delete
return false;
[2207] Fix | Delete
}
[2208] Fix | Delete
[2209] Fix | Delete
/**
[2210] Fix | Delete
* Filters the database query.
[2211] Fix | Delete
*
[2212] Fix | Delete
* Some queries are made before the plugins have been loaded,
[2213] Fix | Delete
* and thus cannot be filtered with this method.
[2214] Fix | Delete
*
[2215] Fix | Delete
* @since 2.1.0
[2216] Fix | Delete
*
[2217] Fix | Delete
* @param string $query Database query.
[2218] Fix | Delete
*/
[2219] Fix | Delete
$query = apply_filters( 'query', $query );
[2220] Fix | Delete
[2221] Fix | Delete
if ( ! $query ) {
[2222] Fix | Delete
$this->insert_id = 0;
[2223] Fix | Delete
return false;
[2224] Fix | Delete
}
[2225] Fix | Delete
[2226] Fix | Delete
$this->flush();
[2227] Fix | Delete
[2228] Fix | Delete
// Log how the function was called.
[2229] Fix | Delete
$this->func_call = "\$db->query(\"$query\")";
[2230] Fix | Delete
[2231] Fix | Delete
// If we're writing to the database, make sure the query will write safely.
[2232] Fix | Delete
if ( $this->check_current_query && ! $this->check_ascii( $query ) ) {
[2233] Fix | Delete
$stripped_query = $this->strip_invalid_text_from_query( $query );
[2234] Fix | Delete
/*
[2235] Fix | Delete
* strip_invalid_text_from_query() can perform queries, so we need
[2236] Fix | Delete
* to flush again, just to make sure everything is clear.
[2237] Fix | Delete
*/
[2238] Fix | Delete
$this->flush();
[2239] Fix | Delete
if ( $stripped_query !== $query ) {
[2240] Fix | Delete
$this->insert_id = 0;
[2241] Fix | Delete
$this->last_query = $query;
[2242] Fix | Delete
[2243] Fix | Delete
wp_load_translations_early();
[2244] Fix | Delete
[2245] Fix | Delete
$this->last_error = __( 'WordPress database error: Could not perform query because it contains invalid data.' );
[2246] Fix | Delete
[2247] Fix | Delete
return false;
[2248] Fix | Delete
}
[2249] Fix | Delete
}
[2250] Fix | Delete
[2251] Fix | Delete
$this->check_current_query = true;
[2252] Fix | Delete
[2253] Fix | Delete
// Keep track of the last query for debug.
[2254] Fix | Delete
$this->last_query = $query;
[2255] Fix | Delete
[2256] Fix | Delete
$this->_do_query( $query );
[2257] Fix | Delete
[2258] Fix | Delete
// Database server has gone away, try to reconnect.
[2259] Fix | Delete
$mysql_errno = 0;
[2260] Fix | Delete
[2261] Fix | Delete
if ( $this->dbh instanceof mysqli ) {
[2262] Fix | Delete
$mysql_errno = mysqli_errno( $this->dbh );
[2263] Fix | Delete
} else {
[2264] Fix | Delete
/*
[2265] Fix | Delete
* $dbh is defined, but isn't a real connection.
[2266] Fix | Delete
* Something has gone horribly wrong, let's try a reconnect.
[2267] Fix | Delete
*/
[2268] Fix | Delete
$mysql_errno = 2006;
[2269] Fix | Delete
}
[2270] Fix | Delete
[2271] Fix | Delete
if ( empty( $this->dbh ) || 2006 === $mysql_errno ) {
[2272] Fix | Delete
if ( $this->check_connection() ) {
[2273] Fix | Delete
$this->_do_query( $query );
[2274] Fix | Delete
} else {
[2275] Fix | Delete
$this->insert_id = 0;
[2276] Fix | Delete
return false;
[2277] Fix | Delete
}
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
// If there is an error then take note of it.
[2281] Fix | Delete
if ( $this->dbh instanceof mysqli ) {
[2282] Fix | Delete
$this->last_error = mysqli_error( $this->dbh );
[2283] Fix | Delete
} else {
[2284] Fix | Delete
$this->last_error = __( 'Unable to retrieve the error message from MySQL' );
[2285] Fix | Delete
}
[2286] Fix | Delete
[2287] Fix | Delete
if ( $this->last_error ) {
[2288] Fix | Delete
// Clear insert_id on a subsequent failed insert.
[2289] Fix | Delete
if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
[2290] Fix | Delete
$this->insert_id = 0;
[2291] Fix | Delete
}
[2292] Fix | Delete
[2293] Fix | Delete
$this->print_error();
[2294] Fix | Delete
return false;
[2295] Fix | Delete
}
[2296] Fix | Delete
[2297] Fix | Delete
if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) {
[2298] Fix | Delete
$return_val = $this->result;
[2299] Fix | Delete
} elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) {
[2300] Fix | Delete
$this->rows_affected = mysqli_affected_rows( $this->dbh );
[2301] Fix | Delete
[2302] Fix | Delete
// Take note of the insert_id.
[2303] Fix | Delete
if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
[2304] Fix | Delete
$this->insert_id = mysqli_insert_id( $this->dbh );
[2305] Fix | Delete
}
[2306] Fix | Delete
[2307] Fix | Delete
// Return number of rows affected.
[2308] Fix | Delete
$return_val = $this->rows_affected;
[2309] Fix | Delete
} else {
[2310] Fix | Delete
$num_rows = 0;
[2311] Fix | Delete
[2312] Fix | Delete
if ( $this->result instanceof mysqli_result ) {
[2313] Fix | Delete
while ( $row = mysqli_fetch_object( $this->result ) ) {
[2314] Fix | Delete
$this->last_result[ $num_rows ] = $row;
[2315] Fix | Delete
++$num_rows;
[2316] Fix | Delete
}
[2317] Fix | Delete
}
[2318] Fix | Delete
[2319] Fix | Delete
// Log and return the number of rows selected.
[2320] Fix | Delete
$this->num_rows = $num_rows;
[2321] Fix | Delete
$return_val = $num_rows;
[2322] Fix | Delete
}
[2323] Fix | Delete
[2324] Fix | Delete
return $return_val;
[2325] Fix | Delete
}
[2326] Fix | Delete
[2327] Fix | Delete
/**
[2328] Fix | Delete
* Internal function to perform the mysqli_query() call.
[2329] Fix | Delete
*
[2330] Fix | Delete
* @since 3.9.0
[2331] Fix | Delete
*
[2332] Fix | Delete
* @see wpdb::query()
[2333] Fix | Delete
*
[2334] Fix | Delete
* @param string $query The query to run.
[2335] Fix | Delete
*/
[2336] Fix | Delete
private function _do_query( $query ) {
[2337] Fix | Delete
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
[2338] Fix | Delete
$this->timer_start();
[2339] Fix | Delete
}
[2340] Fix | Delete
[2341] Fix | Delete
if ( ! empty( $this->dbh ) ) {
[2342] Fix | Delete
$this->result = mysqli_query( $this->dbh, $query );
[2343] Fix | Delete
}
[2344] Fix | Delete
[2345] Fix | Delete
++$this->num_queries;
[2346] Fix | Delete
[2347] Fix | Delete
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
[2348] Fix | Delete
$this->log_query(
[2349] Fix | Delete
$query,
[2350] Fix | Delete
$this->timer_stop(),
[2351] Fix | Delete
$this->get_caller(),
[2352] Fix | Delete
$this->time_start,
[2353] Fix | Delete
array()
[2354] Fix | Delete
);
[2355] Fix | Delete
}
[2356] Fix | Delete
}
[2357] Fix | Delete
[2358] Fix | Delete
/**
[2359] Fix | Delete
* Logs query data.
[2360] Fix | Delete
*
[2361] Fix | Delete
* @since 5.3.0
[2362] Fix | Delete
*
[2363] Fix | Delete
* @param string $query The query's SQL.
[2364] Fix | Delete
* @param float $query_time Total time spent on the query, in seconds.
[2365] Fix | Delete
* @param string $query_callstack Comma-separated list of the calling functions.
[2366] Fix | Delete
* @param float $query_start Unix timestamp of the time at the start of the query.
[2367] Fix | Delete
* @param array $query_data Custom query data.
[2368] Fix | Delete
*/
[2369] Fix | Delete
public function log_query( $query, $query_time, $query_callstack, $query_start, $query_data ) {
[2370] Fix | Delete
/**
[2371] Fix | Delete
* Filters the custom data to log alongside a query.
[2372] Fix | Delete
*
[2373] Fix | Delete
* Caution should be used when modifying any of this data, it is recommended that any additional
[2374] Fix | Delete
* information you need to store about a query be added as a new associative array element.
[2375] Fix | Delete
*
[2376] Fix | Delete
* @since 5.3.0
[2377] Fix | Delete
*
[2378] Fix | Delete
* @param array $query_data Custom query data.
[2379] Fix | Delete
* @param string $query The query's SQL.
[2380] Fix | Delete
* @param float $query_time Total time spent on the query, in seconds.
[2381] Fix | Delete
* @param string $query_callstack Comma-separated list of the calling functions.
[2382] Fix | Delete
* @param float $query_start Unix timestamp of the time at the start of the query.
[2383] Fix | Delete
*/
[2384] Fix | Delete
$query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start );
[2385] Fix | Delete
[2386] Fix | Delete
$this->queries[] = array(
[2387] Fix | Delete
$query,
[2388] Fix | Delete
$query_time,
[2389] Fix | Delete
$query_callstack,
[2390] Fix | Delete
$query_start,
[2391] Fix | Delete
$query_data,
[2392] Fix | Delete
);
[2393] Fix | Delete
}
[2394] Fix | Delete
[2395] Fix | Delete
/**
[2396] Fix | Delete
* Generates and returns a placeholder escape string for use in queries returned by ::prepare().
[2397] Fix | Delete
*
[2398] Fix | Delete
* @since 4.8.3
[2399] Fix | Delete
*
[2400] Fix | Delete
* @return string String to escape placeholders.
[2401] Fix | Delete
*/
[2402] Fix | Delete
public function placeholder_escape() {
[2403] Fix | Delete
static $placeholder;
[2404] Fix | Delete
[2405] Fix | Delete
if ( ! $placeholder ) {
[2406] Fix | Delete
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
[2407] Fix | Delete
$algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
[2408] Fix | Delete
// Old WP installs may not have AUTH_SALT defined.
[2409] Fix | Delete
$salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand();
[2410] Fix | Delete
[2411] Fix | Delete
$placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}';
[2412] Fix | Delete
}
[2413] Fix | Delete
[2414] Fix | Delete
/*
[2415] Fix | Delete
* Add the filter to remove the placeholder escaper. Uses priority 0, so that anything
[2416] Fix | Delete
* else attached to this filter will receive the query with the placeholder string removed.
[2417] Fix | Delete
*/
[2418] Fix | Delete
if ( false === has_filter( 'query', array( $this, 'remove_placeholder_escape' ) ) ) {
[2419] Fix | Delete
add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 );
[2420] Fix | Delete
}
[2421] Fix | Delete
[2422] Fix | Delete
return $placeholder;
[2423] Fix | Delete
}
[2424] Fix | Delete
[2425] Fix | Delete
/**
[2426] Fix | Delete
* Adds a placeholder escape string, to escape anything that resembles a printf() placeholder.
[2427] Fix | Delete
*
[2428] Fix | Delete
* @since 4.8.3
[2429] Fix | Delete
*
[2430] Fix | Delete
* @param string $query The query to escape.
[2431] Fix | Delete
* @return string The query with the placeholder escape string inserted where necessary.
[2432] Fix | Delete
*/
[2433] Fix | Delete
public function add_placeholder_escape( $query ) {
[2434] Fix | Delete
/*
[2435] Fix | Delete
* To prevent returning anything that even vaguely resembles a placeholder,
[2436] Fix | Delete
* we clobber every % we can find.
[2437] Fix | Delete
*/
[2438] Fix | Delete
return str_replace( '%', $this->placeholder_escape(), $query );
[2439] Fix | Delete
}
[2440] Fix | Delete
[2441] Fix | Delete
/**
[2442] Fix | Delete
* Removes the placeholder escape strings from a query.
[2443] Fix | Delete
*
[2444] Fix | Delete
* @since 4.8.3
[2445] Fix | Delete
*
[2446] Fix | Delete
* @param string $query The query from which the placeholder will be removed.
[2447] Fix | Delete
* @return string The query with the placeholder removed.
[2448] Fix | Delete
*/
[2449] Fix | Delete
public function remove_placeholder_escape( $query ) {
[2450] Fix | Delete
return str_replace( $this->placeholder_escape(), '%', $query );
[2451] Fix | Delete
}
[2452] Fix | Delete
[2453] Fix | Delete
/**
[2454] Fix | Delete
* Inserts a row into the table.
[2455] Fix | Delete
*
[2456] Fix | Delete
* Examples:
[2457] Fix | Delete
*
[2458] Fix | Delete
* $wpdb->insert(
[2459] Fix | Delete
* 'table',
[2460] Fix | Delete
* array(
[2461] Fix | Delete
* 'column1' => 'foo',
[2462] Fix | Delete
* 'column2' => 'bar',
[2463] Fix | Delete
* )
[2464] Fix | Delete
* );
[2465] Fix | Delete
* $wpdb->insert(
[2466] Fix | Delete
* 'table',
[2467] Fix | Delete
* array(
[2468] Fix | Delete
* 'column1' => 'foo',
[2469] Fix | Delete
* 'column2' => 1337,
[2470] Fix | Delete
* ),
[2471] Fix | Delete
* array(
[2472] Fix | Delete
* '%s',
[2473] Fix | Delete
* '%d',
[2474] Fix | Delete
* )
[2475] Fix | Delete
* );
[2476] Fix | Delete
*
[2477] Fix | Delete
* @since 2.5.0
[2478] Fix | Delete
*
[2479] Fix | Delete
* @see wpdb::prepare()
[2480] Fix | Delete
* @see wpdb::$field_types
[2481] Fix | Delete
* @see wp_set_wpdb_vars()
[2482] Fix | Delete
*
[2483] Fix | Delete
* @param string $table Table name.
[2484] Fix | Delete
* @param array $data Data to insert (in column => value pairs).
[2485] Fix | Delete
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
[2486] Fix | Delete
* Sending a null value will cause the column to be set to NULL - the corresponding
[2487] Fix | Delete
* format is ignored in this case.
[2488] Fix | Delete
* @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
[2489] Fix | Delete
* If string, that format will be used for all of the values in `$data`.
[2490] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2491] Fix | Delete
* If omitted, all values in `$data` will be treated as strings unless otherwise
[2492] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2493] Fix | Delete
* @return int|false The number of rows inserted, or false on error.
[2494] Fix | Delete
*/
[2495] Fix | Delete
public function insert( $table, $data, $format = null ) {
[2496] Fix | Delete
return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' );
[2497] Fix | Delete
}
[2498] Fix | Delete
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function