Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Abstract_Database::update( $row_id, array $data = array(), string $where = '' )
Update a row
Description Description
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Parameters Parameters
- $row_id
-
(Required)
- $data
-
(Optional)
Default value: array()
- $where
-
(Optional)
Default value: ''
Return Return
(bool)
Source Source
File: classes/Abstract/Database.php
public function update( $row_id, $data = array(), $where = '' ) { global $wpdb; // Row ID must be positive integer $row_id = absint( $row_id ); if ( empty( $row_id ) ) { return false; } if ( empty( $where ) ) { $where = $this->primary_key; } // Initialise column format array $column_formats = $this->get_columns(); // Force fields to lower case $data = array_change_key_case( $data ); // White list columns $data = array_intersect_key( $data, $column_formats ); foreach ( $data as $key => $value ) { if ( is_array( $value ) ) { $data[ $key ] = maybe_serialize( $value ); } } // Reorder $column_formats to match the order of columns given in $data $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); if ( false === $wpdb->update( $this->table_name(), $data, array( $where => $row_id ), $column_formats ) ) { return false; } return true; }
Expand full source code Collapse full source code View on Trac