pense-bête de bruno sanchiz

Accueil > Programmation > PHP > php:mysqli

php:mysqli

Publié le 7 avril 2017, dernière mise-à-jour le 30 septembre 2017, 7 visites, 23646 visites totales.

$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
if ($mysqli->connect_errno) {     die('Erreur de connexion : ' .$mysqli->connect_errno);}
$mysqli->query("SET NAMES <span class="base64" title="PGNvZGUgY2xhc3M9InNwaXBfY29kZSBzcGlwX2NvZGVfaW5saW5lIiBkaXI9Imx0ciI+dXRmODwvY29kZT4="></span>");

function noms_champs_dune_table($mysqli, $table ) {   
	$temp="SELECT * FROM  ".$table." ;";
	$names=array();
	$result=$mysqli->query($temp);
	$field = $mysqli->field_count;
	while ($finfo = $result->fetch_field()) {
		$names[] = $finfo->name;
		}       
	return $names;    
	}   
print_r( noms_champs_dune_table($mysqli,"gperiodic") );

function tables_dune_bd($mysqli){
	$tables=array();
	$temp='SHOW TABLES';
	$requete=$mysqli->query($temp);
	while ($row=$requete->fetch_row()){
		$tables[]=$row[0];
		}
	return $tables;
	}
print_r(tables_dune_bd($mysqli) );

function TableVersTableau($mysqli,$table){
	$datas=array();
	$temp="SELECT * FROM ".$table;
	$resultat=$mysqli->query($temp);
	while ($row=$resultat->fetch_array()){$datas[]=$row;}	
	return $datas;
	}
$Lignes=TableVersTableau($mysqli,$table);


mysqli_result

[bruno sanchiz]