Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
linenumberstrue
// string toObject(string $fetchmode)

$idlang = 1;
$idart = 2;
$cfg = cRegistry::getConfig();
$db = cRegistry::getDb();
$sql = $db->prepare('SELECT * FROM `%s` WHERE idart = %d AND idlang = %d', $cfg['tab']['art_lang'], $idart, $idlang);
$db->query($sql);
if ($db->nextRecord()) {
    $rs = $db->toObject();
    echo "<pre>\$rs: " . print_r($rs, true) . "<pre>";
     echo "<pre>idartlang: " . $rs->idartlang . "<pre>";
    echo "<pre>title: " . $rs->title . "<pre>";
    echo "<pre>author: " . $rs->author . "<pre>";
}

...

Code Block
languagephp
linenumberstrue
// string escape(string $str)

$db$escapedCode = cRegistry::getDb();

$code = ->escape("<html>... more code n' fun ...</html>";

$escapedCode = $db->escape($code);

// Zuvorold warstyle dies folgendermaßen möglich

$dbexcaping
$escapedCode = cRegistrycSecurity::getDb();

$code = escapeDB("<html>... more code n' fun ...</html>";

$escapedCode = cSecurity, cRegistry::escapeDB($code, $dbgetDb());

These were the most important changes of the database class cDb and its predecessors. Developers now have more options to create SQL statements. Das waren die wichtigsten Neuerungen in den Datenbank-Klassen cDb und Eltern-Klassen. Entwickler haben nun mehr Möglichkeiten, um SQL-Anweisungen zu generieren, zum Teil ist das Erstellen der SQL-Anweisungen einfacher sowie lesbarer geworden und der Sicherheitsaspekt wurde zum Teil in die DB-Adapter verlagertThis leads to easier and much more readable code.