fixing database connections
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php namespace Lucent\Edge;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\LucentException;
|
||||
use PDOException;
|
||||
use stdClass;
|
||||
@@ -15,7 +15,7 @@ class EdgeRepo
|
||||
public function insert(Edge $edge): void
|
||||
{
|
||||
try {
|
||||
DB::table("edges")->insert($edge->toDB());
|
||||
Database::make()->table("edges")->insert($edge->toDB());
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() == 23505) {
|
||||
throw new LucentException("Edge already exists");
|
||||
@@ -34,7 +34,7 @@ class EdgeRepo
|
||||
{
|
||||
$edgesDB = collect($edges)->map(fn($e) => $e->toDB())->toArray();
|
||||
try {
|
||||
DB::table("edges")->insert($edgesDB);
|
||||
Database::make()->table("edges")->insert($edgesDB);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() == 23505) {
|
||||
throw new LucentException("Edge already exists");
|
||||
@@ -52,8 +52,8 @@ class EdgeRepo
|
||||
public function replaceForRecord(string $from, array $edges): void
|
||||
{
|
||||
$edgesDB = collect($edges)->map(fn($e) => $e->toDB())->toArray();
|
||||
DB::table("edges")->where("source", $from)->delete();
|
||||
DB::table("edges")->insert($edgesDB);
|
||||
Database::make()->table("edges")->where("source", $from)->delete();
|
||||
Database::make()->table("edges")->insert($edgesDB);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,13 @@ class EdgeRepo
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
$edges = DB::table("edges")->get();
|
||||
$edges = Database::make()->table("edges")->get();
|
||||
return $edges->map([$this, 'mapEdge'])->toArray();
|
||||
}
|
||||
|
||||
public function findForSource(string $recordId): array
|
||||
{
|
||||
$edges = DB::table("edges")->where("source", $recordId)->get();
|
||||
$edges = Database::make()->table("edges")->where("source", $recordId)->get();
|
||||
return $edges->map([$this, 'mapEdge'])->toArray();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class EdgeRepo
|
||||
|
||||
public function remove(Edge $edge): void
|
||||
{
|
||||
DB::table("edges")
|
||||
Database::make()->table("edges")
|
||||
->where("source", $edge->source)
|
||||
->where("target", $edge->target)
|
||||
->where("sourceSchema", $edge->sourceSchema)
|
||||
@@ -100,7 +100,7 @@ class EdgeRepo
|
||||
|
||||
public function findLastEdgeRank(string $source, string $field): string
|
||||
{
|
||||
$data = DB::table("edges")
|
||||
$data = Database::make()->table("edges")
|
||||
->where("source", $source)
|
||||
->where("field", $field)
|
||||
->orderBy("rank", "desc")
|
||||
|
||||
Reference in New Issue
Block a user