logo   Home Download Documentation Support

 

DashingDB Documentation

Learn to use DashingDB Within Minutes

 

mysql_insert_row Function

mysql_insert_row - Insert a row in MySQL Table.

Syntax

string mysql_insert_row ( string table_name, array items, string or array is_unique)

Description

Parameter

Description

table_name

 

Name of the table where data is needed to be inserted.

Input Example: "table_name"

 

items

 

These are items to be inserted.

Input Example: $items["field_name"] = "Item to Input"

 

is_unique

 

Enter false if the data you are inserting is not unique, otherwise NOT UNQIQUE would be returned.

Input Example: "false" or $unique[0] = "field_name";

 

Errors

Error

Description

Error: No table ("table_name") or field ("field_name") exists. Field entered in items either does not exist or table_name entered does not exists

Examples

Example 1

 

<?php

include("class.php");

 

$row["field1"] = "Item1"; // field1 is the field, Test is the item to be inserted in field1 field
$row["field2"] = "Item2"; // field2 is the field, Test3 is the item to be inserted in field2 field

 

mysql_insert_row("tablename", $row, "false"); // We have set is_unique to false because we do not need unique rows.

?>

 

No output would be displayed.

 

Example 2

 

<?php

include("class.php");

 

$row["field1"] = "Item1"; // field1 is the field, Test is the item to be inserted in field1 field
$row["field2"] = "Item2"; // field2 is the field, Test3 is the item to be inserted in field2 field

 

$unique[0] = "field1"; // Field which we want be unique
$unique[1] = "field2"; // Another field we want to be unique

 

echo mysql_insert_row("tablename", $row, $unique); // We have set is_unique to false because we do not need unique rows.

?>

 

First time it would be displayed no output, but you load it second time, string "NOT UNIQUE" would be returned stated that the item you are inserting is not unqiue and therefore it is not inserted!

 

 

© 2017 DashingDB.