src/Db.php
protected function _safe($table, $array) {
		if (!isset($this->cache[$table])) {
			$this->connect();
			
			$query = "SHOW COLUMNS FROM `$table`";
			if ($this->config['driver'] == 'sqlite') {
				$query = 'PRAGMA table_info(`'.$table.'`);';
			}
			$sth = $this->prepare($query);
			$sth->execute();
			$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
			
			foreach ($result as $row) {
				if ($this->config['driver'] == 'sqlite') {
					$columns[] = $row['name'];
				} else {
					$columns[] = $row['Field'];
				}
			}
			$this->cache[$table] = $columns;
		}
		
		// remove all not existent keys
		foreach (array_keys($array) as $key) {
			if (!in_array($key, $this->cache[$table])) unset ($array[$key]);
		}
		
		return $array;
	}
protected function _safe($table, $array) {
		if (!isset($this->cache[$table])) {
			$this->connect();
			
			$query = "SHOW COLUMNS FROM `$table`";
			if ($this->config['driver'] == 'sqlite') {
				$query = 'PRAGMA table_info(`'.$table.'`);';
			}
			$sth = $this->prepare($query);
			$sth->execute();
			$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
			
			foreach ($result as $row) {
				if ($this->config['driver'] == 'sqlite') {
					$columns[] = $row['name'];
				} else {
					$columns[] = $row['Field'];
				}
			}
			$this->cache[$table] = $columns;
		}
		
		// remove all not existent keys
		foreach (array_keys($array) as $key) {
			if (!in_array($key, $this->cache[$table])) unset ($array[$key]);
		}
		
		return $array;
	}
protected function _safe ( $ table , $ array ) { if ( ! isset ( $ this -> cache [ $ table ] ) ) { $ this -> connect ( ) ; $ query = "SHOW COLUMNS FROM `$table`" ; if ( $ this -> config [ 'driver' ] == 'sqlite' ) { $ query = 'PRAGMA table_info(`' . $ table . '`);' ; } $ sth = $ this -> prepare ( $ query ) ; $ sth -> execute ( ) ; $ result = $ sth -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; foreach ( $ result as $ row ) { if ( $ this -> config [ 'driver' ] == 'sqlite' ) { $ columns [ ] = $ row [ 'name' ] ; } else { $ columns [ ] = $ row [ 'Field' ] ; } } $ this -> cache [ $ table ] = $ columns ; } // remove all not existent keys foreach ( array_keys ( $ array ) as $ key ) { if ( ! in_array ( $ key , $ this -> cache [ $ table ] ) ) unset ( $ array [ $ key ] ) ; } return $ array ; }
Removes all keys from an array which are not available in the given table

@param	string $table The table name to compare the array with
@param	array $array An associative array: column_name > value
@return	array
Removes all keys from an array which are not available in the given table