gcdb::strip_invalid_text_for_column()

最后更新于:2021-11-26 09:05:16

gcdb::strip_invalid_text_for_column( string$table, string$column, string$value)

Strips any invalid characters from the string for a given table and column.

参数

$table

(string) (Required) Table name.

$column

(string) (Required) Column name.

$value

(string) (Required) The text to check.

响应

(string|GC_Error) The converted string, or a GC_Error object if the conversion fails.

源文件

文件: gc-includes/gc-db.php

	public function strip_invalid_text_for_column( $table, $column, $value ) {
		if ( ! is_string( $value ) ) {
			return $value;
		}

		$charset = $this->get_col_charset( $table, $column );
		if ( ! $charset ) {
			// Not a string column.
			return $value;
		} elseif ( is_gc_error( $charset ) ) {
			// Bail on real errors.
			return $charset;
		}

		$data = array(
			$column => array(
				'value'   => $value,
				'charset' => $charset,
				'length'  => $this->get_col_length( $table, $column ),
			),
		);

		$data = $this->strip_invalid_text( $data );
		if ( is_gc_error( $data ) ) {
			return $data;
		}

		return $data[ $column ]['value'];
	}