Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jack2jm/66a6fac04c73a452c009a75bc06da0e2 to your computer and use it in GitHub Desktop.

Select an option

Save jack2jm/66a6fac04c73a452c009a75bc06da0e2 to your computer and use it in GitHub Desktop.

Revisions

  1. jack2jm renamed this gist Jul 26, 2024. 1 changed file with 0 additions and 0 deletions.
  2. jack2jm revised this gist Jul 26, 2024. 1 changed file with 23 additions and 1 deletion.
    24 changes: 23 additions & 1 deletion Microsoft azure database use into windows or linux-ubuntu
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    Ubuntu
    *************************
    If driver not found error then
    -> If php version is 8.2, else you can change 8.2 to your preffered php version on server
    -> Run below command.
    @@ -14,4 +15,25 @@ Ubuntu
    Install Microsoft odbc driver
    Copy and paste code from this link - https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=ubuntu18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline
    or below command is there.



    Windows
    ******************
    Download required drivers
    ---------
    1. Download ODBC driver
    https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16#download-for-windows
    2. Download required php mysql driver for microsoft windows.
    2.1. download driver from here
    https://www.microsoft.com/en-us/download/details.aspx?id=20098
    2.2 Extract and Install: Extract the downloaded files.
    Copy the php_sqlsrv_x64.dll and php_pdo_sqlsrv_64.dll files to your PHP extension directory (usually something like C:\xampp\php\ext).
    2.3 Open the php.ini file located in the C:\xampp\php directory.
    extension="D:\xamppppppp_82\php\ext\php_sqlsrv_82_ts_x64.dll"
    extension="D:\xamppppppp_82\php\ext\php_pdo_sqlsrv_82_ts_x64.dll"

    or change name to dll file like below short name and update ini file like:
    extension=php_sqlsrv.dll
    extension=php_pdo_sqlsrv.dll
    2.4 Restart Apache:
    Start or restart the Apache server from the XAMPP Control Panel to apply the changes.
  3. jack2jm revised this gist Jul 26, 2024. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Erros resolve
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,11 @@
    //insert entries
    SET IDENTITY_INSERT roles OFF

    For Laravel seeders
    ----
    Laravel Seeders

    If you're inserting data through Laravel Seeders, ensure you're not manually setting the id field. (remove id from seeders)

    2.

  4. jack2jm revised this gist Jul 26, 2024. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions Erros resolve
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    1. SQLSTATE[23000]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Cannot insert explicit value for identity column in table 'roles'
    SET IDENTITY_INSERT roles ON
    //insert entries
    SET IDENTITY_INSERT roles OFF


    2.

  5. jack2jm revised this gist Jul 26, 2024. 2 changed files with 24 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion Microsoft azure database use into windows or linux-ubuntu
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,9 @@ Ubuntu
    sudo pecl install -f sqlsrv
    sudo pecl install -f pdo_sqlsrv
    sudo phpenmod -v 8.2 sqlsrv pdo_sqlsrv
    sudo service apache2 restart
    sudo service apache2 restart

    Install Microsoft odbc driver
    Copy and paste code from this link - https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=ubuntu18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline
    or below command is there.

    18 changes: 18 additions & 0 deletions ODBC driver
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    if ! [[ "18.04 20.04 22.04 23.04" == *"$(lsb_release -rs)"* ]];
    then
    echo "Ubuntu $(lsb_release -rs) is not currently supported.";
    exit;
    fi

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc

    curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list

    sudo apt-get update
    sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
    # optional: for bcp and sqlcmd
    sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
    echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
    source ~/.bashrc
    # optional: for unixODBC development headers
    sudo apt-get install -y unixodbc-dev
  6. jack2jm created this gist Jul 26, 2024.
    12 changes: 12 additions & 0 deletions Microsoft azure database use into windows or linux-ubuntu
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    Ubuntu
    If driver not found error then
    -> If php version is 8.2, else you can change 8.2 to your preffered php version on server
    -> Run below command.
    sudo apt install php8.2-dev
    sudo update-alternatives --set php /usr/bin/php8.2
    sudo update-alternatives --set php-config /usr/bin/php-config8.2
    sudo update-alternatives --set phpize /usr/bin/phpize8.2
    sudo pecl install -f sqlsrv
    sudo pecl install -f pdo_sqlsrv
    sudo phpenmod -v 8.2 sqlsrv pdo_sqlsrv
    sudo service apache2 restart