<commit_before><?php
/*
 * Limb PHP Framework
 *
 * @link http://limb-project.com
 * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */
lmb_require('limb/dbal/src/lmbSimpleDb.class.php');
lmb_require('limb/dbal/src/query/lmbSelectQuery.class.php');
lmb_require('limb/dbal/src/query/lmbUpdateQuery.class.php');
lmb_require('limb/dbal/src/query/lmbDeleteQuery.class.php');
lmb_require('limb/dbal/src/query/lmbInsertQuery.class.php');
lmb_require('limb/dbal/src/query/lmbBulkInsertQuery.class.php');

/**
 * class lmbDBAL.
 *
 * @package dbal
 * @version $Id: lmbDBAL.class.php 7109 2008-07-10 07:09:25Z serega $
 */
class lmbDBAL
{
  /**
   * @param lmbDbDSN $dsn
   */
  static function setDefaultDSN($dsn)
  {
    lmbToolkit :: instance()->setDefaultDbDSN($dsn);
  }

  static function setEnvironment($env)
  {
    lmbToolkit :: instance()->setDbEnvironment($env);
  }

  /**
   * @param lmbDbDSN $dsn
   * @return lmbDbConnetion
   */
  static function newConnection($dsn)
  {
    return lmbToolkit :: instance()->createDbConnection($dsn);
  }

  /**
   * @param lmbDbDSN $dsn
   * @return lmbDbConnetion
   */
  static function defaultConnection()
  {
    return lmbToolkit :: instance()->getDefaultDbConnection();
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return lmbDbStatement
   */
  static function newStatement($sql, $conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();
    return $conn->newStatement($sql);
  }

  /**
   * @param [lmbDbConnetion] $conn
   * @return lmbSimpleDb
   */
  static function db($conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();

    return new lmbSimpleDb($conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbTableGateway
   */
  static function table($table, $conn = null)
  {
    return lmbToolkit :: instance()->createTableGateway($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbSelectQuery
   */
  static function selectQuery($table, $conn = null)
  {
    return new lmbSelectQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbInsertQuery
   */
  static function insertQuery($table, $conn = null)
  {
    return new lmbInsertQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbBulkInsertQuery
   */
  static function bulkInsertQuery($table, $conn = null)
  {
    return new lmbBulkInsertQuery($table, $conn);
  }
  
  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbUpdateQuery
   */
  static function updateQuery($table, $conn = null)
  {
    return new lmbUpdateQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbDeleteQuery
   */
  static function deleteQuery($table, $conn = null)
  {
    return new lmbDeleteQuery($table, $conn);
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return lmbDbRecordSet
   */
  static function fetch($sql, $conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();
    $stmt = $conn->newStatement($sql);
    return $stmt->getRecordSet();
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return string
   */<commit_msg>[svn r7130] -- added function lmbDBAL::fetchOneRow()<commit_after><?php
/*
 * Limb PHP Framework
 *
 * @link http://limb-project.com
 * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */
lmb_require('limb/dbal/src/lmbSimpleDb.class.php');
lmb_require('limb/dbal/src/query/lmbSelectQuery.class.php');
lmb_require('limb/dbal/src/query/lmbUpdateQuery.class.php');
lmb_require('limb/dbal/src/query/lmbDeleteQuery.class.php');
lmb_require('limb/dbal/src/query/lmbInsertQuery.class.php');
lmb_require('limb/dbal/src/query/lmbBulkInsertQuery.class.php');

/**
 * class lmbDBAL.
 *
 * @package dbal
 * @version $Id: lmbDBAL.class.php 7130 2008-07-23 10:43:27Z conf $
 */
class lmbDBAL
{
  /**
   * @param lmbDbDSN $dsn
   */
  static function setDefaultDSN($dsn)
  {
    lmbToolkit :: instance()->setDefaultDbDSN($dsn);
  }

  static function setEnvironment($env)
  {
    lmbToolkit :: instance()->setDbEnvironment($env);
  }

  /**
   * @param lmbDbDSN $dsn
   * @return lmbDbConnetion
   */
  static function newConnection($dsn)
  {
    return lmbToolkit :: instance()->createDbConnection($dsn);
  }

  /**
   * @param lmbDbDSN $dsn
   * @return lmbDbConnetion
   */
  static function defaultConnection()
  {
    return lmbToolkit :: instance()->getDefaultDbConnection();
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return lmbDbStatement
   */
  static function newStatement($sql, $conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();
    return $conn->newStatement($sql);
  }

  /**
   * @param [lmbDbConnetion] $conn
   * @return lmbSimpleDb
   */
  static function db($conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();

    return new lmbSimpleDb($conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbTableGateway
   */
  static function table($table, $conn = null)
  {
    return lmbToolkit :: instance()->createTableGateway($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbSelectQuery
   */
  static function selectQuery($table, $conn = null)
  {
    return new lmbSelectQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbInsertQuery
   */
  static function insertQuery($table, $conn = null)
  {
    return new lmbInsertQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbBulkInsertQuery
   */
  static function bulkInsertQuery($table, $conn = null)
  {
    return new lmbBulkInsertQuery($table, $conn);
  }
  
  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbUpdateQuery
   */
  static function updateQuery($table, $conn = null)
  {
    return new lmbUpdateQuery($table, $conn);
  }

  /**
   * @param string $table
   * @param [lmbDbConnection] $conn
   * @return lmbDeleteQuery
   */
  static function deleteQuery($table, $conn = null)
  {
    return new lmbDeleteQuery($table, $conn);
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return lmbDbRecordSet
   */
  static function fetch($sql, $conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();
    $stmt = $conn->newStatement($sql);
    return $stmt->getRecordSet();
  }  
  
  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return lmbDbRecord
   */
  static function fetchOneRow($sql, $conn = null)
  {
    if(!$conn)
      $conn = lmbToolkit :: instance()->getDefaultDbConnection();
    $stmt = $conn->newStatement($sql);
    return $stmt->getOneRecord();
  }

  /**
   * @param string $sql
   * @param [lmbDbConnection] $conn
   * @return string
   */
{'fraction_non_alphanumeric': 0.1554411166824773, 'fraction_numerical': 0.0075891042146632335, 'mean_word_length': 3.2956926658905705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3690003', 'n_tokens_mistral': 2655, 'n_tokens_neox': 2596, 'n_words': 493}