Reputation: 387
during I`m trying to get data from oracle 8g, I get oci_connect(): ORA-12170: TNS:Connect timeout. When I am performing few queries everything is rightly, but if I am trying to get slightly much queries I get mentioned error. Interesting fact, if I am adding sleep(1) php function it resolves problem, but caused to take much time for.
Warning: oci_connect(): ORA-12170: TNS:Connect timeout occurred in C:\apache\Apache24\htdocs\statistic\src\OracleRequest.php on line 105
Fatal error: ORA-12170: TNS:Connect timeout occurred in C:\apache\Apache24\htdocs\statistic\src\OracleRequest.php on line 108
Queries are simple, here is for instance
public function getCountOfEntriesByEmployee($surname, $type_of_document)
{
$conn = oci_connect("system", "manager", $this->dsn);
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
if($type_of_document == self::TYPE_OF_DOCUMENT["COMMON_INCOME"]) {
$common_income_documents_by_employee = oci_parse($conn,
"SELECT COUNT(num_card) FROM OFFICE_DOC_IN_CARDS
WHERE DCUS_CODE = 1
and YEAR_CARD = 2020
and TYPE_CARD = " . $type_of_document . "
and DATE_IN = to_date(to_char(SYSDATE, 'yyyy-mm-dd'), 'yyyy-mm-dd')
and SHORT_CONTENT NOT LIKE '%test db%'
and (
(CONCAT(SHORT_CONTENT, SHORT_CONTENT2) like " . "'%*" . mb_convert_encoding($surname, "CP1251") . "%')
or
(CONCAT(SHORT_CONTENT, SHORT_CONTENT2) like " . "'% * " . mb_convert_encoding($surname, "CP1251") . "%')
)"
);
oci_execute($common_income_documents_by_employee);
$data = oci_fetch_row($common_income_documents_by_employee)[0];
oci_free_statement($common_income_documents_by_employee);
oci_close($conn);
return $data;
Thanks a lot everyone!
Upvotes: 0
Views: 1032
Reputation: 580
This is not a PHP issue - issue is result of slow network or other Network related issues. please try to use
SQLNET.INBOUND_CONNECT_TIMEOUT
SQLNET.SEND_TIMEOUT
SQLNET.RECV_TIMEOUT
Inside
$ORACLE_HOME/network/admin/sqlnet.ora
on Oracle Client used by PHP
Upvotes: 1