/** * 提交事务 * * @return boolean */ public function commit() { if (is_null($this->db)) { $this->db = \Util\Db\Manager::getInstance($this->dbName); } return $this->db->commit(); }
/** * Funktion zum endgültigem Löschen von Produkten * @param type $id * @param type $db */ function deleteProduct($id, $db) { $user_id = $_SESSION['user_id']; //debug($id); try { $db->beginTransaction(); $stmt = $db->prepare('SELECT ' . 'products.product_image_path ' . 'FROM products ' . 'WHERE products.product_id = ?'); $stmt->execute(array($id)); $image_path = $stmt->fetch(PDO::FETCH_ASSOC); $stmt = $db->prepare('DELETE ' . 'FROM package_has_products ' . 'WHERE package_has_products.product_id = ? ' . 'AND package_has_products.user_id = ?'); $stmt->execute(array($id, $user_id)); $stmt = $db->prepare('DELETE ' . 'FROM products ' . 'WHERE products.product_id = ?'); $stmt->execute(array($id)); $stmt = $db->prepare('DELETE ' . 'FROM product_has_category ' . 'WHERE product_has_category.product_id = ?'); $stmt->execute(array($id)); $stmt = $db->prepare('SELECT ' . 'product_has_properties.properties_id ' . 'FROM product_has_properties ' . 'WHERE product_has_properties.product_id = ?'); $stmt->execute(array($id)); $properties = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($properties as $key => $property) { $stmt = $db->prepare('DELETE ' . 'FROM properties ' . 'WHERE property_id = ?'); $stmt->execute(array($property['properties_id'])); } $stmt = $db->prepare('DELETE ' . 'FROM product_has_properties ' . 'WHERE product_has_properties.product_id = ?'); $stmt->execute(array($id)); $stmt = $db->prepare('DELETE ' . 'FROM product_has_subcategory ' . 'WHERE product_has_subcategory.product_id = ?'); $stmt->execute(array($id)); $stmt = $db->prepare('DELETE ' . 'FROM user_has_products ' . 'WHERE user_has_products.product_id = ? ' . 'AND user_has_products.user_id = ?'); $stmt->execute(array($id, $user_id)); $db->commit(); } catch (PDOException $e) { $db->rollBack(); $e->getMessage(); } if (empty($e)) { $img = ''; if (is_dir($image_path['product_image_path']) && ($pp = opendir($image_path['product_image_path']))) { while (($file = readdir($pp)) !== false) { if ($file != "." && $file != "..") { $img[] = $file; } } closedir($pp); } foreach ($img as $key => $image) { unlink($image_path['product_image_path'] . $image); } rmdir($image_path['product_image_path']); return true; } else { //var_dump($e); return false; } }
/** * @version 1.10 * @todo metodo generico para executar metodos call * OBS. AINDA NÃO FOI TESTADO * @param type $callabeFunction * @param array $array * @return type * @throws PDOException */ public final function genericExecuteCall($callabeFunction = null, array $array = NULL) { try { $this->con->beginTransaction(); $valuesExecute = $this->prepareKeyValues($array); $sql = "CALL {$callabeFunction}( " . implode(',', array_keys($valuesExecute)) . " );"; $stmt = $this->con->prepare($sql); $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt->execute($valuesExecute); //trabalhar a exception pelo erro gerado $this->con->errorCode(); $this->con->commit(); return TRUE; } catch (PDOException $ex) { $this->con->rollBack(); throw $ex; } }
public function commit() { if (self::$link) { self::$link->commit(); } }
/** * */ public function commit() { // $this->_pdo->commit(); }