Difference between revisions of "Db insert"

From Online Manual

Jump to: navigation, search
m (refresh SMW properties)
 
(One intermediate revision by one other user not shown)
Line 24: 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 12: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')
);