joi, 16 aprilie 2015

Add Capsule Raw To Illuminate Database Laravel

Go to 'database\illuminate\Database\Capsule\Manager' class and add this lines!

/**
 * Get a fluent raw query expression.
 *
 * @param  mixed  $value
 * @return \Illuminate\Database\Query\Expression
 */
public static function raw($value) {
    return static::$instance->connection()->raw($value);
}

Now you can run $capsule->raw('INSERT INTO ....');

https://github.com/illuminate/database

How to count duplicate rows!

Hello, bellow is MySQL query to count duplicate rows by value.

SELECT DISTINCT(user_city) as city, count(user_city) AS count 
FROM users
GROUP BY user_city
HAVING count > 5