@@ -131,12 +131,27 @@ public function getValue($var, $key, $dao)
131
131
}
132
132
else if ($ this ->_mainData [$ var ]['type ' ] == MIDAS_DATA && $ key !=null )
133
133
{
134
- /*$result = $this->fetchRow($this->select()->where($this->_key . ' = ?', $key));
135
- if (!isset($result->$var))
134
+ try
136
135
{
137
- return null;
136
+ $ columnfamily = new ColumnFamily ($ this ->_db ,$ this ->_name );
137
+ $ resultarray = $ columnfamily ->get ($ key ); // retrieve only what we want
138
+ if (!isset ($ resultarray [$ var ]))
139
+ {
140
+ throw new Zend_Exception ('MIDASDatabaseCassandra::getValue() MIDAS_DATA not found. CF= ' .$ this ->_name .' and var= ' .$ var );
141
+ return null ;
142
+ }
143
+ return $ resultarray [$ var ];
138
144
}
139
- return $result->$var;*/
145
+ catch (cassandra_NotFoundException $ e )
146
+ {
147
+ throw new Zend_Exception ('MIDASDatabaseCassandra::getValue() MIDAS_DATA not found. CF= ' .$ this ->_name .' and var= ' .$ var );
148
+ return null ;
149
+ }
150
+ catch (Exception $ e )
151
+ {
152
+ throw new Zend_Exception ($ e );
153
+ }
154
+
140
155
}
141
156
else if ($ this ->_mainData [$ var ]['type ' ] == MIDAS_ONE_TO_MANY )
142
157
{
@@ -147,17 +162,25 @@ public function getValue($var, $key, $dao)
147
162
{
148
163
throw new Zend_Exception ($ this ->_mainData [$ var ]['parent_column ' ]. " is not defined in the dao: " .get_class ($ dao ));
149
164
}
165
+ throw new Zend_Exception ('MIDASDatabaseCassandra::getValue() MIDAS_ONE_TO_MANY not defined yet. You can implement it if you want :) ' );
166
+
150
167
//return $model->__call("findBy" . ucfirst($this->_mainData[$var]['child_column']), array($dao->get($this->_mainData[$var]['parent_column'])));
151
168
}
152
169
else if ($ this ->_mainData [$ var ]['type ' ] == MIDAS_MANY_TO_ONE )
153
170
{
154
171
require_once BASE_PATH .'/library/MIDAS/models/ModelLoader.php ' ;
155
172
$ this ->ModelLoader = new MIDAS_ModelLoader ();
156
173
$ model = $ this ->ModelLoader ->loadModel ($ this ->_mainData [$ var ]['model ' ]);
157
- //return $model->__call("getBy" . ucfirst($this->_mainData[$var]['child_column']), array($dao->get($this->_mainData[$var]['parent_column'])));
174
+ if (!method_exists ($ model , 'getBy ' .ucfirst ($ this ->_mainData [$ var ]['child_column ' ])))
175
+ {
176
+ throw new Zend_Exception (get_class ($ model ).'::getBy ' .ucfirst ($ this ->_mainData [$ var ]['child_column ' ])." is not implemented " );
177
+ }
178
+ return call_user_func (array ($ model ,'getBy ' .ucfirst ($ this ->_mainData [$ var ]['child_column ' ])),
179
+ array ($ dao ->get ($ this ->_mainData [$ var ]['parent_column ' ])));
158
180
}
159
181
else if ($ this ->_mainData [$ var ]['type ' ] == MIDAS_MANY_TO_MANY )
160
182
{
183
+ throw new Zend_Exception ('MIDASDatabaseCassandra::getValue() MIDAS_MANY_TO_MANY not defined yet. You can implement it if you want :) ' );
161
184
//return $this->getLinkedObject($var, $dao);
162
185
}
163
186
else
0 commit comments