<commit_before><?php
  /**
   * AModel class
   * 
   * @category kernel
   * @author <NAME> <<EMAIL>>
   */

  class AModel
  {
    /**
	 * Database driver
	 *
	 * @access private
	 *
	 */
    private static $driver = null;

	/**
	 * Data set
	 *
	 * @access private
	 *
	 */
	private $data;
	
	/**
	 * Constructor
	 *
	 */
	function __construct()
	{
	  if( null == self::$driver ){
		# Load configurations
		require( AEOLUS_HOME.'/etc/driver.php');

		# Load driver class
        A::ld( "db/$driver.php");
	    self::$driver = new $driver();
	    
		$this->data = array( 'result' => false,
	                       'affected' => 0,
						   'lastInsertId' => 0,
						   'set' => array()
						  );
	  }
	}

	/**
	 * Insert data to database
	 *
	 */
	public final function insert($sql)
	{
	  $result = self::$driver->query($sql);
	  
	  if($result){
	    $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
	    $this->data['lastInsertId'] = mysql_insert_id();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Update database tables
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result array
	 *
	 */
	public final function update($sql)
	{
	  if(self::$driver->query($sql)){
        $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Delete data from database tables
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result data
	 *
	 */
	public final function delete($sql)
	{
	  if(self::$driver->query($sql)){
        $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Select data from database
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result data
	 *
	 */
	public final function select($sql)
	{			
	  if($result = self::$driver->query($sql)){	        
	    $this->data['affected'] = mysql_num_rows($result);
	      
	    if( $this->data['affected'] > 0 ){
	      $this->data['result'] = true;
		  $this->data['set'] = array();
	      while( $dataset = mysql_fetch_assoc($result) ){
	        $this->data['set'][] = $dataset;
	      }
	    }
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Escape a variable
	 * 
	 * @access public
	 * @param string $value the string to be escaped
	 * @return string $escaped the escaped string
	 *
	 */
	public final function escape($value)
	{
	  return mysql_real_escape_string($value,self::$driver->getRes());
	}	<commit_msg>Fixed a bug in AModel::select (result should be true after the SQL query successfully executed)<commit_after><?php
  /**
   * AModel class
   * 
   * @category kernel
   * @author <NAME> <<EMAIL>>
   */

  class AModel
  {
    /**
	 * Database driver
	 *
	 * @access private
	 *
	 */
    private static $driver = null;

	/**
	 * Data set
	 *
	 * @access private
	 *
	 */
	private $data;
	
	/**
	 * Constructor
	 *
	 */
	function __construct()
	{
	  if( null == self::$driver ){
		# Load configurations
		require( AEOLUS_HOME.'/etc/driver.php');

		# Load driver class
        A::ld( "db/$driver.php");
	    self::$driver = new $driver();
	    
		$this->data = array( 'result' => false,
	                       'affected' => 0,
						   'lastInsertId' => 0,
						   'set' => array()
						  );
	  }
	}

	/**
	 * Insert data to database
	 *
	 */
	public final function insert($sql)
	{
	  $result = self::$driver->query($sql);
	  
	  if($result){
	    $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
	    $this->data['lastInsertId'] = mysql_insert_id();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Update database tables
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result array
	 *
	 */
	public final function update($sql)
	{
	  if(self::$driver->query($sql)){
        $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Delete data from database tables
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result data
	 *
	 */
	public final function delete($sql)
	{
	  if(self::$driver->query($sql)){
        $this->data['result'] = true;
	    $this->data['affected'] = mysql_affected_rows();
		$this->data['set'] = array();
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Select data from database
	 *
	 * @access public
	 * @param string $sql SQL query string
	 * @return array $data the result data
	 *
	 */
	public final function select($sql)
	{			
	  if($result = self::$driver->query($sql)){	        
	    $this->data['result'] = true;
	    $this->data['affected'] = mysql_num_rows($result);
	      
	    if( $this->data['affected'] > 0 ){
		  $this->data['set'] = array();
	      while( $dataset = mysql_fetch_assoc($result) ){
	        $this->data['set'][] = $dataset;
	      }
	    }
	  }
	  
	  return $this->data;
	}
	
	/**
	 * Escape a variable
	 * 
	 * @access public
	 * @param string $value the string to be escaped
	 * @return string $escaped the escaped string
	 *
	 */
	public final function escape($value)
	{
	  return mysql_real_escape_string($value,self::$driver->getRes());
	}	
{'fraction_non_alphanumeric': 0.17420066152149946, 'fraction_numerical': 0.0011025358324145535, 'mean_word_length': 2.4646721833227243, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 69, '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': '198061', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1740, 'n_words': 414}