rtgx

Mysqli - ďalšie príklady

Multiquery

PHP

$query  = 'SELECT uid, title FROM pages LIMIT 5;';
$query .= 'SELECT uid, header FROM tt_content LIMIT 5;';

// execute multi query
if( $mysqli->multi_query($query) ) {
printf( '---------------------------<br />' );
do {
// store first result set
if( $result = $mysqli->store_result() ) {
while( $row = $result->fetch_row() ) {
printf( "%s<br />", $row[1] );
}
$result->close();
}
if( $mysqli->more_results() ) {
printf( '---------------------------<br />' );
}
} while( $mysqli->next_result() );
}

Výsledok

---------------------------
rtg
System
Generátor typoscriptu
Content elements
Vyhľadávanie
---------------------------
Flash object v html zapisovaný javascriptom
Header data
Config
CONTENT + renderObj
CONTENT

Informácie o vybraných stĺpcoch tabuľky

PHP

$query = 'SELECT pid, uid, header, bodytext FROM tt_content LIMIT 5;';

if( $result = $mysqli->query( $query ) ) {
echo '<table><tr><th>Name</th><th>Table</th><th>max. Len</th><th>Flags</th><th>Type</th></tr>';
// Get field information for all columns
$finfo = $result->fetch_fields();
foreach( $finfo as $val ) {
echo '<tr>
<td>'.$val->name.'</td>
<td>'.$val->table.'</td>
<td>'.$val->max_length.'</td>
<td>'.$val->flags.'</td>
<td>'.$val->type.'</td>
</tr>';
}
echo '</table>';
$result->close();
}

Výsledok

Name

Table

max. Len

Flags

Type

pid

tt_content

2

49161

3

uid

tt_content

2

49667

3

header

tt_content

44

4113

252

bodytext

tt_content

2376

4113

252

Aktuálna znaková sada

PHP

$charset = $mysqli->character_set_name();
printf( "Current character set is <strong>%s</strong><br />", $charset );

Výsledok

Current character set is latin1

 
Žiadne dokumenty ani odkazy k tejto stránke.