mirror of
https://github.com/Cacti/documentation.git
synced 2026-11-06 20:12:40 +09:00
Spelling mistakes/typos Small addition to Standard-Documentation Merged @cigamit DevelopmentStandards wiki page to Standards-Code-Formatting as Overview. And whatever I forgot to mention :)
35 lines
967 B
Markdown
35 lines
967 B
Markdown
# SQL Standards
|
|
|
|
Special care must be taken for Cacti to properly support multiple DBMS's.
|
|
|
|
## Quotes
|
|
|
|
When writing queries do not use quotes around numeric values. While MySQL is
|
|
not strict about types, most DBMS's assume that any value contained within
|
|
quotes is a string.
|
|
|
|
As well, single quotes are used unless a variable is referenced
|
|
|
|
```php
|
|
$graphs = db_fetch_assoc('SELECT * FROM graph WHERE height >= 150');
|
|
```
|
|
|
|
```php
|
|
$rows = db_fetch_cell("SELECT count(*) FROM $archive_table");
|
|
```
|
|
|
|
## SQL Functions
|
|
|
|
Do not use functions in SQL queries that are provided by the DBMS. These
|
|
functions are generally not uniformly support or even available in all DBMS's.
|
|
Common examples of such functions are `MD5()`, `CONCAT()`, and `NOW()`.
|
|
|
|
## Database Abstraction
|
|
|
|
Always use the database libraries provided by Cacti as an extra layer between
|
|
the code and ADODB. Details about these functions are located in
|
|
`lib/sys/database.php`.
|
|
|
|
---
|
|
Copyright (c) 2018 Cacti Group
|