DELIMITER $$ DROP FUNCTION IF EXISTS `sead`.`php__seadgen__insert`$$ CREATE FUNCTION `sead`.`php__seadgen__insert`(in_schema VARCHAR(64), in_table VARCHAR(64)) RETURNS TEXT READS SQL DATA BEGIN DECLARE currentcolumn varchar(64); DECLARE currenttype varchar(64); DECLARE instatement text; DECLARE setstatement text; DECLARE outputstatement text; DECLARE querystatement text; DECLARE anymatches tinyint(1); DECLARE errorcount INT; DECLARE lastrow tinyint(1); DECLARE rowcount INT; DECLARE cursortables CURSOR FOR SELECT column_name, column_type FROM information_schema.columns WHERE table_schema = in_schema and table_name = in_table; DECLARE CONTINUE HANDLER FOR 1329 SET lastrow=1; insertfieldgetsprocedures:BEGIN SET errorcount = 0; IF in_schema is NULL or in_schema <= " " THEN SET errorcount = errorcount + 1; ELSE SET anymatches = 0; SELECT count(*) from information_schema.schemata WHERE schema_name=in_schema INTO anymatches; IF anymatches = 0 THEN SET errorcount = errorcount + 1; END IF; END IF; IF in_table is NULL or in_table <= " " or errorcount > 0 THEN SET errorcount = errorcount + 1; ELSE SET anymatches = 0; SELECT count(*) from information_schema.tables WHERE table_schema=in_schema AND table_name=in_table INTO anymatches; IF anymatches = 0 THEN SET errorcount = errorcount + 1; END IF; END IF; IF errorcount > 0 THEN LEAVE insertfieldgetsprocedures; END IF; IF anymatches > 0 THEN SET lastrow = 0; SET instatement = " "; SET setstatement = " "; SET rowcount = 0; OPEN cursortables; preparestatementloop: LOOP FETCH cursortables INTO currentcolumn, currenttype; IF lastrow = 1 THEN leave preparestatementloop; END IF; IF currentcolumn NOT IN ("id","inserted","inserted_by","updated","updated_by","updated_reason") THEN SET rowcount = rowcount + 1; SET setstatement = concat_ws("", setstatement, " =get_fields('",in_table,"','",currentcolumn,"','",rowcount,"',NULL);?> " ); SET instatement=CONCAT_WS("",instatement,"\n", "$checked['",currentcolumn,"']=word_and_number_check('",currentcolumn,"');"); IF rowcount = 1 THEN SET querystatement = concat_ws("","'.(empty($checked['",currentcolumn,"'])?'NULL':'\"'.$checked['",currentcolumn,"'].'\"').'"); ELSE SET querystatement = concat_ws("",querystatement,",'.(empty($checked['",currentcolumn,"'])?'NULL':'\"'.$checked['",currentcolumn,"'].'\"').'"); END IF; END IF; END LOOP preparestatementloop; close cursortables; SET setstatement = concat_ws("",setstatement,"\n"); LEAVE insertfieldgetsprocedures; ELSE SET errorcount = errorcount + 1; LEAVE insertfieldgetsprocedures; END IF; END; SET outputstatement = concat_ws(""," ",instatement," include_once($_SERVER['DOCUMENT_ROOT'].'inc/inc_navigation_links.php'); ?>
The following fields are emtpy and required:
The ",in_table," data that was transfered has been a success.
'; $showform=FALSE; //header('Location: /transfer?pg=",in_table,"&id='.$id.'&procedure=insert'); //header('Location: /sead/",in_table,"-get/id-'.$id.'/'); } } $result->close(); }else{ echo 'The ",in_table," data has not been entered.
'; echo 'The reason is: '.$error.'
'; $showform=TRUE; } } } if($showform==TRUE){ ?>