I am working on a php method that giving me a syntax error on the third line of the method body. Commenting out the line does not do anything for me. Only by commenting out the entire method, does it actually go away. Am I missing something here?
public function get(Array $array) {
if(array_key_exists('data', $array)) {
if($array['data'] == '*') {
$fieldString = '*';
} else {
$fieldString = '';
for($x=0; $x < count($array['data']); $x++) {
if($x == count($array['data']) - 1 ) {
$fieldString .= $array['data'][$x].' ';
} else {
$fieldString .= $array['data'][$x].', ';
}
}
}
if(array_key_exists('table', $array)) {
$table = $array['table'];
}
if(array_key_exists('conditions', $array)) {
$condition = $array['conditions'];
$filter = '';
foreach($condition['cond'] as $cond) {
if(array_key_exists('type', $cond)) {
$filter .= $cond['type'].' ';
}
if(array_key_exists('field', $cond)) {
$filter .= $cond['field']. ' = ';
}
if(array_key_exists('value', $cond)) {
$filter .= $cond['value'];
}
}
}
$result = $mysqli->query("SELECT ".$fieldString." FROM ".$table. " ".$filter);
$response = $result->fetch_assoc();
if(!empty($response)) {
return $response;
} else {
echo 'response array from get model is empty';
}
} else {
echo '<h3>array data not set for _get() in model </h3>';
}
}