Source for file DBTfillingForm.class.php
Documentation is available at DBTfillingForm.class.php
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
* Including the basic class to define html forms.
require_once( CLASSPATH. "forms/HTMLForm.class.php" );
* Including various funktions to manipulate arrays.
include_once( CLASSPATH. "core/Arrays.class.php" );
* A class to generate forms to put data in a databasetable.
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2003 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* The reference to the needed Databasetable-Object.
* @var integer $lastEntryId
* @author Daniel Plücken <daniel@debakel.net>
* @param object $dbt_obj The reference to the needed
* @param string $name The name of the form.
* @param string $onSubmitOrder The javascript thatshould be execute
* @param string $targetFile The file that should receive the data.
* @param string $method The Method how the data should be send
* Sets up the databasetable by using the information of the form.
* @author Daniel Plücken <daniel@debakel.net>
$sqlQueryString = "ALTER TABLE ". $this->dbt_obj->getName(). " ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " VARCHAR( 255 ) NOT NULL, ";
case "htmlpasswordinput":
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " VARCHAR( 20 ) NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " TEXT NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " INT( 1 ) NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). "` VARCHAR( 150 ) NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " VARCHAR( 150 ) NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " VARCHAR( 150 ) NOT NULL, ";
$sqlQueryString .= "ADD ". $this->formItems[$i]
->getName(). " INT( 15 ) NOT NULL, ";
$alreadyAddedCols .= $this->formItems[$i]->getName();
echo $sqlQueryString = substr(
$result = $this->dbt_obj->parent->query( $sqlQueryString );
* Returns a single dataset as an array if the query could be execute.
* @author Daniel Plücken <daniel@debakel.net>
{ return $this->dbt_obj->getSingleDataset( $where ); }
* Returns the datasets as an two dimensional array if the query could be
* execute. The first dimension carries the datasets. The second dimension
* carries the fields's values of the result list.
* getDatasetsWithFields( $fieldnamesArr, $where );
* getDatasetsWithFields( $where );
* @author Daniel Plücken <daniel@debakel.net>
* @param array $fieldnamesArr The fields that should be in the result
* @param string $where The where clause of the query.
{ return $this->dbt_obj->getDatasetsWithFields( $fieldnamesArr, $where ); }
* Returns the table's fieldnames.
* @author Daniel Plücken <daniel@debakel.net>
{ return $this->dbt_obj->getFieldNames(); }
* Returns the fieldnames and values of the form by a two dimensional array.
* @author Daniel Plücken <daniel@debakel.net>
$tmp_arr = $this->dbt_obj->getRealFieldnames();
* Updates the gotten Dataset.
* @author Daniel Plücken <daniel@debakel.net>
* @param $where The where-definition to the dataset.
$p_key = & $this->dbt_obj->getPrimaryKey;
foreach ( $p_key as $tmp )
$where .= $and. $tmp. " = '". max(
* Inserts a Dataset into the specified database's table.
* @author Daniel Plücken <daniel@debakel.net>
* @return integer|boolean
$GLOBALS["insert_id"] = 0;
if( !empty( $GLOBALS["insert_id"] ) )
return $GLOBALS["insert_id"];
* Replaces a Dataset into the specified database's table.
* @author Daniel Plücken <daniel@debakel.net>
if( !empty( $_REQUEST["id"] ) )
* Generates the sourcecode to build this object and returns it.
* @author Daniel Plücken <daniel@debakel.net>
// setting Layouttable if exists.
if( !empty( $this->layoutTable ) )
$out = $this->layoutTable->getPHPSource(). "\r\n\r\n";
$out .= $this->formItems[$i]->getPHPSource(). "\r\n\r\n";
// $out .= $this->dbt_obj->getItemPHPSource();
$out .= "\x24formname = \"". $this->getName(). "\";\r\n";
$out .= !empty( $this->method )
? "\x24method = \"". $this->getMethod(). "\";\r\n"
$out .= "\x24form = new DBTfillingForm(\r\n"
. " \x24onSubmitOrder,\r\n"
$out .= "\x24error = false;\r\n";
$out .= "if( !empty( \x24formsent ) )\r\n";
$out .= " if( empty( \x24_REQUEST[\"id\"] ) )\r\n";
$out .= " if( \x24id = \x24form -> insertIntoDBT() )\r\n";
$out .= " \x24err_msg = \"<font color=\\\"green\\\">"
. "Erfolgreich eingetragen.</font>\";\r\n";
$out .= " \x24error = true;\r\n";
$out .= " \x24err_msg = \"<font color=\\\"#E10831\\\">"
. "Leider ist ein Fehler aufgtreten.<br>"
. "Bitte versuchen Sie es erneut.</font>\";\r\n";
$out .= " if( !empty( \x24_REQUEST[\"id\"] ) )\r\n";
. "\"id = '\".\x24_REQUEST[\"id\"].\"'\" "
$out .= " \x24err_msg = \"<font color=\\\"green\\\">"
. "Erfolgreich eingetragen.</font>\";\r\n";
$out .= " \x24error = true;\r\n";
$out .= " \x24err_msg = \"<font color=\\\"#E10831\\\">"
. "Leider ist ein Fehler aufgtreten.<br>"
. "Bitte versuchen Sie es erneut.</font>\";\r\n";
$out .= "\x24form->addHiddenFormItem( "
. "\"id\", \x24_REQUEST[\"id\"] "
} // End of class DBTfillingForm
|