clonefish logo

The clonefish constructor

<?php

  function form( 
    $name, 
    $action, 
    $method, 
    $db = null, 
    $dbtype = 'mysql',
    $id = null ) {
  }
?>

<?php

  // examples:
  include('clonefish/form.php');
  $form = new clonefish( 
    'loginform', 'login.php', 'POST'
  );

?>
Parameter Description
name name="" parameter of the form tag
action action="" parameter of the form tag (the script name the form will be submitted to)
method method="" parameter of the form tag (GET or POST)
db If you use dynamic fields or the database validation, you may pass a mysql link identifier or have to pass a reference to an AdoDB or PearDB object here:
  • if you use the 'mysql' database wrapper (which uses the built-in mysql functions like mysql_query() ), you are not required to use this parameter. If the link identifier is not specified (or is null), the last link opened by mysql_connect() is assumed.
  • if you use the 'adodb' database wrapper, pass an AdoDB object
  • if you use the 'peardb' database wrapper, pass a PearDB object
dbtype Using this parameter allows you to define the database wrapper to use. It determines the filename and the class name of the wrapper, so if you want to create an own wrapper, you'll have to use the naming convention dbwrapper_dbtype.php and class DBWrapperdbtype. Creating a wrapper class is very easy: feel free to check the classes already available, and create your own!
id This is a special parameter used by the selectDynamic element - using this parameter and the 'valuesql' setting of a selectDynamic element, you can automatically pre-select the options of a multiple select.
<?php

  function form( 
    $name, 
    $action, 
    $method, 
    $db = null, 
    $dbtype = 'mysql',
    $id = null ) {
  }
?>

<?php

  // further examples:

  // by default, it uses the MySQL database type, so 
  $form = new clonefish(
    'loginform', 'login.php', 'POST'
  );
  // is essentially just like writing
  $form = new clonefish( 
    'loginform', 'login.php', 'POST', null, 'mysql'
  );

  // as you can see, you don't have to specify $mysql_link if 
  // you want to use the last opened mysql link. If you use
  // multiple connections, or you use some other database
  // wrapper, just pass your link variable or object:
  $mysql_link = mysql_connect( [...] );
  $form = new clonefish( 
    'loginform', 'login.php', 'POST', $mysql_link, 'mysql'
  );

  $form = new clonefish( 
    'loginform', 'login.php', 'POST', $db_object, 'adodb'
  );

?>