Db insert: Difference between revisions From Online Manual

Jump to: navigation, search
(Created page with "{{smcfunc |function=db_insert |usage=$smcFunc['db_insert'] (method, table, columns, data, keys, disable_trans, connection) |description=Insert data into the database. |parameters...")
 
m (refresh SMW properties)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{smcfunc
{{smcfunc
|function=db_insert
|function=db_insert
|order_position=4
|usage=$smcFunc['db_insert'] (method, table, columns, data, keys, disable_trans, connection)
|usage=$smcFunc['db_insert'] (method, table, columns, data, keys, disable_trans, connection)
|description=Insert data into the database.
|description=Insert data into the database.
Line 23: Line 24:
);</nowiki>
);</nowiki>
}}
}}
<noinclude>
<noinclude>
[[Category:Database Functions]]
[[Category:Database Functions]]</noinclude>
[[Category:2.0]]
[[Category:Customizing SMF]]
[[Category:Developing SMF]]</noinclude>

Latest revision as of 16:39, 11 October 2012

Usage:

$smcFunc['db_insert'] (method, table, columns, data, keys, disable_trans, connection)


Description: Insert data into the database.

Parameters:

  • method tells how to change the data. Accepts "replace" "ignore" or "insert" (default replace).
  • table the table where the data will be changed on.
  • columns An array ( column_name => input_type) set that holds all column names that will be changed and their expected input type.
  • data holds an array that must be as long as the column array with all the data that will be used.
  • keys is supposed to hold the tables key information, only affect sqlite and postrgresql (when using "replace").
  • disable_trans .
  • connection the database connection.

Example:

$smcFunc['db_insert']($topicinfo['new_from'] == 0 ? 'ignore' : 'replace',
	'{db_prefix}log_topics',
	array(
		'id_member' => 'int', 'id_topic' => 'int', 'id_msg' => 'int',
	),
	array(
		$user_info['id'], $topic, $mark_at_msg,
	),
	array('id_member', 'id_topic')
);



Advertisement: