public static function add($objectType, $objectId = null, $action = null, $fieldName = null, $oldValue = null, $newValue = null, $userId = 0, $content = '')
    {
        global $PPHP;
        $db = $PPHP['db'];

        $ip = '127.0.0.1';
        $req = grab('request');
        if (isset($req['remote_addr'])) {
            $ip = $req['remote_addr'];
        };

        // First argument could contain named arguments
        if (is_array($objectType)) {
            if (isset($objectType['objectId']))  $objectId  = $objectType['objectId'];
            if (isset($objectType['action']))    $action    = $objectType['action'];
            if (isset($objectType['fieldName'])) $fieldName = $objectType['fieldName'];
            if (isset($objectType['oldValue']))  $oldValue  = $objectType['oldValue'];
            if (isset($objectType['newValue']))  $newValue  = $objectType['newValue'];
            if (isset($objectType['userId']))    $userId    = $objectType['userId'];
            if (isset($objectType['content']))   $content   = $objectType['content'];
            if (isset($objectType['objectType'])) {
                $objectType = $objectType['objectType'];
            } else {
                $objectType = null;
            };
        };
        if ($objectType === null && $objectId === null && $PPHP['contextType'] !== null && $PPHP['contextId'] !== null) {
            $objectType = $PPHP['contextType'];
            $objectId = $PPHP['contextId'];
        };

        if (isset($_SESSION['user']['id'])) {
            $actingUserId = $_SESSION['user']['id'];
            if ($userId === 0) {
                $userId = $actingUserId;
            };
        };

        // Enforce size limit on field values
        $oldValue = substr($oldValue, 0, 250);
        $newValue = substr($newValue, 0, 250);

        $db->exec(
            "
            INSERT INTO transactions
            (actingUserId, userId, ip, objectType, objectId, action, fieldName, oldValue, newValue, content)
            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
            ",
            array(
                $actingUserId,
                $userId,
                $ip,
                $objectType,
                $objectId,
                $action,
                $fieldName,
                $oldValue,
                $newValue,
                $content
            )
        );
    }