Posts

Moving To And Away from Rackspace in the Same Year

I’ve been wanting to write this post for at least a year and I figured now would be a good time to take a break from my scheduled set of posts to discuss my transition both to and away from Rackspace last year.

Read More

Compressing MySQL Tables For Fun and Profit (or just Save Space)

Occasionally, you have a database table that holds a lot of text data and it’s not accessed regularly (log tables for example). InnoDB provides an easy way to compress your tables on disk so they use less space.

Read More

Lessons Learned From "PHP Objects, Patterns, and Practice"

As part of investing in myself I decided to read four different programming/management books in 2017. For the second quarter, I read PHP Objects, Patterns, and Practice by Matt Zandstra. This is my writeup for “proof”.

Read More

Count Distinct Values With A Condition

The other day I needed to find the total distinct count of a column as well as the distinct count of that column when a specific criteria had been met. In order to do this you can do the following:

select 
    count(distinct column) as full,
    count(distinct case when column2 = 1 then column end) as partial
from a;

This is mostly here so I’ll remember the next time I need this. :-)

Link Post and Podcast Roundup: August 2017 Edition

Link Post Logo

August’s links.

Read More

Beware of Joins on Derived Tables

MySQL is a powerful tool but it’s also a great way to shoot yourself in the foot. The other day we received reports of people finding a specific page slow but it was only slow when multiple people where using it.

Read More

Increasing Swap Space on a Running Ubuntu Server

You normally don’t want your servers using swap space because of the performance hit that occurs but for some operations you just can’t get around it. I’ve covered how to create a swap file before but what the swap you’ve created isn’t large enough?

Read More

Find Missing Columns in MySQL

With most of my projects I try not to delete data from my database. As part of this we have a “deleted” column in every table that keeps track of deleted data so it’s easy to restore and keeps valid FK relationships. Some tables (status tables, tables that form the basis for select elements) never have elements deleted so we don’t worry about this. The other day we needed to make sure every table had a deleted column.

In order to fix this we looked at the information_schema database that MySQL creates. It’s a set of dynamically generated tables that allow you to SQL your way through your database’s layout.

Below is the select we created to find these missing columns:

select TABLES.TABLE_NAME from information_schema.TABLES
left join information_schema.COLUMNS on TABLES.TABLE_NAME = COLUMNS.TABLE_NAME and TABLES.TABLE_SCHEMA = COLUMNS.TABLE_SCHEMA and COLUMNS.COLUMN_NAME = 'deleted'
where TABLES.TABLE_SCHEMA = '{yourschemaname}' and COLUMNS.TABLE_NAME is null

Link Post and Podcast Roundup: June 2017 Edition

Link Post Logo

June’s links.

Read More

Fixing the "Token undefined not a primary expression at column null of the expression" error

The other day I was working on an Angular application and I received the following error message:

Token ‘undefined’ not a primary expression at column null of the expression

This was not a very helpful error message but I tracked it down to the following:

<label ng-click=toggleIsRequiredChecked($event, activeModules, module)">
    <input type="checkbox" ng-checked="getIsRequiredChecked(activeModules, moduleName)">
    
</label>

Do you see the error? The double quote is missing from the ng-click attribute which caused the error. I added it and the code worked:

<label ng-click="toggleIsRequiredChecked($event, activeModules, module)">
    <input type="checkbox" ng-checked="getIsRequiredChecked(activeModules, moduleName)">
    
</label>
RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general