Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
related_select.php
Go to the documentation of this file.
1 <?php
11 require_once 'HTML/QuickForm/select.php';
12 require_once 'Dataface/Relationship.php';
13 require_once 'Dataface/QueryTool.php';
14 require_once 'Dataface/DB.php';
15 class HTML_QuickForm_related_select extends HTML_QuickForm_select {
16 
17  function HTML_QuickForm_related_select( &$relationship ){
18  $sql = $relationship->getDomainSQL();
19  // The sql query to return all candidate rows of relationship
20  $fkeys = $relationship->getForeignKeyValues();
21  // Values of foreign keys (fields involved in where and join clauses)
22  $table = $relationship->getDomainTable();
23  if ( isset( $fkeys[$table] ) ){
24  $query = $fkeys[$table];
25  foreach ($query as $key=>$val){
26  if ( strpos($val,'$')===0 or $val == '__'.$table.'__auto_increment__'){
27  unset($query[$key]);
28  }
29  }
30  } else {
31  $query = array();
32  }
33  $qt = new Dataface_QueryTool($table, $relationship->_sourceTable->db, $query);
34  $options = $qt->getTitles();
35  //print_r($options);
36 
37  $this->HTML_QuickForm_select('test','test',$options);
38 
39  echo $this->toHtml();
40 
41 
42  }
43 
44 
45 }
46 
47