1 | <?php |
||
39 | class Update extends AbstractCommand |
||
40 | { |
||
41 | |||
42 | private $table; |
||
43 | private $data = []; |
||
44 | |||
45 | use WhereTrait; |
||
46 | |||
47 | /** |
||
48 | * @param string $table table with which you wish to append to |
||
49 | * @param array $data a single level associative array containing keys that |
||
50 | * represent the fields and values that represent new values to be added into |
||
51 | * the table |
||
52 | * @param null|WhereStatementInterface $where an object that is designed to return |
||
53 | * a where statement to limit the data that is affected by the update |
||
54 | * @since v1.0.0 |
||
55 | */ |
||
56 | 13 | public function __construct( |
|
64 | |||
65 | /** |
||
66 | * takes the SQL and the data provided and executes the query with the data |
||
67 | * @param PDO $pdo a connection object that defines where the connection is |
||
68 | * to be executed |
||
69 | * @return bool TRUE on success or FALSE on failure. |
||
70 | * @throws NoRecordsAffectedException if strict is set to true an exception will be thrown if |
||
71 | * @throws EmptyDatasetException if no data has been set no fields can be discerned and no query can be made |
||
72 | * @throws ExecutionErrorException thrown when any exception or SQL failure occurs |
||
73 | * @since v1.0.0 |
||
74 | */ |
||
75 | 4 | public function execute(PDO $pdo) |
|
90 | |||
91 | /** |
||
92 | * Generates a SQL statement ready to be prepared for execution with the |
||
93 | * intent of updating data |
||
94 | * @return string a string that represents an update statement ready to be |
||
95 | * prepared by PDO |
||
96 | * @throws EmptyDatasetException if no data has been set no fields can be |
||
97 | * discerned and no query can be made |
||
98 | * @since v1.0.0 |
||
99 | */ |
||
100 | 7 | public function getSql() |
|
118 | |||
119 | /** |
||
120 | * retrieves the table with which you wish to update |
||
121 | * @return string table with which you wish to update |
||
122 | * @since v1.0.0 |
||
123 | */ |
||
124 | 7 | public function getTable() |
|
128 | |||
129 | /** |
||
130 | * defines a table with which you wish to update |
||
131 | * @param string $table a table with which you wish to update |
||
132 | * @return Update for method chaining |
||
133 | * @since v1.0.0 |
||
134 | */ |
||
135 | 13 | public function setTable($table) |
|
140 | |||
141 | /** |
||
142 | * Returns a combination of data from Where statement and from this object |
||
143 | * @return array |
||
144 | * @since v1.0.0 |
||
145 | */ |
||
146 | 4 | public function getCombinedData() |
|
151 | |||
152 | /** |
||
153 | * retrieves the data that is used to generate the update statement. The |
||
154 | * fields of the array are used to generate the field list. |
||
155 | * @return array a single level associative array containing keys that |
||
156 | * represent the fields and values that represent new values to be updated in the table |
||
157 | * @since v1.0.0 |
||
158 | */ |
||
159 | 10 | public function getData() |
|
163 | |||
164 | /** |
||
165 | * sets the data that is used to generate the update statement. The fields |
||
166 | * of the array are used to generate the field list. |
||
167 | * @param array $data a single level associative array containing keys that |
||
168 | * represent the fields and values that represent values to be updated into the table |
||
169 | * @return Update for method chaining |
||
170 | * @since v1.0.0 |
||
171 | */ |
||
172 | 13 | public function setData($data) |
|
177 | } |
||
178 |