Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
Kirby Foster: "Nice software. Small, lightweight, works well. I evaluated lots of software before deciding that your software worked the best for what I do. Both Maestro for MySQL and PHP Generator have saved me lots of time".
Grey: "We're a two-person company, it's just me an my wife. I'm the technical guru, and she handles the business operations. I have to know a lot about MySQL, but that's much too technical for her. I have frequently had to setup CGI scripts (I code in Perl) so she can manage some of our tables (suppliers, manufacturers, etc).

I discovered PHP Generator a couple of days ago, tried the free version,and within a few hours I had purchased the Pro version (as well as SQL Maestro for MySQL).

Today I am completing the conversion of the last of my custom table managers to PHP Generator. This is eliminating several thousand lines of code that I don't have to support any more!

Thanks for this fantastic product".

More

Add your opinion

PHP Generator for MySQL online Help

Prev Return to chapter overview Next

OnAfterInsertRecord

This event occurs when the Insert command is executed, and after the actual insertion.

 

Signature:

function OnAfterInsertRecord ($page, $rowData, $tableName, 

       &$success, &$message, &$messageDisplayTime)

 

Parameters:

$page

An instance of the Page class.

$rowData

The associative array of values that corresponds to the currently processed row.

$tableName

The name of processed table.

$success

Indicates whether the last data manipulation statement was successful or not.

$message

A message to be displayed to a user. If the statement completed successfully, the value of this parameter is equal to empty string. If the statement failed, the value of this parameter contains the error message that came from the database server.

$messageDisplayTime

A time interval (in seconds) after which the message will disappear automatically. Default value is 0 (the message will not disappear).

 

Success messages are displayed in green while error messages are displayed in red.

 

Example 1:

The following code shows the message about a success of the operation. The message will be hidden in 5 seconds:

 

if ($success) {

  $message = 'Record processed successfully.';

}

else {

  $message = '<p>Something wrong happened. ' .

    '<a class="alert-link" href="mailto:admin@example.com">' .

      'Contact developers</a> for more info.</p>';

}

$messageDisplayTime = 5;

 

Example 2:

The following code logs information about added records into a separate table:

 

if ($success) {

  $userId = $page->GetCurrentUserId();    

  $currentDateTime = SMDateTime::Now();

  $sql = 

    "INSERT INTO activity_log (table_name, action, user_id, log_time) " .

    "VALUES ('$tableName', 'INSERT', $userId, '$currentDateTime');";

  $page->GetConnection()->ExecSQL(sprintf($sql, $userId, $action, $currentDateTime));

}

 

Example 3:

The following code is used in our Feature Demo to save genres of a newly added movie to a separate table:

 

if ($success && GetApplication()->IsPOSTValueSet('genres')) {

  $genres = GetApplication()->GetPOSTValue('genres');

  $lastInsertId = $page->GetConnection()->GetLastInsertId();

  foreach ($genres as $genre) {

    $sql = sprintf('INSERT INTO movie_genres VALUES(%d, %d);', $lastInsertId, $genre);

    $page->GetConnection()->ExecSQL($sql);

  }

}

 

See also: OnAfterUpdateRecord, OnAfterDeleteRecord, OnBeforeInsertRecord.



Prev Return to chapter overview Next