tyrola/sdc

This package is abandoned and no longer maintained. No replacement package was suggested.

A very simple mysqli database lib

dev-master / 1.0.x-dev 2017-12-26 12:15 UTC

This package is not auto-updated.

Last update: 2020-08-21 18:07:54 UTC


README

Simple PHP Database Connector

  • works with mysqli
  • very simple ;)

query() Example:

<?php

$db = new mysqli("localhost", "dbUser", "dbPassword", "dbName");
$sdc = new DatabaseConnector($db);

$name = "Franz";

$sql = "UPDATE
            `table`
        SET
            `col` = '1'
        WHERE
            `name` = ".$sdc->quote($name").";";

$sdc->query($sql);

getAll() Example:

<?php

$db = new mysqli("localhost", "dbUser", "dbPassword", "dbName");
$sdc = new DatabaseConnector($db);

$sql = "SELECT
            `name`
        FROM
            `table`
        LIMIT
            `10`";

$entries = $sdc->getAll($sql);

foreach ($entries as $entry) {
    echo $entry["name"];
}

getFirst() Example:

<?php

$db = new mysqli("localhost", "dbUser", "dbPassword", "dbName");
$sdc = new DatabaseConnector($db);

$sql = "SELECT
            `name`
        FROM
            `table`
        LIMIT
            `10`";

$entry = $sdc->getFirst($sql);

echo $entry["name"];

getOne() Example:

<?php

$db = new mysqli("localhost", "dbUser", "dbPassword", "dbName");
$sdc = new DatabaseConnector($db);

$sql = "SELECT
            `name`
        FROM
            `table`
        WHERE
            `id` = '1'";

$name = $sdc->getOne($sql);

echo $name;