Skip to content

Instantly share code, notes, and snippets.

@necmettin
Created January 26, 2023 02:12
Show Gist options
  • Select an option

  • Save necmettin/7f523dcac8b67ca38f74f4640c2d1897 to your computer and use it in GitHub Desktop.

Select an option

Save necmettin/7f523dcac8b67ca38f74f4640c2d1897 to your computer and use it in GitHub Desktop.

Revisions

  1. necmettin created this gist Jan 26, 2023.
    27 changes: 27 additions & 0 deletions find-0000
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php

    function cmd_db_find_0000(): void
    {
    global $App;
    $key = "Tables_in_bulundum_com";
    $tables = field2array($App->RDB->run("SHOW TABLES"), $key);
    foreach ($tables as $tablename)
    {
    $fields = $App->RDB->run("SHOW COLUMNS FROM `$tablename`");
    foreach ($fields as $field)
    {
    if ($field['Type'] === 'datetime' || $field['Type'] === 'date')
    {
    $fieldname = $field['Field'];
    $qstr = "SELECT Id FROM `$tablename` WHERE $fieldname LIKE '0000%'";
    $rows = field2array($App->RDB->run($qstr));
    if ($rows)
    {
    pp("$tablename: $fieldname");
    pp($qstr);
    ppj($rows);
    }
    }
    }
    }
    }