src/SudoBible.php
protected function queryFiles($strAction)
	{
		if (!in_array($strAction, ['create', 'insert', 'drop']))
			throw new Exception('Invalid parameter "' . $strAction . '" sent to SudoBible::queryFiles()');

		$strPath = 'queries/' . $this->dbType . '/' . $strAction;
		foreach (scandir($strPath) as $strFilename) {

			// Only run SQL files (eliminates ., .., and subdirs)
			// Using in_array() in case DBs other than SQL are supported in the future.
			if (in_array(substr($strFilename, -4), ['.sql'])) {
				$mResult = $this->db->query(file_get_contents($strPath . '/' . $strFilename));

				// Check success if creating or dropping
				if ('insert' !== $strAction && true !== $mResult) {
					throw new Exception('Unable to ' . $strAction . ' table in ' . $strFilename
						. ' - please ensure your DB user has the right permissions.');
				}
			}
		}
	}
protected function queryFiles($strAction)
	{
		if (!in_array($strAction, ['create', 'insert', 'drop']))
			throw new Exception('Invalid parameter "' . $strAction . '" sent to SudoBible::queryFiles()');

		$strPath = 'queries/' . $this->dbType . '/' . $strAction;
		foreach (scandir($strPath) as $strFilename) {

			// Only run SQL files (eliminates ., .., and subdirs)
			// Using in_array() in case DBs other than SQL are supported in the future.
			if (in_array(substr($strFilename, -4), ['.sql'])) {
				$mResult = $this->db->query(file_get_contents($strPath . '/' . $strFilename));

				// Check success if creating or dropping
				if ('insert' !== $strAction && true !== $mResult) {
					throw new Exception('Unable to ' . $strAction . ' table in ' . $strFilename
						. ' - please ensure your DB user has the right permissions.');
				}
			}
		}
	}
protected function queryFiles ( $ strAction ) { if ( ! in_array ( $ strAction , [ 'create' , 'insert' , 'drop' ] ) ) throw new Exception ( 'Invalid parameter "' . $ strAction . '" sent to SudoBible::queryFiles()' ) ; $ strPath = 'queries/' . $ this -> dbType . '/' . $ strAction ; foreach ( scandir ( $ strPath ) as $ strFilename ) { // Only run SQL files (eliminates ., .., and subdirs) // Using in_array() in case DBs other than SQL are supported in the future. if ( in_array ( substr ( $ strFilename , - 4 ) , [ '.sql' ] ) ) { $ mResult = $ this -> db -> query ( file_get_contents ( $ strPath . '/' . $ strFilename ) ) ; // Check success if creating or dropping if ( 'insert' !== $ strAction && true !== $ mResult ) { throw new Exception ( 'Unable to ' . $ strAction . ' table in ' . $ strFilename . ' - please ensure your DB user has the right permissions.' ) ; } } } }
Run the query files in a given directory.

@param string $strAction create, insert, or drop
@throws Exception
Run the query files in a given directory .