Driver


Using ConnectionFactory


The ConnectionFactory allows access maintained connections in the siesta.config.json file.

// accessing the default connection
$defaultConnection = ConnectionFactory::getConnection();

// accessing a connection by name
$customConnection = ConnectionFactory::getConnection("custom");

Using Connection


The connection class abstracts database specific and allows to start transaction and executing queries.

$connection = ConnectionFactory::getConnection();

try {
    $connection->startTransaction();

    ...

    $resultSet = $connection->query("UPDATE ...");


    $connection->commit();
} catch (SQLException $sql) {
    $connection->rollback();
}

Using ResultSet


Custom stored procedures allow to return ResultSet objects. ResultSet objects allow iterating over the list rows found including type aware access to the data.

    $resultSet = $artistService->getMyCustomList("Parameter1", "parameter2");

    // hasNext() method will tell if there is another row available.
    while($resultSet->hasNext()) {

        // getter allow to access row data
        // using the generated const for every column
        $isCool = $resultSet->getBooleanValue(Artist::COLUMN_IS_COOL);
        $numberOfAlbums = $resultSet->getIntegerValue(Artist::COLUMN_NUMBER_OF_ALBUMS);

        // you can also use name of a column directly
        $custom = $resultSet->getFloatValue("custom_column_name");
        $artistName = $resultSet->getStringValue(Artist::COLUMN_NAME);
        $dob = $resultSet->getDateTime(Artist::COLUMN_DOB);

    }
    // mandatory(!!!) with storeprocedures
    $resultSet->close();