Featured Posts

[Informasi Harga][feat1]

Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

April 02, 2023

 mysql -u root -p

Enter password: <enter password>
mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
mysql>FLUSH PRIVILEGES;
mysql>exit

Change Database Character Set in Oracle 12c

February 16, 2023

 Change Database Character Set in Oracle 12c



For the previous version, the official method for character set is using CSSCAN and ASALTER utility. So, from Oracle Database 12c, Oracle introduced a new tool called Database Migration Assistant for Unicode referred in Doc ID 1272374.1. But we have two cases; the first one is applied only if the new character set is a strict superset of the current character set. If not, you will have the “ORA-12712: new character set must be a superset of old character set” error. And then Oracle introduces the “INTERNAL_USE” option. The two option avoid to you to use a traditional method by using Export/Import or Data Pump Utility.
To change the Character set, you use the statement as follow:
ALTER DATABASE CHARACTER SET new_character_set;
E.g.: ALTER DATABASE CHARACTER SET WE8MSWIN1252;
Note: You must notice that this action cannot be rolled back, but you re apply the same method to back to the previous character set. However, it’s advised to do a full backup of your database before applying the change.
We want now to change the NLS_CHARACTERSET from WE8MSWIN1252 to AL32UTF8;
SQL> select * from NLS_DATABASE_PARAMETERS
  2  where parameter='NLS_CHARACTERSET';
PARAMETER                      VALUE
----------------------------- ----------------------------------------
NLS_CHARACTERSET               WE8MSWIN1252

To change the database character set, perform the following steps:
1.       Properly Shut down the database:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
2.       Start the Database as restricted session

SQL> startup restrict
ORACLE instance started.

Total System Global Area 5167382528 bytes
Fixed Size                  3842808 bytes
Variable Size            1090522376 bytes
Database Buffers         4060086272 bytes
Redo Buffers               12931072 bytes
Database mounted.
Database opened.
3.       Change the Character Set
SQL> alter database character set AL32UTF8;
alter database character set AL32UTF8
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
Don’t worry, in our case, the new Character Set is not a superset of the old one. In this case we must use the below:
SQL> alter database character set INTERNAL_USE AL32UTF8;
Database altered.
4.       Once the Character Set is changed, you must properly restart the database.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 5167382528 bytes
Fixed Size                  3842808 bytes
Variable Size            1090522376 bytes
Database Buffers         4060086272 bytes
Redo Buffers               12931072 bytes
Database mounted.
Database opened.

5.       Verify that the new Character set is applied
SQL> select * from NLS_DATABASE_PARAMETERS
  2  where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
AL32UTF8

Sort array of objects by one property

February 15, 2023

 Use usort, here's an example adapted from the manual:

function cmp($a, $b) {
    return strcmp($a->name, $b->name);
}

usort($your_data, "cmp");

You can also use any callable as the second argument. Here are some examples:

  • Using anonymous functions (from PHP 5.3)

      usort($your_data, function($a, $b) {return strcmp($a->name, $b->name);});
    
  • From inside a class

      usort($your_data, array($this, "cmp")); // "cmp" should be a method in the class
    
  • Using arrow functions (from PHP 7.4)

      usort($your_data, fn($a, $b) => strcmp($a->name, $b->name));
    

Also, if you're comparing numeric values, fn($a, $b) => $a->count - $b->count as the "compare" function should do the trick, or, if you want yet another way of doing the same thing, starting from PHP 7 you can use the Spaceship operator, like this: fn($a, $b) => $a->count <=> $b->count.

How to configure PostgreSQL to accept all incoming connections WINDOWS

January 26, 2023

1. SETTING PG_HBA.CONF

Just use 0.0.0.0/0.

host    all             all             0.0.0.0/0            md5

Make sure the listen_addresses in postgresql.conf (or ALTER SYSTEM SET) allows incoming connections on all available IP interfaces.

listen_addresses = '*'

After the changes you have to reload the configuration. One way to do this is execute this SELECT as a superuser.

SELECT pg_reload_conf();

Note: to change listen_addresses, a reload is not enough, and you have to restart the server.


2. RESTART POSTGRES SERVICES

  • Press Windows key + R, 'RUN' box will appear.
  • Type services. ...
  • Services window will open, search for postgresql-13. ...
  • Right-click on the postgresql-13 and click on the restart option.
  • The services will restart now.
  • This is how we can restart PostgreSQL services in windows machines.
3. Open Windows Firewall Port
AND ADD POSTGRESQL INTO WINDOWS FIREWALL INBOUNDS RULE

Does your PostgreSQL database run on a Windows server with firewall enabled?

In this case you can just turn off the firewall for a first test in Control Panel -> Systems and Security -> Windows Firewall -> Turn Windows Firewall on or off.

As an alternative you can go to Control Panel -> Systems and Security ->  Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule:

  • Rule Type: Port 
  • TCP or UDP: TCP
  • Specific local ports: 5432
  • Action: Allow the connection
  • When does this rule apply: Domain, Private and Public (all three checked)
  • Name: "PostgreSQL Incoming"

Array and string offset access syntax with curly braces is deprecated

September 12, 2022

 It's really simple to fix the issue, however keep in mind that you should fork and commit your changes for each library you are using in their repositories to help others as well.

Let's say you have something like this in your code:

$str = "test";
echo($str{0});

since PHP 7.4 curly braces method to get individual characters inside a string has been deprecated, so change the above syntax into this:

$str = "test";
echo($str[0]);

Fixing the code in the question will look something like this:

public function getRecordID(string $zoneID, string $type = '', string $name = ''): string
{
    $records = $this->listRecords($zoneID, $type, $name);
    if (isset($records->result[0]->id)) {
        return $records->result[0]->id;
    }
    return false;
}

FIX ERROR : Declaration of MX_Loader should be compatible with CI_Loader After Update To PHP 7

September 12, 2022
After updating 5.6 to PHP 7. I was using HMVC implementation of CodeIgniter and PHP upgrade 
Here I have fixed all issue. Bellow I have given:


1.third party\MX\Lang.php
line=38
public function load($langfile ='', $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')

2.third party\MX\Loader.php
line=107
public function helper($helper = array())

3.third party\MX\Loader.php
line=124
public function helpers($helpers = array())

4.third party\MX\Loader.php
line=142
public function library($library = '', $params = NULL, $object_name = NULL)

5.third party\MX\Loader.php
line=131
public function language($langfile = array(), $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')

6.third party\MX\Loader.php
line=283
public function  &_ci_get_component($component)

Cara Install Firebird Di XAMPP PHP 7

September 12, 2022

Latar Belakang

Recent versions of PHP indeed no longer ship with the interbase package. Instead you can use the Firebird PHP driver, which is a fork and continued development of the interbase package.


1.  Download interbase.dll di link ini

Interbase.dll

2. Ekstrak file lalu pindahkahn ke c://xampp/php/ext

3. Selesai

Powered by Blogger.