Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
27 | public function validate($rowHash, $referenceResource, array $referenceFields) |
||
28 | { |
||
29 | $referenceFields = implode(" || ', ' || ", $referenceFields); |
||
30 | |||
31 | $validationSql = "SELECT |
||
32 | COUNT(*) |
||
33 | FROM |
||
34 | $referenceResource |
||
35 | WHERE |
||
36 | $referenceFields = :row_hash"; |
||
37 | |||
38 | $statement = Base::$pdoConnection->prepare($validationSql); |
||
39 | $statement->bindParam(':row_hash', $rowHash); |
||
40 | $results = $statement->execute(); |
||
41 | |||
42 | if (false === $results) { |
||
43 | throw new \Exception("Could not validate the foreign key for $referenceResource |
||
44 | fields $referenceFields with hash of $rowHash."); |
||
45 | } |
||
46 | |||
47 | return (0 !== $results[0]['count']); |
||
48 | } |
||
49 | } |
||
50 |