<commit_before><?php
/**
 *
 * $Id$
 */
  
  uses(
    'rdbms.SQLException',
    'util.Date',
    'util.log.Logger'
  );
  
  /**
   * Ergnzt bz_id-Felder durch bz_description, Datumsangaben durch unix-Timestamp
   *
   * @purpose Datenbank-Klasse fr Schlund-Datenbanken
   * @example sybase.ini
   * @see     http://manuals.sybase.com/
   * @see     http://curry.schlund.de/datenbank/MIGRAENE.html#bearbeitungszustand
   */
  class SPSybase extends Object {
    var 
      $handle= NULL,
      $host, 
      $user, 
      $pass, 
      $db, 
      $field_map= array(),
      $last_affected_rows= -1, 
      $last_num_rows= -1,
      $transaction= 0;
   
    // Do buffered queries? Default: TRUE
    var
      $_buffering= TRUE;
   
    // Logger
    var
      $log;
	  
    var
      $fields	= NULL,
      $lengths	= NULL;
 
    /**
     * Constructor
     */
    function __construct($params) {
      $l= &Logger::getInstance();
      $this->log= &$l->getCategory($this->getName());
      parent::__construct($params);
    }
    
    /**
     * Konnektieren
     *
     * @access  public
     * @return  resource Datenbank-Handle
     * @throws  SQLException, wenn kein Connect zustande kommt
     */
    function connect() {
      $this->handle= sybase_connect($this->host, $this->user, $this->pass);
      if (FALSE === $this->handle) return throw(new SQLException(sprintf(
        'Unable to connect to %s@%s',
        $this->user,
        $this->host
      )));
      return $this->handle;
    }

    /**
     * Datenbank auswhlen
     *
     * @access  public
     * @param   string db default NULL Auszuwhlende Datenbank (wenn NULL, $this->db)
     * @return  bool result Datenbank ausgewhlt?
     */    
    function select_db($db= NULL) {
      if(!is_null($db)) $this->db= $db;
      return @sybase_select_db($this->db, $this->handle);
    }
    
    /**
     * Private Helper-Funktion, ermglicht solcherlei Aufrufe
     *
     * <pre>
     * $qrh= $dbo->query('
     *   select 
     *     domain_id 
     *   from 
     *     domain 
     *   where 
     *     domainname = %s 
     *     and adminc= %d
     *     and ext_vertragpos= %s
     *   ', 
     *   'thekid.de', 
     *   2828822,
     *   NULL
     * );
     * </pre>
     *
     * => Um das Quoten von Strings muss sich nicht mehr gekmmert werden!
     * => NULL wird automatisch zu NULL (bei String-Feldern)
     *
     * @access  private
     * @param   array args Die Argumente
     */
    function prepare($args) {
      $sql= $args[0];
      if (sizeof($args)<= 1) return $sql;
      $j= 0;    
      $sql= $tok= strtok($sql, '%');
      while (++$j && $tok= strtok('%')) {
        $arg= (is_object($args[$j]) && method_exists($args[$j], 'toString') 
          ? $args[$j]->toString()
          : $args[$j]
        );
        switch ($tok{0}) {
          case 'd': $sql.= ($arg === NULL ? 'NULL' : intval($arg)).substr($tok, 1); break;
          case 'c': $sql.= ($arg === NULL ? 'NULL' : $arg).substr($tok, 1); break;
          case 's': $sql.= ($arg === NULL ? 'NULL' : '"'.str_replace('"', '""', $arg).'"').substr($tok, 1); break;
          case 'l': $sql.= ($arg === NULL ? 'NULL' : '"'.str_replace('"', '""', $arg).'%"').substr($tok, 1); break;
          default: $sql.= '%'.$tok; $j--;
        }
      }
      return $sql;
    }
    
    function setBuffering($b) {
      $this->_buffering= $b;
    }
    
    /**
     * Query-Funktion. Connected, falls ntig
     *
     * @access  public
     * @param   string sql Der abzusetzende SQL-Query-String
     * @return  bool result Query-Ergebnis
     * @throws  SQLException, wenn der Query schiefgeht
     */
    function query() {
      $args= func_get_args();
      $this->lengths= $this->fields= NULL;
	  <commit_msg>- neue %-Anweisungen<commit_after><?php
/**
 *
 * $Id$
 */
  
  uses(
    'rdbms.SQLException',
    'util.Date',
    'util.log.Logger'
  );
  
  /**
   * Ergnzt bz_id-Felder durch bz_description, Datumsangaben durch unix-Timestamp
   *
   * @purpose Datenbank-Klasse fr Schlund-Datenbanken
   * @example sybase.ini
   * @see     http://manuals.sybase.com/
   * @see     http://curry.schlund.de/datenbank/MIGRAENE.html#bearbeitungszustand
   */
  class SPSybase extends Object {
    var 
      $handle= NULL,
      $host, 
      $user, 
      $pass, 
      $db, 
      $field_map= array(),
      $last_affected_rows= -1, 
      $last_num_rows= -1,
      $transaction= 0;
   
    // Do buffered queries? Default: TRUE
    var
      $_buffering= TRUE;
   
    // Logger
    var
      $log;
	  
    var
      $fields	= NULL,
      $lengths	= NULL;
 
    /**
     * Constructor
     */
    function __construct($params) {
      $l= &Logger::getInstance();
      $this->log= &$l->getCategory($this->getName());
      parent::__construct($params);
    }
    
    /**
     * Konnektieren
     *
     * @access  public
     * @return  resource Datenbank-Handle
     * @throws  SQLException, wenn kein Connect zustande kommt
     */
    function connect() {
      $this->handle= sybase_connect($this->host, $this->user, $this->pass);
      if (FALSE === $this->handle) return throw(new SQLException(sprintf(
        'Unable to connect to %s@%s',
        $this->user,
        $this->host
      )));
      return $this->handle;
    }

    /**
     * Datenbank auswhlen
     *
     * @access  public
     * @param   string db default NULL Auszuwhlende Datenbank (wenn NULL, $this->db)
     * @return  bool result Datenbank ausgewhlt?
     */    
    function select_db($db= NULL) {
      if(!is_null($db)) $this->db= $db;
      return @sybase_select_db($this->db, $this->handle);
    }
    
    /**
     * Private Helper-Funktion, ermglicht solcherlei Aufrufe
     *
     * <pre>
     * $qrh= $dbo->query('
     *   select 
     *     domain_id 
     *   from 
     *     domain 
     *   where 
     *     domainname = %s 
     *     and adminc= %d
     *     and ext_vertragpos= %s
     *   ', 
     *   'thekid.de', 
     *   2828822,
     *   NULL
     * );
     * </pre>
     *
     * => Um das Quoten von Strings muss sich nicht mehr gekmmert werden!
     * => NULL wird automatisch zu NULL (bei String-Feldern)
     *
     * @access  private
     * @param   array args Die Argumente
     */
    function prepare($args) {
      $sql= $args[0];
      if (sizeof($args)<= 1) return $sql;
      $j= 0;    
      $sql= $tok= strtok($sql, '%');
      while (++$j && $tok= strtok('%')) {
        $arg= (is_object($args[$j]) && method_exists($args[$j], 'toString') 
          ? $args[$j]->toString()
          : $args[$j]
        );
        switch ($tok{0}) {
          case 'd': $sql.= ($arg === NULL ? 'NULL' : intval($arg)).substr($tok, 1); break;
          case 'c': $sql.= ($arg === NULL ? 'NULL' : $arg).substr($tok, 1); break;
          case 's': $sql.= ($arg === NULL ? 'NULL' : '"'.str_replace('"', '""', $arg).'"').substr($tok, 1); break;
          case 'l': $sql.= ($arg === NULL ? 'NULL' : '"'.str_replace('"', '""', $arg).'%"').substr($tok, 1); break;
          case 'u': $sql.= ($arg === NULL ? 'NULL' : '"'.date ('Y-m-d h:iA', $arg).'"').substr($tok, 1); break;
          case 'f': $sql.= ($arg === NULL ? 'NULL' : floatval ($arg)).substr($tok, 1); break;
          default: $sql.= '%'.$tok; $j--;
        }
      }
      return $sql;
    }
    
    function setBuffering($b) {
      $this->_buffering= $b;
    }
    
    /**
     * Query-Funktion. Connected, falls ntig
     *
     * @access  public
     * @param   string sql Der abzusetzende SQL-Query-String
     * @return  bool result Query-Ergebnis
     * @throws  SQLException, wenn der Query schiefgeht
     */
    function query() {
      $args= func_get_args();
      $this->lengths= $this->fields= NULL;
	  
{'fraction_non_alphanumeric': 0.17307443365695793, 'fraction_numerical': 0.004919093851132686, 'mean_word_length': 1.9409973353635326, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '919435', 'n_tokens_mistral': 2780, 'n_tokens_neox': 2691, 'n_words': 586}