DALMP\QueueΒΆ
The DALMP\Queue
class works as a dispatcher for the current Queue classes, following a common interface in order to maintain
compatibility with other DALMP classes.
Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.
See also
Parameters
DALMP\Queue(object)
object: | An QueueInterface instance. |
---|
Why?
There are times where database go down or you can’t Insert/Update data into a table because of the ‘too many connections mysql’. In this cases a queue always is useful so that you can later process the queries and not lose important data.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php
require_once 'dalmp.php';
$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';
$DSN = "utf8://$user:$password".'@localhost/test';
$db = new DALMP\Database($DSN);
$queue = new DALMP\Queue(new DALMP\Queue\SQLite('/tmp/dalmp_queue.db'));
/**
* In case something goes wrong, the database is unavailable, fields missing, etc,
* you can save the 'sql query' and later process it again.
*/
$sql = 'INSERT INTO testX SET colA=(NOW())';
try {
$rs = $db->Execute($sql);}
} catch(Exception $e) {
$queue->enqueue($sql);
}
|
See also
Note
The Dalmp\Queue has no dependency with the DALMP\Database class, this means that you can use only the Database or the Queue classes with out need to depend on eitherone.
Thanks Navicat for supporting Open Source projects.
A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.
Donating helps ensure continued support, development and availability.
comments powered by Disqus