MySQL Snippet: List Tables and Count of Rows

In order to produce a list of all tables and the count of rows per table in MySQL there are two methods available:

Cached Estimate

As reported by other users and MySQL documentation, in this method, a cached estimate of number of rows will be returned which might not be an accurate representation of the data. However, this method is said to be less computationally heavy. The following snippet uses this method; just replace *Database_Name* with the name of your database:

WHERE TABLE_SCHEMA = `*Database_Name*`;

The Manual Way

Another solution proposed by a StackOverflow user, Nathan, is listed below. This method outputs a SELECT statement with the table name and row count for each table in your database. Each SELECT statement is returned on a row and ends with a UNION keyword. You could use this output by removing the UNION keyword from the last output row, and executing the resulting MySQL script to get a list of tables and number of rows per table. This method is more computationally intensive but returns a more accurate output. Here is the snippet; again, do not forget to replace *Database_Name* with the name of your database:

    'SELECT "', 
    '" AS table_name, COUNT(*) AS exact_row_count FROM `', 
    '` UNION '
WHERE table_schema = '*Database_Name*';

Based on: StackOverflow

PHP Snippet: WordPress/ACF Save Post Hook – Save Title

In order to have ACF save the concatenation of the author custom post type’s first name and last name as title, use the following.

add_action('acf/save_post', 'my_acf_save_post');

function my_acf_save_post($post_id)

	if ($_POST['post_type'] != 'cpt-author')

	$Post_Title = '';

	$Fields = get_fields($post_id);

	$FirstName = $Fields['ACF-Author-FirstName'];

	if (isset($FirstName)) {
		$Post_Title = $FirstName . ' ';

	$LastName = $Fields['ACF-Author-LastName'];

	if (isset($LastName)) {
		$Post_Title = $Post_Title . $LastName . ' ';

	$post_update = array(
		'ID'         => $post_id,
		'post_title' => $Post_Title


Based on: ACF | acf/save_post

Path: This Environment Variable is Too Large

When there are too many entries defined in Windows Path environment variable, you might be faced with this error using the UI when adding a new entry. One solution without having to remove any existing entries is to use the PowerShell snippet below.

For example, to add “C:\Program Files\Java\jdk-14.0.2\bin” to Path :

  • Open up Powershell in Administrator mode
  • Enter the following:
$newPath = $env:Path + ';
C:\Program Files\Java\jdk-14.0.2\bin;'
[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine")
$env:Path = $newPath

Source: Code Examples