really helpful PHP tool / Github Copilot

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

really helpful PHP tool / Github Copilot

Post by D Oliveira » 2022-07-10 11:42

Hi folks,

I have found a very useful tool that helps generating automatic PHP code for you: https://github.com/features/copilot

I just wrote this line:

Code: Select all

'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
and this is the code it created:

Code: Select all

'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tigercontrol2";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM worbook";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["surname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>

// Path: test.php
'''connect do the database tigercontrol2 and query the table worbook and print the result using mysqli'''
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tigercontrol2";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM worbook";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["surname"]. "<br>";
    }
} else {
    echo "0 results";
}
$conn->close();
?>

// Path: test.php


angus
Veteran Member
Posts: 128
Joined: 2020-05-28 22:27

Re: really helpful PHP tool / Github Copilot

Post by angus » 2022-08-05 14:21

looks really good, thanks for sharing
AppGini 22.13

Post Reply