Documentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
v1.4:dblayer [2011/04/01 11:59]
Reines
v1.4:dblayer [2011/04/01 12:03]
Reines
Line 35: Line 35:
  bool drop_index( string $table_name , string $index_name [, bool $no_prefix = FALSE] )  bool drop_index( string $table_name , string $index_name [, bool $no_prefix = FALSE] )
  bool truncate_table( string $table_name [, bool $no_prefix = FALSE] )  bool truncate_table( string $table_name [, bool $no_prefix = FALSE] )
 +}
 +</​code>​
 +
 +==== Example usage ====
 +
 +<code php>
 +// Fetch user count
 +$result = $db->​query('​SELECT COUNT(id) FROM '​.$db->​prefix.'​users AS u WHERE u.id>1 AND u.group_id!='​.PUN_UNVERIFIED) or error('​Unable to fetch user list count',​ __FILE__, __LINE__, $db->​error());​
 +$num_users = $db->​result($result);​
 +</​code>​
 +
 +<code php>
 +// Grab the users
 +$result = $db->​query('​SELECT u.id, u.username, u.title, u.num_posts,​ u.registered,​ g.g_id, g.g_user_title FROM '​.$db->​prefix.'​users AS u LEFT JOIN '​.$db->​prefix.'​groups AS g ON g.g_id=u.group_id WHERE u.id IN('​.implode(',',​ $user_ids).'​)'​) or error('​Unable to fetch user list', __FILE__, __LINE__, $db->​error());​
 +while ($user_data = $db->​fetch_assoc($result))
 +{
 + // Do something with $user_data...
 } }
 </​code>​ </​code>​