public static function run($query, $params=array()) {
		
		$self = static::getInstance();
		
		$self->openConnection();
		
		$ret = NULL;
		
		try {
			
			// prepare query
			$stat = $self->handler->prepare($query);

			// bind parameters
			$stat->execute((array)$params);

			// count affected rows
			$affected = $stat->rowCount();
			
		} catch (\PDOException $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			
			switch ($e->getCode()) {
				
				// integrity constraint violation
				/*
				 case '23000':
					 $message = 'Database integrity constraint violation';
					 break;
				 */
				default:
					$message = $e->getMessage();
					break;
			}
			
			$self->addError($message);
			
			$affected = 0;
			
		} catch (\Exception $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			$self->addError($e->getMessage());
			$affected = 0;
			
		}
		
		$stat->closeCursor();
		$self->logParamQuery($query, $affected, $params);
		
		return $affected;
			
	}
public static function run($query, $params=array()) {
		
		$self = static::getInstance();
		
		$self->openConnection();
		
		$ret = NULL;
		
		try {
			
			// prepare query
			$stat = $self->handler->prepare($query);

			// bind parameters
			$stat->execute((array)$params);

			// count affected rows
			$affected = $stat->rowCount();
			
		} catch (\PDOException $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			
			switch ($e->getCode()) {
				
				// integrity constraint violation
				/*
				 case '23000':
					 $message = 'Database integrity constraint violation';
					 break;
				 */
				default:
					$message = $e->getMessage();
					break;
			}
			
			$self->addError($message);
			
			$affected = 0;
			
		} catch (\Exception $e) {
			
			// logger
			$self->logParamQuery($query, 0, $params);
			$self->addError($e->getMessage());
			$affected = 0;
			
		}
		
		$stat->closeCursor();
		$self->logParamQuery($query, $affected, $params);
		
		return $affected;
			
	}
public static function run ( $ query , $ params = array ( ) ) { $ self = static :: getInstance ( ) ; $ self -> openConnection ( ) ; $ ret = NULL ; try { // prepare query
 $ stat = $ self -> handler -> prepare ( $ query ) ; // bind parameters
 $ stat -> execute ( ( array ) $ params ) ; // count affected rows
 $ affected = $ stat -> rowCount ( ) ; } catch ( \ PDOException $ e ) { // logger
 $ self -> logParamQuery ( $ query , 0 , $ params ) ; switch ( $ e -> getCode ( ) ) { // integrity constraint violation
 /*
				 case '23000':
					 $message = 'Database integrity constraint violation';
					 break;
				 */ default : $ message = $ e -> getMessage ( ) ; break ; } $ self -> addError ( $ message ) ; $ affected = 0 ; } catch ( \ Exception $ e ) { // logger
 $ self -> logParamQuery ( $ query , 0 , $ params ) ; $ self -> addError ( $ e -> getMessage ( ) ) ; $ affected = 0 ; } $ stat -> closeCursor ( ) ; $ self -> logParamQuery ( $ query , $ affected , $ params ) ; return $ affected ; }
Run a query with parameters and return TRUE if success. Support PDO parameters bind.

@param	string	SQL query to run.
@param	array	List of parameters to bind on the sql query.

@return	int		Number of affected items.
Run a query with parameters and return TRUE if success . Support PDO parameters bind .