Download the PHP package pontikis/dacapo without Composer
On this page you can find all versions of the php package pontikis/dacapo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pontikis/dacapo
More information about pontikis/dacapo
Files in pontikis/dacapo
Package dacapo
Short Description Dacapo - Simple PHP database wrapper
License MIT
Homepage https://github.com/pontikis/dacapo
Informations about the package dacapo
Dacapo
Dacapo class (Simple PHP database wrapper)
Copyright Christos Pontikis http://www.pontikis.net
License MIT https://raw.github.com/pontikis/dacapo/master/MIT_LICENSE
Overview - Database
- Supported RDMBS: MySQLi (or MariaDB), POSTGRESQL
- Simple and clear syntax
- Only prepared statements are used
- Supported Queries: single SELECT, UPDATE, INSERT, DELETE.
- Support of transactions
- Write SQL easily and securely. Use dacapo
sql_placeholder
(? is the default) in place of parameters values. Dacapo will create SQL prepared statements from standard ANSI SQL.
Remarks
- For MYSQLi SELECT prepared statements,
mysqlnd
is required - Persistent database connection NOT supported.
- BLOB columns NOT supported
- avoid boolean columns, use integer instead (1,0)
- Use
$ds->execute()
to execute one or usually multiple SQL statements (e.g. an SQL script). You cannot use prepared statements here.
About Exceptions
You SHOULD create custom wrappers in your application to catch exceptions.
Dacapo Error Handler will throw DacapoErrorException
.
If you choose to not use Dacapo Error Handler you will define type of Exception in your own Error Handler.
About Postgresql sequences
When you execute an INSERT query in Postgres you have also to query a sequence if you want to get the last inserted value in Primary Key column. In this case use setQueryInsertPgSequence()
. There are three options:
self::PG_SEQUENCE_NAME_AUTO
in this case sequence name will be automatically constructed astablename_id_seq
. This is the default setting (ideal for SERIAL columns)null
(in the rare case when no Primary key is defined)- the sequence real name
REMEMBER that query_insert_pg_sequence
will be reset to default self::PG_SEQUENCE_NAME_AUTO
after each INSERT query.
Documentation
For HTML documentation, see docs/doxygen/html/
folder (open index.html
file in a browser).
Install
using Composer (recommended)
or the old-school way:
Usage - examples
Create instance
Select
Iterate data
Select row
Insert
Update
Delete
Transactions
Utility functions
lower
limit
PHPUnit
Tests performed in Debian 9 Linux server with
- php 7
- MariaDB Ver 15.1 Distrib 10.1.26-MariaDB (similar to MySQL 5.7)
- Postgres 9.6.7
Test databases are provided in tests/dbdata
folder. Customize credentials in tests/phpunit.xml
. First copy phpunit.dest.xml
to phpunit.xml
MySQL tests
Test connect
and select
mysqli timout make some tests slow. Run them once and then use:
In this case PHP_Invoker is needed https://github.com/sebastianbergmann/php-invoker
CUD tests Insert (C) Update (U) and Delete (D) operations and Transactions
Postgres tests
Test connect
and select
CUD tests Insert (C) Update (U) and Delete (D) operations and Transactions
Run certain test eg testConnectFails1()
You cannot use --filter
with CUD tests. Actually every CUD test depends on previous.
Contribution
Your contribution is welcomed.
- Pull requests are accepted only in
dev
branch. - Remember to also submit the relevant PHPUnit tests.
- Review is always required.