symfony API

sfDatabase Class

« Back to API menu

action

addon

autoload

cache

command

config

controller

creole

database

debug

exception

filter

form

generator

helper

i18n

log

plugin

propel

request

response

routing

storage

task

test

user

util

validator

view

widget

You are currently browsing the symfony documentation for the 1.1 version. Switch to:

sfDatabase is a base abstraction class that allows you to setup any type of database connection via a configuration file.

Method Summary

  • __construct($parameters = array())
    Class constructor.
  • shutdown()
    Executes the shutdown procedure.
  • boolean hasParameter($name)
    Returns true if the given key exists in the parameter holder.
  • string getParameter($name, $default = null)
    Gets the parameter associated with the given key.
  • connect()
    Connects to the database.
  • bool initialize($parameters = array())
    Initializes this sfDatabase object.
  • mixed getResource()
    Retrieves a raw database resource associated with this sfDatabase implementation.
  • getParameterHolder()
    Gets the parameter holder for this object.
  • mixed getConnection()
    Retrieves the database connection associated with this sfDatabase implementation.
  • setParameter($name, $value)
    Sets the value for the given key.

Method Details

  • __construct ($parameters = array())

    Class constructor.

  • shutdown ()

    Executes the shutdown procedure.

    throws sfDatabaseException If an error occurs while shutting down this database

  • (boolean) hasParameter ($name)

    $name The key name

    Returns true if the given key exists in the parameter holder.

    This is a shortcut for:

    $this->getParameterHolder()->has()

    returns true if the given key exists, false otherwise

  • (string) getParameter ($name, $default = null)

    $name The key name
    $default The default value

    Gets the parameter associated with the given key.

    This is a shortcut for:

    $this->getParameterHolder()->get()

    returns The value associated with the key

  • connect ()

    Connects to the database.

    throws sfDatabaseException If a connection could not be created

  • (bool) initialize ($parameters = array())

    $parameters An associative array of initialization parameters

    Initializes this sfDatabase object.

    returns true, if initialization completes successfully, otherwise false

    throws sfInitializationException If an error occurs while initializing this sfDatabase object

  • (mixed) getResource ()

    Retrieves a raw database resource associated with this sfDatabase implementation.

    returns A database resource

    throws sfDatabaseException If a resource could not be retrieved

  • getParameterHolder ()

    Gets the parameter holder for this object.

    returns A sfParameterHolder instance

  • (mixed) getConnection ()

    Retrieves the database connection associated with this sfDatabase implementation.

    When this is executed on a Database implementation that isn't an abstraction layer, a copy of the resource will be returned.

    returns A database connection

    throws sfDatabaseException If a connection could not be retrieved

  • setParameter ($name, $value)

    $name The key name
    $value The value

    Sets the value for the given key.

    This is a shortcut for:

    $this->getParameterHolder()->set()