Example #1
0
 /**
  * Set the keys array
  */
 function prepareTableKeysAfterInsert()
 {
     $table = $this->pSet->getOriginalTableName();
     $keyFields = $this->pSet->getTableKeys();
     foreach ($keyFields as $k) {
         if (array_key_exists($k, $this->newRecordData)) {
             $this->keys[$k] = $this->newRecordData[$k];
         } elseif ($this->pSet->isAutoincField($k)) {
             if ($this->connection->dbType == nDATABASE_MySQL) {
                 $this->keys[$k] = GetMySQLLastInsertID($this->connection);
             } elseif ($this->connection->dbType == nDATABASE_MSSQLServer || $this->connection->dbType == nDATABASE_PostgreSQL) {
                 $this->keys[$k] = $this->connection->getInsertedId();
             } else {
                 if ($this->connection->dbType == nDATABASE_Oracle) {
                     $OraSequenceName = $this->pSet->getOraSequenceName($k);
                     if ($OraSequenceName) {
                         $lastIdSQL = "SELECT " . $OraSequenceName . ".CURRVAL FROM DUAL";
                     } else {
                         $lastIdSQL = "SELECT MAX(" . $this->connection->addFieldWrappers($k) . ") FROM " . $this->connection->addTableWrappers($table);
                     }
                 } else {
                     $lastIdSQL = "SELECT MAX(" . $this->connection->addFieldWrappers($k) . ") FROM " . $this->connection->addTableWrappers($table);
                 }
                 $keyData = $this->connection->query($lastIdSQL)->fetchNumeric();
                 if (count($keyData)) {
                 }
                 $this->keys[$k] = $keyData[0];
             }
         }
     }
 }
function prepareTableKeysAfterInsert($table, &$avalues, &$pageObject, $keys)
{
	global $conn, $failed_inline_add;
	$failed_inline_add = false;
	$keyfields=$pageObject->pSet->getTableKeys();
	foreach($keyfields as $k)
	{
		if(array_key_exists($k,$avalues))
			$keys[$k]=$avalues[$k];
		elseif($pageObject->pSet->isAutoincField($k))
		{
			$keys[$k]=GetMySQLLastInsertID();
		}
		else
			$failed_inline_add = true;
	}
	return $keys;
}