https://github.com/genaker/mage-db2
https://github.com/genaker/mage-db2
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/genaker/mage-db2
- Owner: Genaker
- Created: 2024-11-28T00:03:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-27T05:50:44.000Z (about 1 year ago)
- Last Synced: 2025-05-04T09:59:18.999Z (about 1 year ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# install
```
composer require mage/db2
```
If you have any conflicts, you can use:
```
composer require mage/db2 --with-all-dependencies --ignore-platform-reqs --prefer-source --no-scripts
```
use Mage\DB2\DB2;
$isReturningCustomer = DB2::table('sales_order')
->where('customer_id', $customerId)
->where('entity_id', '<', $entityId)
->exists();
```
```
DB2::table('sales_order')->where('customer_id', 123)->get();
```
Query product images with product details using DB2:
```
$images = DB2::table('catalog_product_entity_media_gallery as main_table')
->join(
'catalog_product_entity_media_gallery_value as mgv',
'mgv.value_id',
'=',
'main_table.value_id'
)
->join(
'catalog_product_entity as e',
'e.entity_id',
'=',
'mgv.entity_id'
)
->select([
'main_table.value_id',
'main_table.attribute_id',
'main_table.value',
'main_table.media_type',
'main_table.disabled',
'e.sku'
])
->where('main_table.media_type', '=', 'image')
->where('main_table.disabled', '=', 0)
->orderBy('main_table.value_id', 'ASC')
->get();
```