https://github.com/interlab/smf-cool-db
new db style for smf 2.xx
https://github.com/interlab/smf-cool-db
Last synced: about 2 months ago
JSON representation
new db style for smf 2.xx
- Host: GitHub
- URL: https://github.com/interlab/smf-cool-db
- Owner: interlab
- License: mit
- Created: 2013-12-20T08:48:48.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-25T16:15:29.000Z (over 12 years ago)
- Last Synced: 2025-03-23T01:45:36.136Z (over 1 year ago)
- Language: PHP
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cool-db-smf
===========
new db style for smf 2.xx
## Example ##
**old style**
```php
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT id_cat, cat_order
FROM {db_prefix}categories',
[]
);
if ($smcFunc['db_num_rows']($request) == 0)
return [];
while ($row = $smcFunc['db_fetch_assoc']($request))
{
# ...
$cat_order[$row['id_cat']] = $row['cat_order'];
}
$smcFunc['db_free_result']($request);
```
**new style**
```php
use Inter\DB;
$request = DB::query('
SELECT id_cat, cat_order
FROM {db_prefix}categories',
[]
);
if (!$request->num_rows)
return [];
while ($row = $request->fetch_assoc)
{
# ...
$cat_order[$row['id_cat']] = $row['cat_order'];
}
$request->free;
```