/** * Ends transactional mode and enables auto commit again. * * @throws SQLAnywhereException * * @return boolean Whether or not ending transactional mode succeeded. */ private function endTransaction() { if (!sasql_set_option($this->connection, 'auto_commit', 'on')) { throw SQLAnywhereException::fromSQLAnywhereError($this->connection); } return true; }
/** * {@inheritdoc} * * @throws SQLAnywhereException */ public function rollBack() { if (!sasql_rollback($this->connection)) { throw SQLAnywhereException::fromSQLAnywhereError($this->connection); } $this->endTransaction(); return true; }
/** * {@inheritdoc} * * @throws SQLAnywhereException */ public function execute($params = null) { if (is_array($params)) { $hasZeroIndex = array_key_exists(0, $params); foreach ($params as $key => $val) { $key = $hasZeroIndex && is_numeric($key) ? $key + 1 : $key; $this->bindValue($key, $val); } } if (!sasql_stmt_execute($this->stmt)) { throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt); } $this->result = sasql_stmt_result_metadata($this->stmt); return true; }
/** * {@inheritdoc} * * @throws SQLAnywhereException */ public function bindParam($column, &$variable, $type = null, $length = null) { switch ($type) { case PDO::PARAM_INT: case PDO::PARAM_BOOL: $type = 'i'; break; case PDO::PARAM_LOB: $type = 'b'; break; case PDO::PARAM_NULL: case PDO::PARAM_STR: $type = 's'; break; default: throw new SQLAnywhereException('Unknown type: ' . $type); } if (!sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) { throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt); } return true; }