ajaxCRUD.com

» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX

   by loud canvas media

AjaxCRUD Class Documentation / Reference Material

<< Reference overview
<< Home

addValueOnInsert

sets a value to a field on row insert
void addValueOnInsert( String fieldName, String value )
This function should be used when certain fields should be immediately populated with pre-defined data. A good use of this function is when your table has a "date created" field for an entity. This field can be automatically determined (by mySQL) and then set when adding the row.

Keep in mind: this function will overwrite any value input by the user for this field. Therefore it should always be used in conjuctiton with omitAddField so that an input box for the field does not even display when adding an entry.

Details

Type function
Returns void

Parameters

fieldName
The database field name you want to be able to assign a specific data input to on row insert
value
Value to overwrite the field with - if the value is "NOW()" it is parsed not as a string, but as a mySQL expression

Example

$tblDemo->addValueOnInsert("fldCreationDate", "NOW()");


NOTE: you MUST use omitAddField with the field for it to be overwritten; reason being - if a value is sent for that field as part of the "add" form then that takes priority over addValueOnInsert

See also

New, Edit

 

"just what i [was] look[ing] for..."
~Sergey

What is a business/commercial website?

A commercial website is one created for a business, for which purpose is generating revenue or cash flow of any type (and that isn't under a non-profit organization). So if you're selling a product, selling advertisement, selling a service, or just marketing a commercial business, your site is commercial. A company website is also commercial even if it doesn't sell anything, as it's purpose is to front a commercial company.
Close