Download the PHP package atk14/dbmole without Composer

On this page you can find all versions of the php package atk14/dbmole. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbmole

DbMole

Build Status

DbMole provides basic functionality with database (Postgresql, MySQL or Oracle).

Basic usage

At first, define the global function dbmole_connection which returns connection to the database.

Only one Postgresql database is considered in this example.

function dbmole_connection($dbmole){
  return pg_connect("dbname=testing_database host=localhost user=test password=test123");
}

Instantiating

$dbmole = PgMole::GetInstance();

Selecting rows

$rows = $dbmole->selectRows("SELECT id,title,author FROM books");
foreach($rows as $row){
  echo $row["id"].": ".$row["title"]." (".$row["author"].")<br>";
}

Selecting single row

$row = $dbmole->selectRow("SELECT id,title,author FROM books WHERE id=123");
var_dump($row); // ["id" => "123", "title" => "Book Title", "author" => "John Doe"]

Selecting single value

$amount_of_books = $dbmole->selectSingleValue("SELECT COUNT(*) FROM books");
// or better
$amount_of_books = $dbmole->selectInt("SELECT COUNT(*) FROM books");

For selecting single values, there are also methods:

Safe binding of the query variables

$rows = $dbmole->selectRows("SELECT id,title,author FROM books WHERE UPPER(title) LIKE UPPER(:search)",[":search" => "%Goodies%"]);
$row = $dbmole->selectRow("SELECT id,title,author FROM books WHERE id=:id",[":id" => 123]);
$dbmole->doQuery("UPDATE books SET title=:title, author=:author WHERE id=:id",[":id" => 123,":title" => "Good Reading", ":author" => "Samantha Doe"]);

Limiting rows:

$rows = $dbmole->selectRows("SELECT * FROM employees",[],["limit" => "10", "offset" => 0]);
$rows = $dbmole->selectRows("SELECT * FROM employees WHERE created_at>=:date",[":date" => "2020-01-01"],["limit" => "10", "offset" => 0]);

Working in transaction

$dbmole->begin();

// do something with $dbmole

$dbmole->commit();

Working in transaction, avoiding unnecessary database connections

$dbmole->begin(["execute_after_connecting" => true]);

// do something with $dbmole and sometimes do nothig

if($dbmole->isConnected()){
  $dbmole->commit();
}

Insering new record into a table

$dbmole->insertIntoTable("books",[
  "id" => 123,
  "title" => "Nice Reading",
  "author" => "Brody Doe"
]);

Sequencies

$next_id = $dbmole->selectSequenceNextval("seq_book");
$curr_id = $dbmole->selectSequenceCurrval("seq_book");

Error callback

When an error occurs on SQL level, DbMole call the specified callback.

DbMole::RegisterErrorHandler("dbmole_error_handler");

function dbmole_error_handler($dbmole){
  echo "Dear visitor, unfortunately an error has occurred";
  $dbmole->sendErrorReportToEmail("[email protected]");
  $dbmole->logErrorReport();
  exit(1);
}

Installation

Just use the Composer:

composer require atk14/dbmole

Testing

Install required dependencies for development:

composer update --dev

Run tests:

cd test
../vendor/bin/run_unit_tests

License

DbMole is free software distributed under the terms of the MIT license


All versions of dbmole with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
atk14/files Version >1.3
atk14/sendmail Version 1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atk14/dbmole contains the following files

Loading the files please wait ....