Download the PHP package tbolner/monetdb-php without Composer

On this page you can find all versions of the php package tbolner/monetdb-php. 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 monetdb-php

MonetDB-PHP

The official PHP client library for accessing MonetDB. For PHP 8.x and 7.2 or above (see instructions below).

Main features:

If you wish to implement your own client library either for PHP or for another language, then please read the guide about the client-server protocol.

Table of contents

Installation with Composer (PHP 8.x)

This library is available on Packagist at:

First install Composer, then execute the following in your project's directory:

Usage without installation

You don't need to use Composer in your project. You can just copy all files in the 'src' folder, and include them in your project through the include.php file, which was created just for this purpose.

Then either reference the classes by a combination of a use statement and the short class name (as it is done in the example projects):

Or just use the fully qualified class name (if your project doesn't use namespaces):

Please make sure that the php-mbstring (multi-byte string) extension is installed and enabled, and the character encoding for your project is set to UTF-8: (This is required for preventing SQL injection attacks)

Installation for PHP 7.2 or above.

Only the 1.1.x versions support PHP 7.2 or above.

Examples

Example projects:

Example 1: Simple query

The returned values are always in string representation except the null, which is always returned as null.

Example 2: Get execution stats

Example 3: Parameterized query with prepared statement

In MonetDB the placeholders of prepared statements have specific types. This library auto-converts some of the PHP types to the corresponding MonetDB types.

MonetDB type Accepted PHP types Value examples
timestamp string, DateTime "2020-12-20 11:14:26.123456"
date string, DateTime "2020-12-20"
boolean boolean, string, integer true, false, "true", 0, "0", 1, "t", "f", "yes", "no", "enabled", "disabled"
Numeric values integer, float, string 12.34, "12.34" (use string for huge numbers)
Character types string "Hello World!"
Binary string "0f44ba12" (always interpreted as hexadecimal)
time string, DateTime "11:28", "12:28:34"

Always pass the null values as null, and not as a string.

Example 4: Using escaping

Example 5: Renaming fields and using column info

Example 6: Query the first record only

Example 7: Transactions

Or:

Example 8: Importing data the fastest way

Example 9: Using multiple connections



API Reference

Class Summary
Connection Class for encapsulating a connection to a MonetDB server.
Response This class represents a response for an SQL query or for a command. In case of a 'select' query, this class can be iterated through, using a 'foreach' loop. The records are returned as associative arrays, indexed by the column names.
StatusRecord This class shares the information returned by MonetDB about the executed queries. Like execution time, number of rows affected, etc. Note that only specific fields are populated for specific queries, the others remain NULL.
ColumnInfo This class contains information about the columns of a table response to a 'select' query.



Connection Class

Class for encapsulating a connection to a MonetDB server.

Method Documentation
__construct Create a new connection to a MonetDB database. br>@paramint $maxReplySize = 200 : The maximal number of tuples returned in a response. A higher value results in smaller number of memory allocations and string operations, but also in higher memory footprint.
Close Close the connection
Query Execute an SQL query and return its response. For 'select' queries the response can be iterated using a 'foreach' statement. You can pass an array as second parameter to execute the query as prepared statement, where the array contains the parameter values. SECURITY WARNING: For prepared statements in MonetDB, the parameter values are passed in a regular 'EXECUTE' command, using escaping. Therefore the same security considerations apply here as for using the Connection->Escape(...) method. Please read the comments for that method. br>@returnResponse
QueryFirst Execute an SQL query and return only the first row as an associative array. If there is more data on the stream, then discard all. Returns null if the query has empty result. You can pass an array as second parameter to execute the query as prepared statement, where the array contains the parameter values. br>@returnstring[] -or- null
Command Send a 'command' to MonetDB. Commands are used for configuring the database, for example setting the maximal response size, or for requesting unread parts of a query response ('export').br>@returnResponse -or- null
Escape Escape a string value, to be inserted into a query, inside single quotes. The following characters are escaped by this method: backslash, single quote, carriage return, line feed, tabulator, null character, CTRL+Z. As a security measure this library forces the use of multi-byte support and UTF-8 encoding, which is also used by MonetDB, avoiding the SQL-injection attacks, which play with differences between character encodings. strong>$value
@returnstring
ClearPsCache Clears the in-memory cache of prepared statements. This is called automatically when an error is received from MonetDB, because that also purges the prepared statements and all session state in this case.
GetMaxReplySize The maximal number of tuples returned in a response.br>
@returnint



Response Class

This class represents a response for an SQL query or for a command. In case of a 'select' query, this class can be iterated through, using a 'foreach' loop. The records are returned as associative arrays, indexed by the column names.

Method Documentation
Discard Read through all of the data and discard it. Use this method when you don't want to iterate through a long query, but you would like to start a new one instead.
IsDiscarded Returns true if this response is no longer connected to an input TCP stream.br>
@returnboolean
GetColumnNames Returns the names of columns for the table. If you would like to have more information about the columns than just their names, then use the 'GetColumnInfo()' method.br>
@returnstring[]
Fetch Returns the next row as an associative array, or null if the query ended.br>
@returnarray -or- null
GetStatusRecords Returns one or more Status records that tell information about the queries executed through a single request.br>
@returnStatusRecord[]
GetColumnInfo Returns an array of ColumnInfo objects that contain information about the columns of a table response to a 'select' query.br>
@returnColumnInfo[]



StatusRecord Class

This class shares the information returned by MonetDB about the executed queries. Like execution time, number of rows affected, etc. Note that only specific fields are populated for specific queries, the others remain NULL.

Method Documentation
GetQueryType Returns a short string which identifies the type of the query.br>
@returnstring
GetDescription Returns a user-friendly text which describes the effect of the query.br>
@returnstring
GetQueryTime The time the server spent on executing the query. In milliseconds.br>
@returnfloat -or- null
GetSqlOptimizerTime SQL optimizer time in milliseconds.br>
@returnfloat -or- null
GetMalOptimizerTime MAL optimizer time in milliseconds.br>
@returnfloat -or- null
GetAffectedRows The number of rows updated or inserted.br>
@returninteger -or- null
GetTotalRowCount The total number of rows in the result set. This includes those rows too, which are not in the current response.br>
@returninteger -or- null
GetAsText Get a description of the status response in a human-readable format.br>
@returnstring
GetPreparedStatementID Get the ID of a created prepared statement. This ID can be used in an 'EXECUTE' statement, but only in the same session.br>
@returninteger -or- null
GetResultID Returns the ID of the result set that is returned for a query. It is stored on the server for this session, and parts of it can be queried using the "export" command.br>
@returninteger -or- null
GetAutoCommitState Available after "start transaction", "commit" or "rollback". Tells whether the current session is in auto-commit mode or not.br>
@returnboolean -or- null
GetRowCount The number of rows (tuples) in the current response only.br>
@returninteger -or- null
GetColumnCount Column count. If the response contains tabular data, then this tells the number of columns.br>
@returninteger -or- null
GetQueryID Query ID. A global ID which is also used in functions such as sys.querylog_catalog().br>
@returninteger -or- null
GetLastInsertID The last automatically generated ID by an insert statement. (Usually auto_increment) NULL if none.br>
@returninteger -or- null
GetExportOffset The index (offset) of the first row in a block response. (For an "export" command.)br>
@returninteger -or- null



ColumnInfo Class

This class contains information about the columns of a table response to a 'select' query.

Method Documentation
GetTableName The name of the table the field belongs to, or the name of a temporary resource if the value is the result of an expression.br>
@returnstring
GetColumnName Column name.br>
@returnstring
GetType The SQL data type of the field.br>
@returnstring
GetLength A length value that can be used for deciding the width of the columns when rendering the response.br>
@returninteger



Development setup through the Docker image

Running the integration tests

The output should be similar to:

IDE setup


All versions of monetdb-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2 || >=8.0
ext-mbstring Version *
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 tbolner/monetdb-php contains the following files

Loading the files please wait ....