public function update() { global $wpdb; $query_string = "UPDATE " . $this->table_name; $query_string .= " SET "; $properties = EZP_CS_Utility::get_public_properties($this); foreach ($properties as $prop_name => $prop_value) { $type_format = EZP_CS_Utility::get_db_type_format($prop_value); $query_string .= "{$prop_name} = {$type_format},"; } if (count($properties) > 0) { $query_string = substr($query_string, 0, -1); } $query_string .= " WHERE id = " . $this->id; $prepared_query = $wpdb->prepare($query_string, $properties); $wpdb->query($prepared_query); $this->dirty = false; return true; }
public function update() { global $wpdb; $query_string = "UPDATE " . $this->table_name; $query_string .= " SET type = %s, data = %s WHERE id = %d;"; $data = EZP_CS_Utility::get_public_properties($this); $serialized_data = json_encode($data); if (strlen($serialized_data) < 65536) { $prepared_query = $wpdb->prepare($query_string, $this->type, $serialized_data, $this->id); $wpdb->query($prepared_query); $this->dirty = false; return true; } else { EZP_CS_Utility::debug("Entity trying to be updated exceeds max size of 65K!"); return false; } }