@@ 90-105 (lines=16) @@ | ||
87 | * occurs |
|
88 | * @since v1.0.0 |
|
89 | */ |
|
90 | public function execute(PDO $pdo) |
|
91 | { |
|
92 | try { |
|
93 | $sql = $this->getSql(); |
|
94 | $stmt = $pdo->prepare($sql); |
|
95 | if (!$stmt->execute($this->getData())) { |
|
96 | throw new ExecutionErrorException($stmt->errorInfo()[2]); |
|
97 | } |
|
98 | $this->checkAffected($stmt, new NoRecordsAffectedCreateException()); |
|
99 | return $pdo->lastInsertId(); |
|
100 | } catch (NoRecordsAffectedException $exc) { |
|
101 | throw $exc; |
|
102 | } catch (\Exception $exc) { |
|
103 | throw new ExecutionErrorException($exc->getMessage()); |
|
104 | } |
|
105 | } |
|
106 | ||
107 | /** |
|
108 | * retrieves the table with which you wish to append to |
@@ 63-79 (lines=17) @@ | ||
60 | * @throws ExecutionErrorException thrown when any exception or SQL failure occurs |
|
61 | * @since v1.0.0 |
|
62 | */ |
|
63 | public function execute(PDO $pdo) |
|
64 | { |
|
65 | try { |
|
66 | $stmt = $pdo->prepare($this->getSql()); |
|
67 | if (count($this->getData()) > 0) { |
|
68 | $result = $stmt->execute($this->getData()); |
|
69 | } else { |
|
70 | $result = $stmt->execute(); |
|
71 | } |
|
72 | $this->checkAffected($stmt, new NoRecordsAffectedDeleteException()); |
|
73 | return $result; |
|
74 | } catch (NoRecordsAffectedException $exc) { |
|
75 | throw $exc; |
|
76 | } catch (\Exception $exc) { |
|
77 | throw new ExecutionErrorException($exc->getMessage()); |
|
78 | } |
|
79 | } |
|
80 | ||
81 | /** |
|
82 | * retrieves the data that is uses to fulfill the requirements of a prepared |