<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56476] trunk/src/wp-includes/class-wpdb.php: Database: Improve the documentation for various methods in the `wpdb` class.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56476">56476</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56476","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-08-26 18:09:07 +0000 (Sat, 26 Aug 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Database: Improve the documentation for various methods in the `wpdb` class.
See <a href="https://core.trac.wordpress.org/ticket/58833">#58833</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpdbphp">trunk/src/wp-includes/class-wpdb.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpdbphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wpdb.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wpdb.php 2023-08-26 13:01:05 UTC (rev 56475)
+++ trunk/src/wp-includes/class-wpdb.php 2023-08-26 18:09:07 UTC (rev 56476)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2447,8 +2447,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Examples:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 'bar' ) )
- * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $wpdb->insert(
+ * 'table',
+ * array(
+ * 'column1' => 'foo',
+ * 'column2' => 'bar',
+ * )
+ * );
+ * $wpdb->insert(
+ * 'table',
+ * array(
+ * 'column1' => 'foo',
+ * 'column2' => 1337,
+ * ),
+ * array(
+ * '%s',
+ * '%d',
+ * )
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2456,16 +2472,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wpdb::$field_types
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_set_wpdb_vars()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $data Data to insert (in column => value pairs).
- * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
- * Sending a null value will cause the column to be set to NULL - the corresponding
- * format is ignored in this case.
- * @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
- * If string, that format will be used for all of the values in `$data`.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in `$data` will be treated as strings unless otherwise
- * specified in wpdb::$field_types. Default null.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $data Data to insert (in column => value pairs).
+ * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
+ * Sending a null value will cause the column to be set to NULL - the corresponding
+ * format is ignored in this case.
+ * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
+ * If string, that format will be used for all of the values in `$data`.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in `$data` will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|false The number of rows inserted, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function insert( $table, $data, $format = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2473,12 +2489,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Replaces a row in the table.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Replaces a row in the table or inserts it if it does not exist, based on a PRIMARY KEY or a UNIQUE index.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * A REPLACE works exactly like an INSERT, except that if an old row in the table has the same value as a new row
+ * for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Examples:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 'bar' ) )
- * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $wpdb->replace(
+ * 'table',
+ * array(
+ * 'ID' => 123,
+ * 'column1' => 'foo',
+ * 'column2' => 'bar',
+ * )
+ * );
+ * $wpdb->replace(
+ * 'table',
+ * array(
+ * 'ID' => 456,
+ * 'column1' => 'foo',
+ * 'column2' => 1337,
+ * ),
+ * array(
+ * '%d',
+ * '%s',
+ * '%d',
+ * )
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2486,16 +2524,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wpdb::$field_types
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_set_wpdb_vars()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $data Data to insert (in column => value pairs).
- * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
- * Sending a null value will cause the column to be set to NULL - the corresponding
- * format is ignored in this case.
- * @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
- * If string, that format will be used for all of the values in `$data`.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in `$data` will be treated as strings unless otherwise
- * specified in wpdb::$field_types. Default null.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $data Data to insert (in column => value pairs).
+ * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
+ * A primary key or unique index is required to perform a replace operation.
+ * Sending a null value will cause the column to be set to NULL - the corresponding
+ * format is ignored in this case.
+ * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
+ * If string, that format will be used for all of the values in `$data`.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in `$data` will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|false The number of rows affected, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function replace( $table, $data, $format = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2513,18 +2552,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wpdb::$field_types
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_set_wpdb_vars()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $data Data to insert (in column => value pairs).
- * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
- * Sending a null value will cause the column to be set to NULL - the corresponding
- * format is ignored in this case.
- * @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
- * If string, that format will be used for all of the values in `$data`.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in `$data` will be treated as strings unless otherwise
- * specified in wpdb::$field_types. Default null.
- * @param string $type Optional. Type of operation. Either 'INSERT' or 'REPLACE'.
- * Default 'INSERT'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $data Data to insert (in column => value pairs).
+ * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
+ * Sending a null value will cause the column to be set to NULL - the corresponding
+ * format is ignored in this case.
+ * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
+ * If string, that format will be used for all of the values in `$data`.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in `$data` will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
+ * @param string $type Optional. Type of operation. Either 'INSERT' or 'REPLACE'.
+ * Default 'INSERT'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|false The number of rows affected, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2565,8 +2604,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Examples:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 'bar' ), array( 'ID' => 1 ) )
- * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $wpdb->update(
+ * 'table',
+ * array(
+ * 'column1' => 'foo',
+ * 'column2' => 'bar',
+ * ),
+ * array(
+ * 'ID' => 1,
+ * )
+ * );
+ * $wpdb->update(
+ * 'table',
+ * array(
+ * 'column1' => 'foo',
+ * 'column2' => 1337,
+ * ),
+ * array(
+ * 'ID' => 1,
+ * ),
+ * array(
+ * '%s',
+ * '%d',
+ * ),
+ * array(
+ * '%d',
+ * )
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2574,25 +2638,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wpdb::$field_types
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_set_wpdb_vars()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $data Data to update (in column => value pairs).
- * Both $data columns and $data values should be "raw" (neither should be SQL escaped).
- * Sending a null value will cause the column to be set to NULL - the corresponding
- * format is ignored in this case.
- * @param array $where A named array of WHERE clauses (in column => value pairs).
- * Multiple clauses will be joined with ANDs.
- * Both $where columns and $where values should be "raw".
- * Sending a null value will create an IS NULL comparison - the corresponding
- * format will be ignored in this case.
- * @param array|string $format Optional. An array of formats to be mapped to each of the values in $data.
- * If string, that format will be used for all of the values in $data.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in $data will be treated as strings unless otherwise
- * specified in wpdb::$field_types. Default null.
- * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
- * If string, that format will be used for all of the items in $where.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in $where will be treated as strings. Default null.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $data Data to update (in column => value pairs).
+ * Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+ * Sending a null value will cause the column to be set to NULL - the corresponding
+ * format is ignored in this case.
+ * @param array $where A named array of WHERE clauses (in column => value pairs).
+ * Multiple clauses will be joined with ANDs.
+ * Both $where columns and $where values should be "raw".
+ * Sending a null value will create an IS NULL comparison - the corresponding
+ * format will be ignored in this case.
+ * @param string[]|string $format Optional. An array of formats to be mapped to each of the values in $data.
+ * If string, that format will be used for all of the values in $data.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in $data will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
+ * @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
+ * If string, that format will be used for all of the items in $where.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in $where will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|false The number of rows updated, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function update( $table, $data, $where, $format = null, $where_format = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2645,8 +2710,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Examples:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * wpdb::delete( 'table', array( 'ID' => 1 ) )
- * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * $wpdb->delete(
+ * 'table',
+ * array(
+ * 'ID' => 1,
+ * )
+ * );
+ * $wpdb->delete(
+ * 'table',
+ * array(
+ * 'ID' => 1,
+ * ),
+ * array(
+ * '%d',
+ * )
+ * );
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2654,17 +2732,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wpdb::$field_types
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_set_wpdb_vars()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $where A named array of WHERE clauses (in column => value pairs).
- * Multiple clauses will be joined with ANDs.
- * Both $where columns and $where values should be "raw".
- * Sending a null value will create an IS NULL comparison - the corresponding
- * format will be ignored in this case.
- * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
- * If string, that format will be used for all of the items in $where.
- * A format is one of '%d', '%f', '%s' (integer, float, string).
- * If omitted, all values in $data will be treated as strings unless otherwise
- * specified in wpdb::$field_types. Default null.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $where A named array of WHERE clauses (in column => value pairs).
+ * Multiple clauses will be joined with ANDs.
+ * Both $where columns and $where values should be "raw".
+ * Sending a null value will create an IS NULL comparison - the corresponding
+ * format will be ignored in this case.
+ * @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
+ * If string, that format will be used for all of the items in $where.
+ * A format is one of '%d', '%f', '%s' (integer, float, string).
+ * If omitted, all values in $data will be treated as strings unless otherwise
+ * specified in wpdb::$field_types. Default null.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return int|false The number of rows deleted, or false on error.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $table, $where, $where_format = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2708,9 +2786,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $table Table name.
- * @param array $data Field/value pair.
- * @param mixed $format Format for each field.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $table Table name.
+ * @param array $data Array of values keyed by their field names.
+ * @param string[]|string $format Formats or format to be mapped to the values in the data.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return array|false An array of fields that contain paired value and formats.
</span><span class="cx" style="display: block; padding: 0 10px"> * False for invalid values.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2768,10 +2846,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $data Array of fields to values.
- * @param mixed $format Formats to be mapped to the values in $data.
- * @return array Array, keyed by field names with values being an array
- * of 'value' and 'format' keys.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $data Array of values keyed by their field names.
+ * @param string[]|string $format Formats or format to be mapped to the values in the data.
+ * @return array {
+ * Array of values and formats keyed by their field names.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function process_field_formats( $data, $format ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $formats = (array) $format;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2803,10 +2885,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $data As it comes from the wpdb::process_field_formats() method.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $data {
+ * Array of values and formats keyed by their field names,
+ * as it comes from the wpdb::process_field_formats() method.
+ *
+ * @type array ...$0 {
+ * Value and format for this field.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * }
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $table Table name.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array|false The same array as $data with additional 'charset' keys.
- * False on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false {
+ * The same array of data with additional 'charset' keys, or false if
+ * the charset for the table cannot be found.
+ *
+ * @type array ...$0 {
+ * Value, format, and charset for this field.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * @type string|false $charset The charset to be used for the value.
+ * }
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function process_field_charsets( $data, $table ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $data as $field => $value ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2834,10 +2936,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.1
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $data As it comes from the wpdb::process_field_charsets() method.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $data {
+ * Array of values, formats, and charsets keyed by their field names,
+ * as it comes from the wpdb::process_field_charsets() method.
+ *
+ * @type array ...$0 {
+ * Value, format, and charset for this field.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * @type string|false $charset The charset to be used for the value.
+ * }
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $table Table name.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array|false The same array as $data with additional 'length' keys, or false if
- * any of the values were too long for their corresponding field.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false {
+ * The same array of data with additional 'length' keys, or false if
+ * information for the table cannot be found.
+ *
+ * @type array ...$0 {
+ * Value, format, charset, and length for this field.
+ *
+ * @type mixed $value The value to be formatted.
+ * @type string $format The format to be mapped to the value.
+ * @type string|false $charset The charset to be used for the value.
+ * @type array|false $length {
+ * Information about the maximum length of the value.
+ * False if the column has no length.
+ *
+ * @type string $type One of 'byte' or 'char'.
+ * @type int $length The column length.
+ * }
+ * }
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function process_field_lengths( $data, $table ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $data as $field => $value ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2861,7 +2991,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves one variable from the database.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves one value from the database.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Executes a SQL query and returns the value from the SQL result.
</span><span class="cx" style="display: block; padding: 0 10px"> * If the SQL result contains more than one column and/or more than one row,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3169,9 +3299,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string|null $charset The character set to use. Default null.
- * @param string $table The name of the table being checked.
- * @param string $column The name of the column being checked.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|null|false|WP_Error $charset The character set to use. Default null.
+ * @param string $table The name of the table being checked.
+ * @param string $column The name of the column being checked.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $charset = apply_filters( 'pre_get_col_charset', null, $table, $column );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( null !== $charset ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3223,8 +3353,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Array of column length information, false if the column has no length (for
</span><span class="cx" style="display: block; padding: 0 10px"> * example, numeric column), WP_Error object if there was an error.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string $type One of 'byte' or 'char'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @type int $length The column length.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string $type One of 'byte' or 'char'.
</del><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_col_length( $table, $column ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3399,7 +3529,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $data Array of value arrays. Each value array has the keys 'value' and 'charset'.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $data Array of value arrays. Each value array has the keys 'value', 'charset', and 'length'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * An optional 'ascii' key can be set to false to avoid redundant ASCII checks.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|WP_Error The $data parameter, with invalid characters removed from each value.
</span><span class="cx" style="display: block; padding: 0 10px"> * This works as a passthrough: any additional keys such as 'field' are
</span></span></pre>
</div>
</div>
</body>
</html>