Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
RelationshipTool.php
Go to the documentation of this file.
1 <?php
2 /*-------------------------------------------------------------------------------
3  * Xataface Web Application Framework
4  * Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *-------------------------------------------------------------------------------
20  */
30 require_once 'SQL/Parser.php';
31 
33 
34 
35  var $_table;
36  var $_parser;
37 
39  $this->_table =& Dataface_Table::loadTable($tablename);
40  $this->_parser = new Sql_parser();
41  }
42 
43 
44  public static function getInstance($tablename){
45  static $instances = array();
46  if (!isset($instances[$tablename]) ){
47  $instances[$tablename] = new Dataface_RelationshipTool($tablename);
48  }
49  return $instances[$tablename];
50  }
51 
52 
53 
54  function isRemoveable($relationship_name){}
55  function isLinkable($relationship_name){}
56  function isUnlinkable($relationship_name){}
57 
58  function isAddable($relationship_name){
59  $r =& $this->_table->getRelationship($relationship_name);
60  $sql = $this->_table->parseString($r['sql']);
61  echo $sql;
62  $struct = $this->_parser->parse($sql);
63  print_r($struct);
64 
65  $where_clause = $struct['where_clause'];
66 
67 
68  }
69 
70 
71 
72 
73 
74 
75 
76 }