MyBB Documentation

Simple Select

The 1.6 Documentation is no longer maintained and some information may be outdated.

The MyBB 1.6 series reached end of life on October 1, 2015.

This means there will be no more security or maintenance releases for these series and forums running these versions of MyBB may be at risk of unfixed security issues. All administrators are strongly encouraged to upgrade their forums to the latest release of MyBB as soon as possible.

Contents

2) simple_select - Used to perform a simple select query (with no joins) on a table

string simple_select ( string table [,string field(s)] [, string conditions] [, array options])

Builds a simple query, then sends it off to $db->query().

table

   The table name to be queried.

field(s)

   Comma delimetered list of fields to be selected.

conditions

   SQL formatted list of conditions to be matched.

options

   List of options: order by, order direction, limit, limit start

Returns a resource on success, or FALSE on error.

Example 1. $db->fetch_field() example (in 1.4.x)


global $db;

$query = $db->simple_select("settings", "*",
"name='boardclosed_reason'", array("order_by" => 'name',
"order_dir" => 'DESC', "limit" => 1));

$settings = $db->fetch_array($query);

/*
Outputs:
	Array
	(
		[sid] => 6
		[name] => boardclosed_reason
		[title] => Board Closed Reason
		[description] => If your forum is closed, you can set a
 message here that your visitors will be able to see when they visit
 your forums.
		[optionscode] => textarea
		[value] => These forums are currently closed for maintenance.
 Please check back later.
		[disporder] => 2
		[gid] => 2
	)
*/

echo "<pre>";
print_r($settings);
echo "</pre>";

Edit this page on GitHub