-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
299 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/vendor | ||
/build | ||
composer.phar | ||
composer.lock | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
<?php | ||
|
||
use Faker\Generator as Faker; | ||
use Spiritix\LadaCache\Tests\Database\Models\Car; | ||
use Spiritix\LadaCache\Tests\Database\Models\CarMaterial; | ||
use Spiritix\LadaCache\Tests\Database\Models\Driver; | ||
use Spiritix\LadaCache\Tests\Database\Models\Engine; | ||
use Spiritix\LadaCache\Tests\Database\Models\Material; | ||
use Spiritix\LadaCache\Tests\Database\Models\CarMaterial; | ||
|
||
/* @var $factory callable */ | ||
/* @var $faker \Laracasts\TestDummy\FakerAdapter */ | ||
|
||
$factory(Car::class, [ | ||
$factory->define(Car::class, function (Faker $faker) { | ||
return [ | ||
'name' => $faker->word, | ||
'engine_id' => $faker->randomNumber(8), | ||
'driver_id' => $faker->randomNumber(8), | ||
]); | ||
]; | ||
}); | ||
|
||
$factory(Engine::class, [ | ||
'name' => $faker->word, | ||
'car_id' => $faker->randomNumber(8), | ||
]); | ||
$factory->define(Engine::class, function (Faker $faker) { | ||
return [ | ||
'name' => $faker->word, | ||
'car_id' => $faker->randomNumber(8), | ||
]; | ||
}); | ||
|
||
$factory(Driver::class, [ | ||
'name' => $faker->word, | ||
]); | ||
$factory->define(Driver::class, function (Faker $faker) { | ||
return [ | ||
'name' => $faker->word, | ||
]; | ||
}); | ||
|
||
$factory(Material::class, [ | ||
'name' => $faker->word, | ||
]); | ||
$factory->define(Material::class, function (Faker $faker) { | ||
return [ | ||
'name' => $faker->word, | ||
]; | ||
}); | ||
|
||
$factory(CarMaterial::class, [ | ||
'car_id' => $faker->randomNumber(8), | ||
'material_id' => $faker->randomNumber(8), | ||
]); | ||
$factory->define(CarMaterial::class, function (Faker $faker) { | ||
return [ | ||
'car_id' => $faker->randomNumber(8), | ||
'material_id' => $faker->randomNumber(8), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,31 @@ | |
namespace Spiritix\LadaCache\Database\Connection; | ||
|
||
use Spiritix\LadaCache\Database\Connection; | ||
use Illuminate\Database\Schema\MySqlBuilder; | ||
use Illuminate\Database\Query\Processors\MySqlProcessor; | ||
use Doctrine\DBAL\Driver\PDOMySql\Driver as DoctrineDriver; | ||
use Illuminate\Database\Query\Grammars\MySqlGrammar as QueryGrammar; | ||
use Illuminate\Database\Query\Processors\MySqlProcessor; | ||
use Illuminate\Database\Schema\Grammars\MySqlGrammar as SchemaGrammar; | ||
use Illuminate\Database\Schema\MySqlBuilder; | ||
use PDO; | ||
|
||
/** | ||
* Overrides Laravel's MySQL connection class. | ||
* | ||
* Contains code smell copy-pasted from Laravel :( | ||
* | ||
* @package Spiritix\LadaCache\Database\Connection | ||
* @author Matthias Isler <[email protected]> | ||
*/ | ||
class MysqlConnection extends Connection | ||
{ | ||
/** | ||
* Get the default query grammar instance. | ||
* | ||
* @return \Illuminate\Database\Query\Grammars\MySqlGrammar | ||
*/ | ||
protected function getDefaultQueryGrammar() | ||
{ | ||
return $this->withTablePrefix(new QueryGrammar); | ||
} | ||
|
||
/** | ||
* Get a schema builder instance for the connection. | ||
* | ||
|
@@ -42,16 +51,6 @@ public function getSchemaBuilder() | |
return new MySqlBuilder($this); | ||
} | ||
|
||
/** | ||
* Get the default query grammar instance. | ||
* | ||
* @return \Illuminate\Database\Query\Grammars\MySqlGrammar | ||
*/ | ||
protected function getDefaultQueryGrammar() | ||
{ | ||
return $this->withTablePrefix(new QueryGrammar); | ||
} | ||
|
||
/** | ||
* Get the default schema grammar instance. | ||
* | ||
|
@@ -81,4 +80,21 @@ protected function getDoctrineDriver() | |
{ | ||
return new DoctrineDriver; | ||
} | ||
|
||
/** | ||
* Bind values to their parameters in the given statement. | ||
* | ||
* @param \PDOStatement $statement | ||
* @param array $bindings | ||
* @return void | ||
*/ | ||
public function bindValues($statement, $bindings) | ||
{ | ||
foreach ($bindings as $key => $value) { | ||
$statement->bindValue( | ||
is_string($key) ? $key : $key + 1, $value, | ||
is_int($value) || is_float($value) ? PDO::PARAM_INT : PDO::PARAM_STR | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.