Hi,
ich weiss nicht genau wo dein Problem liegen könnte, aber ich gebe dir mal meine Liste von alten, guten und den besten Methoden um mit einer Datenbank zu kommunizieren.
Die Beste Methode sollte man eigentlich immer nutzen, da Sie das neue DataBaseAbstarctionLayer Konzept unterstützt d.h. Datenbank unabhängig ist:
// REFERENCE TO USE the MySQL WRAPPER
// (D)ata (B)ase (A)bstraction (L)ayer
// OLD
//#####
/*
$res = mysql(TYPO3_db, 'SELECT * FROM mytable WHERE uid=123 AND title LIKE "%blabla%"ORDER BY title LIMIT 5');
• while($row = mysql_fetch_assoc($res)) {
• echo $row['title'].'<br />';}
• $res = mysql(TYPO3_db, 'INSERT INTO mytable (pid,title) VALUES (123, "My Title")');
• $res = mysql(TYPO3_db, 'UPDATE mytable SET title="My Title" WHERE uid=123');
• $res = mysql(TYPO3_db, 'DELETE FROM mytable WHERE uid=123');
NEW
//#####
// BEST:
SELECT
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*', // SELECT ...
'mytable', // FROM ...
'uid=123 AND title LIKE "%blabla%"', // WHERE...
'', // GROUP BY...
'title', // ORDER BY...
'5,10' // LIMIT to 10 rows, starting with number 5
// (MySQL compat.)
);
INSERT
$insertArray = array(
'pid' => 123,
'title' => 'Mein Titel'
);
$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('meinetabelle', $insertArray);
UPDATE
$updateArray = array(
'title' => 'Mein Titel'
);
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('meinetabelle', 'uid=123', $updateArray);
DELETE
$res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('meinetabelle', 'uid=123');
// GOOD:
SELECT
$query = $GLOBALS['TYPO3_DB']->SELECTquery(
'*', // SELECT ...
'mytable', // FROM ...
'uid=123 AND title LIKE "%blabla%"', // WHERE...
'', // GROUP BY...
'title', // ORDER BY...
'5' // LIMIT ...
);
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
INSERT
$insertArray = array(
'pid' => 123,
'title' => 'My Title'
);
$query = $GLOBALS['TYPO3_DB']->INSERTquery('mytable', $insertArray);
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
UPDATE
$updateArray = array(
'title' => 'My Title'
);
$query = $GLOBALS['TYPO3_DB']->UPDATEquery('mytable', 'uid=123', $updateArray);
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
DELETE
$query = $GLOBALS['TYPO3_DB']->DELETEquery('mytable', 'uid=123');
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
ALTERNATIVE:
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, 'SELECT * FROM mytable WHERE uid=123 AND title LIKE "%blabla%" ORDER BY title LIMIT 5');
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
echo $row['title'].'<br />';}
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, 'INSERT INTO mytable (pid,title) VALUES (123, "My Title")');
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, 'UPDATE mytable SET title="My Title" WHERE uid=123');
$res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, 'DELETE FROM mytable WHERE uid=123');
*/