Automattic\WooCommerce\Internal\Utilities

DatabaseUtil::parse_dbdelta_output()publicWC 1.0

Parses the output given by dbdelta and returns information about it.

Method of the class: DatabaseUtil{}

No Hooks.

Return

Array[]. An array containing a 'created_tables' key whose value is an array with the names of the tables that have been (or would have been) created.

Usage

$DatabaseUtil = new DatabaseUtil();
$DatabaseUtil->parse_dbdelta_output( $dbdelta_output ): array;
$dbdelta_output(array) (required)
The output from the execution of dbdelta.

DatabaseUtil::parse_dbdelta_output() code WC 8.7.0

public function parse_dbdelta_output( array $dbdelta_output ): array {
	$created_tables = array();

	foreach ( $dbdelta_output as $table_name => $result ) {
		if ( "Created table $table_name" === $result ) {
			$created_tables[] = str_replace( '(', '', $table_name );
		}
	}

	return array( 'created_tables' => $created_tables );
}