I have a function that allows me to perform sql queries depending on what type of SQL server the user has chosen. The function works fine getting a single row of data, but it never returns more than 1 row.
This is the sql function:
function sqlQuery($query){
switch (DATABASE_TYPE) {
case 'MYSQL':
// Establishes a connection to the database.
$connection = mysql_connect(DATABASE_LOCATION, DATABASE_USERNAME, DATABASE_PASSWORD);
if(!$connection){
throw new Exception(mysql_error(), 1);
}
mysql_select_db(DATABASE_NAME);
// Performs the query.
global $response;
$response = mysql_query($query);
if(!$response){
throw new Exception(mysql_error(), 1);
}
return mysql_fetch_array($response);
break;
}
}
And like I said above, this works just fine for single row queries, but I can't get any more.
If I try this:
$sql = "SELECT * FROM test"
$rows = sqlQuery($sql);
foreach($rows as $value){
echo($value);
}
If row 1 of test is 1 | Hello | PHP
it would echo 11HelloHelloPHPPHP