Skip to content

Commit

Permalink
Add debug pgsql
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenanhung committed Nov 14, 2024
1 parent 0701464 commit 28297c8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/controllers/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,33 @@ public function php()
{
phpinfo();
}

protected function pgsql_function_check($function_name = 'pg_connect'): string
{
if (function_exists($function_name)) {
return "function " . $function_name . " is already";
} else {
return "function " . $function_name . " is not available";
}
}

public function pgsql_check()
{
$data = array(
'function_check' => array(
'pg_connect' => $this->pgsql_function_check('pg_connect'),
'pg_close' => $this->pgsql_function_check('pg_close'),
'pg_query' => $this->pgsql_function_check('pg_query'),
'pg_escape_string' => $this->pgsql_function_check('pg_escape_string'),
'pg_last_error' => $this->pgsql_function_check('pg_last_error'),
)
);

$this->output
->set_status_header()
->set_content_type('application/json', 'utf-8')
->set_output(json_encode($data, JSON_PRETTY_PRINT))
->_display();
exit;
}
}

0 comments on commit 28297c8

Please sign in to comment.