---
title: "Datensätze nicht auslesbar?"
url: "https://www.typo3.net/d/38447-datensaetze-nicht-auslesbar"
source: "typo3.net"
tags: ["Extensions","Entwicklung","Datenbank","Frage"]
created: "2006-02-24"
last_reply: "2006-02-28"
replies: 2
solved: false
page: 1
pages: 1
lang: "de"
---

# Datensätze nicht auslesbar?

Extensions › Entwicklung · 2 Antworten · gestartet 2006-02-24

## Eröffnungsbeitrag

**TRXde** · 2006-02-24 · [Beitrag #1](https://www.typo3.net/d/38447-datensaetze-nicht-auslesbar/1)

Hi,

ich bin ein Typo3-Anfänger was die Extensionentwicklung und steh gerade auf dem Schlauch.   #angry#

Ich habe testweise ein paar Daten in die Datenbank eingetragen und ich kriege sie nicht ausgegeben, jedenfalls $this->internal["res_count"] immer 0. Hier der Ausschnitt.

```php
function listView($content,$conf)	{
$this->conf=$conf;		// Setting the TypoScript passed to this function in $this->conf
$this->pi_setPiVarDefaults();
$this->pi_loadLL();		// Loading the LOCAL_LANG values
	
....


if (!isset($this->piVars["pointer"])) $this->piVars["pointer"]=0;
if (!isset($this->piVars["mode"])) $this->piVars["mode"]=1;

// Initializing the query parameters:
list($this->internal["orderBy"],$this->internal["descFlag"]) = explode(":",$this->piVars["sort"]);

$this->internal["results_at_a_time"]=1;
	$this->internal["maxPages"]=t3lib_div::intInRange($lConf["maxPages"],0,1000,2);	

$this->internal["searchFieldList"]="entryid,author,title";

$this->internal["orderByList"]="uid,entryid";
			
// Get number of records:
$res = $this->pi_exec_query("tx_text_1",1);
list($this->internal["res_count"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
	
// Make listing query, pass query to SQL database:
$res = $this->pi_exec_query("tx_text_1");
$this->internal["currentTable"] = "tx_text_1";
```

## Antworten

### [#2](https://www.typo3.net/d/38447-datensaetze-nicht-auslesbar/2) · anj · 2006-02-26

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:

```php
// 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');

*/
```

### [#3](https://www.typo3.net/d/38447-datensaetze-nicht-auslesbar/3) · TRXde · 2006-02-28

Vielen Dank, jetzt hats geklappt, obwohl ich nicht verstehe warum es bei mir nicht geklappt hat.  #paralyzed#

---

Quelle: „Datensätze nicht auslesbar?“, typo3.net, https://www.typo3.net/d/38447-datensaetze-nicht-auslesbar
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
