/** * Wrapper method for Next\DB\Driver\Driver::prepare() and Next\DB\Statement\Statement:execute() * * @return Next\DB\Statement\Statement * Statement Object * * @throws Next\DB\Table\TableException * SQL Statement is empty * * @throws Next\DB\Table\TableException * A DriverException or a StatementException is caught */ private function execute() { $query = $this->assemble(); if (empty($query)) { throw TableException::logic('Query is empty'); } // Preparing... try { $stmt = $this->driver->prepare($query); } catch (DriverException $e) { throw TableException::prepare($e); } // ... and Executing try { $stmt->execute($this->getReplacements()); } catch (StatementException $e) { throw TableException::execute($e); } return $stmt; }
/** * Add HAVING Clause(s) * * @param array|string $condition * HAVING Clause * * @param array|optional $value * Value for Clause's Placeholders (if any) * * @param mixed|boolean|optional $isMatchingHaving * * <p>If TRUE is a 'AND' HAVING Clause</p> * * <p>If FALSE, is 'OR' HAVING Clause</p> * * @return Next\DB\Table\Select * Table Select Object (Fluent Interface) * * @throws Next\DB\Table\TableException * HAVING Clause is empty */ public function having($condition, array $value = array(), $isMatchingHaving = TRUE) { $condition = trim((string) $condition); if (empty($condition)) { throw TableException::logic('HAVING Clause Condition must be set as non-empty string'); } // Registering Placeholder Replacement Value $this->setReplacements((array) $value, self::SQL_HAVING); // Adding Clause to SQL Parts Property parent::$parts[self::SQL_HAVING][] = array($condition => $isMatchingHaving ? self::SQL_AND : self::SQL_OR); return $this; }