This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:dev:all:examples:sql [16.07.2015 21:56] – [INSERT / UPDATE] translated mrbaseman | en:dev:all:examples:sql [20.02.2019 07:49] (current) – [SELECT] Manuela v.d.Decken | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | ||
- | |||
====== This is how SQL works... ====== | ====== This is how SQL works... ====== | ||
Line 18: | Line 16: | ||
Each of all the four examples give back a result-object with all records of the visible sections of a page at the current time. | Each of all the four examples give back a result-object with all records of the visible sections of a page at the current time. | ||
<code php Example-1.php> | <code php Example-1.php> | ||
- | $oResult = $oDb-> | + | $oResult = $oDb-> |
</ | </ | ||
<code php Example-2.php> | <code php Example-2.php> | ||
$sql = ' | $sql = ' | ||
- | $sql .= 'WHERE `page_id`=' | + | $sql .= 'WHERE `page_id`=' |
$sql .= 'ORDER BY `block`, `position`'; | $sql .= 'ORDER BY `block`, `position`'; | ||
$oResult = $oDb-> | $oResult = $oDb-> | ||
Line 31: | Line 29: | ||
. 'FROM `' | . 'FROM `' | ||
. 'WHERE `page_id`=' | . 'WHERE `page_id`=' | ||
- | | + | |
- | | + | |
. 'ORDER BY `block`, `position`'; | . 'ORDER BY `block`, `position`'; | ||
$oResult = $oDb-> | $oResult = $oDb-> | ||
Line 39: | Line 36: | ||
$sql = ' | $sql = ' | ||
. 'WHERE `page_id`=' | . 'WHERE `page_id`=' | ||
- | | + | |
- | | + | |
. 'ORDER BY `block`, `position`'; | . 'ORDER BY `block`, `position`'; | ||
$oResult = $oDb-> | $oResult = $oDb-> | ||
</ | </ | ||
- | Question: Which of the examples are easier to read, to understand and to modify if required? **1**& | + | **Question:** Which of the examples are easier to read, understand and modify if required?\\ |
+ | **Answers: | ||
---- | ---- | ||
Line 98: | Line 95: | ||
==== REPLACE ==== | ==== REPLACE ==== | ||
- | //(mySQL spezifische Erweiterung zu ANSI-SQL)// | + | //(MySQL specific extension to ANSI SQL)// |
- | Wie überall gibt es fast keine Regel ohne Ausnahme.\\ | + | Like everywhere else, there is almost no rule without exception.\\ |
- | **REPLACE** | + | **REPLACE** |
- | Wird versucht, einen Datensatz einzufügen, der einen Index-Konflikt mit einem bestehende Datensatz auslöst, wird der Prozess nicht abgebrochen, | + | If you try to insert a record which would cause an index conflict with an existing data set, the process will not be canceled, but the existing, old record is deleted and the new values are added instead.\\ |
- | **REPLACE** | + | **REPLACE** |
- | Der WebsiteBaker-Core benutzt dieses | + | The WebsiteBaker |
<code sql> | <code sql> | ||
-- Structure of table ' | -- Structure of table ' | ||
Line 114: | Line 111: | ||
){TABLE_ENGINE}; | ){TABLE_ENGINE}; | ||
</ | </ | ||
- | Im Statement muss zwingend ein Wert für das Feld mit dem PRIMARY_KEY | + | In a statement it is mandatory to pass a value for the field with the PRIMARY_KEY |
- | Auch der Aufbau des Statements weicht vom normalen | + | |
<code php snippet.php> | <code php snippet.php> | ||
$sql = ' | $sql = ' | ||
Line 125: | Line 121: | ||
}</ | }</ | ||
- |