Connecting to SteemSQL database using PHP7

in #utopian-io7 years ago

Github project:
https://github.com/Bulletproofmonk/PHPSteemSQL

File edited for this commit:
PHP7 sample code for connecting to SteemSQL
Readme file

Links to each commit:
Added SteemSQL connection code for PHP7
Edit Readme

The PHPSteemSQL project on Github contains code samples for querying the SteemSQL database using PHP. PHP programmers who are not familiar with the Microsoft SQL database which SteemSQL is based on may have trouble connecting to the database using the PHP extensions without a reference point. The purpose of this project is to provide PHP programmers with sample codes to help them connect and query the SteemSQL database.

Previously, I have provided the PHP5 code for connecting and querying the database in this article. In this development update, I have added the code for connecting to SteemSQL using PHP7, as well as updated the Readme.md file to reflect this change.

The main differences between the connection files for PHP5 and PHP7 are summed up in the table below:

DifferencePHP5PHP7
Extension required mssql pdo_dblib
Syntax used Procedural Object Oriented

The new extension used in PHP7 called PDO_DBLIB enables access to Microsoft SQL Server databases via PHP using the PHP Data Objects (PDO) interface. The mssql extension used in PHP5 is no longer available for PHP7.

Make sure you enable the required extensions for the relevant PHP version in order for it to work (see PHP5 article for instructions on how to enable PHP extensions with web hosts that use the CPanel interface and how I managed to unblock outgoing connections to a specific port).

Screenshot of logged in session of Github to prove I'm the owner:

image.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

恭喜你!您的这篇文章入选 @justyy 今日榜单 【优秀被错过的文章】, 请继续努力!若您不喜欢,请回复 STOP,谢谢。

Congratulations! This post has been selected by @justyy as today's 【Good Posts You May Miss】, Steem On! Reply STOP if don't want to see this. Thanks.

能有yy支持就夠了。

你这篇写得不错,不过按规则的确过不了, 因为 steemsql 不是开源,而且这应该算 tutorial 会好一些。

沒事,多謝鼓勵。都是在為大眾服務,錢無所謂。

Keep it up the great work going, although this is too technical for me but your motto behind it is quite obvious.

Your contribution cannot be approved yet because it is too basic and also SteemSQL is not open source.

See the Utopian Rules. Please edit your contribution to reapply for approval.

You may edit your post here, as shown below:

You can contact us on Discord.
[utopian-moderator]

Hi @codingdefined thank you for reviewing this submission. While SteemSQL is not open source, it is used in open source projects which have been approved many times on Utopoian, such as SteemSQL wrapper (https://utopian.io/project/sihaelov/steemsql-wrapper/github/114453017/all).
This code that I have provided might look simple, but it is asked by many programmers on the steemit.chat steemSQL channel, as @arcange and @justyy will tell you, how many times people ask this question, how to connect to SteemSQL using PHP7. This code takes a long time to figure out without a reference point and it is a good resource for future open source PHP developers planning on using SteemSQL as the backend. If I provided a complex example here it will lose the purpose of this project, which is to help PHP programmers get started on SteemSQL.
Thank you for your consideration & Merry Christmas to you :)

p.s. If you google SteemSQL PHP7, this article is the most relevant in the search result.

Hi @magicmonk, I have talked about this with my supervisor and we still think it is too short as a dev contribution.

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 60122.55
ETH 3199.29
USDT 1.00
SBD 2.43