Type
magento2-module
Magento 2 Table Query
magento2-module
MIT
None
None
None
None
None
A simple module works as a wrapper around Magento connection to perform CRUD operations on a db table
composer require alaa/magento2-table-query
public function __construct(\Alaa\TableQuery\Model\QueryInterfaceFactory $queryFactory)
{
$this->queryFactory = $queryFactory;
}
$query = $this->queryFactory->create(['table' => 'my_table', 'primaryId' => 'primary_id']);
$data = [
[
'name' => 'some name'
'age' => 33,
...
],
[...]
]
$query->put($data);
Retrieve a record based on condition
$query->pull('id = 5')
Retrieve first record and delete it
$query->poll()
Retrieve last record and delete it
$query->pop()
$query->purge();
$query->update(...)
$it = $query->iterator();
while ($it->valid()) {
$row = $it->current();
// ... do something with row
$it->next();
}
Feel free to raise issues and contribute
MIT