@@ -50,66 +50,66 @@ |
||
| 50 | 50 | { |
| 51 | 51 | switch(DB::connection()->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME)) |
| 52 | 52 | { |
| 53 | - case 'mysql': |
|
| 54 | - |
|
| 55 | - $sql = 'INSERT INTO quotalog' . |
|
| 56 | - ' (date, connection, hits, misses, created_at, updated_at)' . |
|
| 57 | - ' VALUES' . |
|
| 58 | - ' ( :date, :connection, :hits, :misses, :created_at, :updated_at)' . |
|
| 59 | - ' ON DUPLICATE KEY UPDATE' . |
|
| 60 | - ' hits = VALUES(hits),' . |
|
| 61 | - ' misses = VALUES(misses),' . |
|
| 62 | - ' updated_at = VALUES(updated_at)'; |
|
| 63 | - |
|
| 64 | - $this->doUpsertStatement($sql); |
|
| 65 | - |
|
| 66 | - break; |
|
| 67 | - case 'sqlite': |
|
| 68 | - |
|
| 69 | - $date = $this->argument('date'); |
|
| 70 | - $connection = $this->argument('connection'); |
|
| 71 | - |
|
| 72 | - $sql = 'UPDATE quotalog' . |
|
| 73 | - ' SET `date` = :date' . |
|
| 74 | - ', `connection` = :connection' . |
|
| 75 | - ', `hits` = :hits' . |
|
| 76 | - ', `misses` = :misses' . |
|
| 77 | - ', `updated_at` = :updated_at' . |
|
| 78 | - ' WHERE `date` = ' . '\''. $date . '\'' . |
|
| 79 | - ' AND `connection` = ' . '\'' . $connection . '\''; |
|
| 80 | - |
|
| 81 | - $this->doUpdateStatement($sql); |
|
| 82 | - |
|
| 83 | - $changes = DB::select('SELECT changes()'); |
|
| 84 | - if(! $this->sqliteUpdateDidChange($changes)) |
|
| 85 | - { |
|
| 53 | + case 'mysql': |
|
| 54 | + |
|
| 86 | 55 | $sql = 'INSERT INTO quotalog' . |
| 87 | - ' (' . |
|
| 88 | - ' `date`' . |
|
| 89 | - ', `connection`' . |
|
| 90 | - ', `hits`' . |
|
| 91 | - ', `misses`' . |
|
| 92 | - ', `created_at`' . |
|
| 93 | - ', `updated_at`' . |
|
| 94 | - ')' . |
|
| 95 | - ' VALUES' . |
|
| 96 | - ' (' . |
|
| 97 | - ' :date' . |
|
| 98 | - ', :connection' . |
|
| 99 | - ', :hits' . |
|
| 100 | - ', :misses' . |
|
| 101 | - ', :created_at' . |
|
| 102 | - ', :updated_at' . |
|
| 103 | - ')'; |
|
| 56 | + ' (date, connection, hits, misses, created_at, updated_at)' . |
|
| 57 | + ' VALUES' . |
|
| 58 | + ' ( :date, :connection, :hits, :misses, :created_at, :updated_at)' . |
|
| 59 | + ' ON DUPLICATE KEY UPDATE' . |
|
| 60 | + ' hits = VALUES(hits),' . |
|
| 61 | + ' misses = VALUES(misses),' . |
|
| 62 | + ' updated_at = VALUES(updated_at)'; |
|
| 104 | 63 | |
| 105 | 64 | $this->doUpsertStatement($sql); |
| 106 | - } |
|
| 107 | - break; |
|
| 108 | 65 | |
| 109 | - default: |
|
| 110 | - throw new \ErrorException( |
|
| 111 | - __CLASS__.'::'.__FUNCTION__. |
|
| 112 | - ' Driver: ' . $driver . ' not supported.'); |
|
| 66 | + break; |
|
| 67 | + case 'sqlite': |
|
| 68 | + |
|
| 69 | + $date = $this->argument('date'); |
|
| 70 | + $connection = $this->argument('connection'); |
|
| 71 | + |
|
| 72 | + $sql = 'UPDATE quotalog' . |
|
| 73 | + ' SET `date` = :date' . |
|
| 74 | + ', `connection` = :connection' . |
|
| 75 | + ', `hits` = :hits' . |
|
| 76 | + ', `misses` = :misses' . |
|
| 77 | + ', `updated_at` = :updated_at' . |
|
| 78 | + ' WHERE `date` = ' . '\''. $date . '\'' . |
|
| 79 | + ' AND `connection` = ' . '\'' . $connection . '\''; |
|
| 80 | + |
|
| 81 | + $this->doUpdateStatement($sql); |
|
| 82 | + |
|
| 83 | + $changes = DB::select('SELECT changes()'); |
|
| 84 | + if(! $this->sqliteUpdateDidChange($changes)) |
|
| 85 | + { |
|
| 86 | + $sql = 'INSERT INTO quotalog' . |
|
| 87 | + ' (' . |
|
| 88 | + ' `date`' . |
|
| 89 | + ', `connection`' . |
|
| 90 | + ', `hits`' . |
|
| 91 | + ', `misses`' . |
|
| 92 | + ', `created_at`' . |
|
| 93 | + ', `updated_at`' . |
|
| 94 | + ')' . |
|
| 95 | + ' VALUES' . |
|
| 96 | + ' (' . |
|
| 97 | + ' :date' . |
|
| 98 | + ', :connection' . |
|
| 99 | + ', :hits' . |
|
| 100 | + ', :misses' . |
|
| 101 | + ', :created_at' . |
|
| 102 | + ', :updated_at' . |
|
| 103 | + ')'; |
|
| 104 | + |
|
| 105 | + $this->doUpsertStatement($sql); |
|
| 106 | + } |
|
| 107 | + break; |
|
| 108 | + |
|
| 109 | + default: |
|
| 110 | + throw new \ErrorException( |
|
| 111 | + __CLASS__.'::'.__FUNCTION__. |
|
| 112 | + ' Driver: ' . $driver . ' not supported.'); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |