/**
 * insert record on Add page 
 * @param RunnerPage &pageObject
 * @intellisense
 */
function DoInsertRecordSQLOnAdd(&$pageObject)
{
    $table = $pageObject->pSet->getOriginalTableName();
    $avalues = $pageObject->getNewRecordData();
    $blobfields = $pageObject->getBlobFields();
    //	make SQL string
    $strSQL = "insert into " . $pageObject->connection->addTableWrappers($table) . " ";
    $strFields = "(";
    $strValues = "(";
    $blobs = PrepareBlobs($avalues, $blobfields, $pageObject);
    foreach ($avalues as $akey => $value) {
        $strFields .= $pageObject->getTableField($akey) . ", ";
        if (in_array($akey, $blobfields)) {
            $strValues .= $value . ", ";
        } else {
            if (is_null($pageObject->cipherer)) {
                $strValues .= add_db_quotes($akey, $value) . ", ";
            } else {
                $strValues .= $pageObject->cipherer->AddDBQuotes($akey, $value) . ", ";
            }
        }
    }
    if (substr($strFields, -2) == ", ") {
        $strFields = substr($strFields, 0, strlen($strFields) - 2);
    }
    if (substr($strValues, -2) == ", ") {
        $strValues = substr($strValues, 0, strlen($strValues) - 2);
    }
    $strSQL .= $strFields . ") values " . $strValues . ")";
    if (!ExecuteUpdate($pageObject, $strSQL, $blobs)) {
        return false;
    }
    return true;
}
Beispiel #2
0
function DoInsertRecordSQL($table, &$avalues, &$blobfields, $pageid, &$pageObject, &$cipherer)
{
    global $error_happened, $conn, $inlineadd, $usermessage, $message, $failed_inline_add, $keys, $strTableName;
    //	make SQL string
    $strSQL = "insert into " . AddTableWrappers($table) . " ";
    $strFields = "(";
    $strValues = "(";
    $blobs = PrepareBlobs($avalues, $blobfields);
    foreach ($avalues as $akey => $value) {
        $strFields .= $pageObject->pSet->getTableField($akey) . ", ";
        if (in_array($akey, $blobfields)) {
            $strValues .= $value . ", ";
        } else {
            if (is_null($cipherer)) {
                $strValues .= add_db_quotes($akey, $value) . ", ";
            } else {
                $strValues .= $cipherer->AddDBQuotes($akey, $value) . ", ";
            }
        }
    }
    if (substr($strFields, -2) == ", ") {
        $strFields = substr($strFields, 0, strlen($strFields) - 2);
    }
    if (substr($strValues, -2) == ", ") {
        $strValues = substr($strValues, 0, strlen($strValues) - 2);
    }
    $strSQL .= $strFields . ") values " . $strValues . ")";
    if (!ExecuteUpdate($pageObject, $strSQL, $blobs, true)) {
        return false;
    }
    if ($error_happened) {
        return false;
    }
    $pageObject->ProcessFiles();
    if ($inlineadd == ADD_INLINE) {
        $status = "ADDED";
        $message = "" . "Record was added" . "";
        $IsSaved = true;
    } else {
        $message = "<<< " . "Record was added" . " >>>";
    }
    if ($usermessage != "") {
        $message = $usermessage;
    }
    $auditObj = GetAuditObject($table);
    if ($inlineadd == ADD_SIMPLE || $inlineadd == ADD_INLINE || $inlineadd == ADD_ONTHEFLY || $inlineadd == ADD_POPUP || $inlineadd == ADD_MASTER || tableEventExists("AfterAdd", $strTableName) || $auditObj) {
        $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)) {
                $lastrs = @db_query("SELECT lastval()", $conn);
                if ($lastdata = db_fetch_numarray($lastrs)) {
                    $keys[$k] = $lastdata[0];
                }
            } else {
                $failed_inline_add = true;
            }
        }
    }
    return true;
}
/**
 * insert record on Add & Register pages
 * @intellisense
 */
function DoInsertRecordSQL($table,&$avalues,&$blobfields, $pageid, &$pageObject, &$cipherer, &$keys)
{
	global $error_happened,$conn,$inlineadd,$message,$failed_inline_add,$strTableName;
	//	make SQL string
	$strSQL = "insert into ".AddTableWrappers($table)." ";
	$strFields="(";
	$strValues="(";
	$blobs = PrepareBlobs($avalues,$blobfields);
	foreach($avalues as $akey=>$value)
	{
		$strFields .= $pageObject->pSet->getTableField($akey).", ";
		if(in_array($akey, $blobfields))			
			$strValues.=$value.", ";
		else
			if(is_null($cipherer))
				$strValues .= add_db_quotes($akey,$value).", ";
			else 
				$strValues .= $cipherer->AddDBQuotes($akey,$value).", ";
	}
	if(substr($strFields,-2)==", ")
		$strFields=substr($strFields,0,strlen($strFields)-2);
	if(substr($strValues,-2)==", ")
		$strValues=substr($strValues,0,strlen($strValues)-2);
	$strSQL.=$strFields.") values ".$strValues.")";
	
	if(!ExecuteUpdate($pageObject,$strSQL,$blobs,true))
		return false;
	
	if($error_happened)
		return false;
	$pageObject->ProcessFiles();
	if ( $inlineadd==ADD_INLINE ) 
	{
		$status="ADDED";
		$message=""."Record was added"."";
		$IsSaved = true;
	} 
	else
		$message="<<< "."Record was added"." >>>";

		
	$auditObj = GetAuditObject($table);
	
	if($inlineadd==ADD_SIMPLE || $inlineadd==ADD_INLINE || $inlineadd==ADD_ONTHEFLY || $inlineadd==ADD_POPUP || $inlineadd==ADD_MASTER || tableEventExists("AfterAdd",$strTableName) || $auditObj)
	{
		$keys = prepareTableKeysAfterInsert($table, $avalues, $pageObject, $keys);
	}
	return true;
}