Download the PHP package eftec/daoone without Composer

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

Database Access Object wrapper for PHP and MySqli in a single class

DaoOne. It's a simple wrapper for Mysqli

This library is as fast as possible. Most of the operations are simple string/array managements.

Note: This release is moved to https://github.com/EFTEC/PdoOne
PdoOne does the same job but it works with PDO library (instead of MySQLi). Right now PdoOne works with Mysqli and SqlSrv but it has many other features that will not be present on DaoOne

Build Status Packagist Total Downloads [Maintenance]() [composer]() [php]() [php]() [CocoaPods]()

Migrating to eftec/PdoOne

Adding the dependency

Install via composer

composer require eftec/pdoone

This library could works in tandem with eftec/daoone.

Changing the library

Change the class, instead of use eftec/daoone -> eftec/pdoone

Example:

Before:

After:

Constructor

Before:

After:

Operators

If we use DaoOne::runGen(false), then we must check the result. runGen (DaoOne) returns a mysqli_result object. runGen (PdoOne) returns a pdostatement object.

Before:

After:

How it works?

Turn this

into this

Table of Content

Install (using composer)

Add to composer.json the next requirement, then update composer.

or install it via cli using

composer require eftec/daoone

Install (manually)

Just download the file lib/DaoOne.php and save it in a folder.

Usage

Start a connection

where

Run an unprepared query

Run a prepared query

note: you could also insert using a procedural chain insert($table,$schema,[$values])

Run a prepared query with parameters.

Return data (first method)

It returns a mysqli_statement.

This statement must be processed manually.

Return data (second method)

It returns an associative array.

Running a transaction

startTransaction()

It starts a transaction

commit($throw=true)

It commits a transaction.

rollback($throw=true)

It rollbacks a transaction.

Fields

throwOnError=true

If true (default), then it throws an error if happens an error. If false, then the execution continues

isOpen=true

It is true if the database is connected otherwise,it's false.

Query Builder (DQL)

You could also build a procedural query.

Example:

select($columns)

Generates a select command.

Generates the query: select col1,col2 ....

Generates the query: *select from table** ....

distinct($distinct='distinct')

Generates a select command.

Generates the query: select distinct col1,col2 ....

Note: ->distinct('unique') returns select unique ..

from($tables)

Generates a from command.

Generates the query: select * from table

$tables could be a single table or a sql construction. For examp, the next command is valid:

where($where,[$arrayParameters=array()])

Generates a where command.

Generates the query: select * from table where p1=1

Note: ArrayParameters is an array as follow: type,value.
Where type is i=integer, d=double, s=string or b=blob. In case of doubt, use "s"
Example of arrayParameters:
['i',1 ,'s','hello' ,'d',20.3 ,'s','world']

Generates the query: select * from table where p1=?(1)

Generates the query: select * from table where p1=?(1) and p2=?('hello')

Note. where could be nested.

Generates the query: select * from table where p1=?(1) and p2=?('hello')

You could also use:

Generates the query: select * from table where p1=?(Coca-Cola) and p2=?(1)

order($order)

Generates a order command.

Generates the query: select * from table order by p1 desc

group($group)

Generates a group command.

Generates the query: select * from table group by p1

having($having,[$arrayParameters])

Generates a group command.

Generates the query: select * from table group by p1 having p1>?(1)

Note: Having could be nested having()->having()
Note: Having could be without parameters having('col>10')

runGen($returnArray=true)

Run the query generate.

Note if returnArray is true then it returns an associative array. if returnArray is false then it returns a mysqli_result
Note: It resets the current parameters (such as current select, from, where,etc.)

toList()

It's a macro of runGen. It returns an associative array or null.

toResult()

It's a macro of runGen. It returns a mysqli_result or null.

first()

It's a macro of runGen. It returns the first row (if any, if not, it returns false) as an associative array.

last()

It's a macro of runGen. It returns the last row (if any, if not, it returns false) as an associative array.

Sometimes is more efficient to run order() and first() because last() reads all values.

sqlGen()

It returns the sql command.

Note: it doesn't reset the query.

Query Builder (DML), i.e. insert, update,delete

There are four ways to execute each command.

Let's say that we want to add an integer in the column col1 with the value 20

Schema and values using a list of values: Where the first value is the column, the second is the type of value (i=integer,d=double,s=string,b=blob) and second array contains the values.

Schema and values in the same list: Where the first value is the column, the second is the type of value (i=integer,d=double,s=string,b=blob) and the third is the value.

Schema and values using two associative arrays:

Schema and values using a single associative array: The type is calculated automatically.

insert($table,$schema,[$values])

Generates a insert command.

Using nested chain (single array)

Using nested chain multiple set

or (the type is defined, in the possible, automatically by MySql)

Using nested chain declarative set

Generates the query: insert into productype(idproducttype,name,type) values(?,?,?) ....

update($$table,$schema,$values,[$schemaWhere],[$valuesWhere])

Generates a insert command.

or

Generates the query: update producttype set name=?,type=? where idproducttype=? ....

delete([$table],[$schemaWhere],[$valuesWhere])

Generates a delete command.

Generates the query: delete from producttype where idproducttype=? ....

You could also delete via a DQL builder chain.

Generates the query: delete from producttype where idproducttype=? ....

Sequence

Sequence is an alternative to AUTO_NUMERIC field. It uses a table to generate an unique ID.
The sequence used is based on Twitter's Snowflake and it is generated based on time (with microseconds), Node Id and a sequence. This generates a LONG (int 64) value that it's unique

Creating a sequence

Using the sequence

Creating a sequence without a table.

Changelist


All versions of daoone with dependencies

PHP Build Version
Package Version
Requires ext-mysqli Version *
ext-json Version *
ext-openssl 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 eftec/daoone contains the following files

Loading the files please wait ....