kirkbushell / eloquence

A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.
MIT License
537 stars 58 forks source link

Question: Databases supported #57

Closed ericp1337 closed 7 years ago

ericp1337 commented 8 years ago

Is MySQL/MariaDB the only supported database? Because I tried to use the countCache with postgresql and the syntax is not compatible since it doesn't like the tilda (`)

ericp1337 commented 8 years ago

I've managed to rewrite the following in order to support multiple database systems

    public function updateCacheRecord(array $config, $operation, $amount, $foreignKey)
    {
        if (is_null($foreignKey)) {
            return;
        }

        $config = $this->processConfig($config);

        $sql = DB::table($config['table'])
            ->where($config['key'], $foreignKey);

        /*
         * Increment for + operator
         */
        if ($operation == '+') {
            return $sql
                ->increment($config['field'], $amount);
        }

        /*
         * Operator is - so decrement
         */
        return $sql
            ->decrement($config['field'], $amount);
    }

But am having trouble figuring out if the rebuildCacheRecord can be rewritten using the DB class.

It would be nice if someone could figure out a way to do this so that this project's cache behavior can be used on all supported laravel databases.

kirkbushell commented 8 years ago

Interesting, I wasn't aware (obviously) that would be an issue in PSQL.

Let's definitely look at correcting that. Would you like to start a PR?

ericp1337 commented 8 years ago

Here's what I've come up with so far. https://github.com/computerfr33k/eloquence/commit/acf8407b2f0e1ea2aec0370fb5a821a38fa03caa