Funzione | Drupal | WordPress |
Requisito | global $wpdb; | |
Query secca | $res=db_result(db_query ($q)) ; | $res=$wpdb->get_var($q) ; |
Query generica | $res=db_query($q) ; | $res=$wpdb->get_results($q,ARRAY_A); |
Scan risultato query | while ($item = db_fetch_array($items)) | foreach ($items as $item) |
DML | db_query($q) | $wpdb->query($q) ; |
SQL Injection protection: $sql = $wpdb->prepare( “SELECT * FROM %s ORDER BY date_created DESC”,$tablename ); $results = $wpdb->get_results( $sql , ARRAY_A );
SQL Injection protection:
$sql = $wpdb->prepare( “SELECT * FROM %s ORDER BY date_created DESC”,$tablename );
$results = $wpdb->get_results( $sql , ARRAY_A );
%d (integer)
%f (float)
%s (string)