In addition to the other answers, you should combine the settings into a single ALTER SESSION
statement:
ALTER SESSION SET NLS_TERRITORY = 'CIS' NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' NLS_DATE_LANGUAGE = 'RUSSIAN';
This is particularly recommended if you are executing the statement from PHP (and not just via a PL/SQL block or logon trigger) since it reduces the number of round-trips between PHP and the database, and can have a significant performance benefit.
For discussion of using triggers, see p 304 of the free Oracle PDF The Underground PHP and Oracle Manual.
If you do need to execute the statement from PHP, and have other SQL commands that are executed at logon, wrap them all in an anonymous PL/SQL block:
begin
execute immediate
'alter session set nls_date_format = ''YYYY-MM-DD'' nls_language = AMERICAN';
-- other SQL statements could be put here
end;
This can be executed with one oci_parse()
call, so it only needs one round-trip.