expression.class.inc.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * General definition of an expression tree (could be OQL, SQL or whatever)
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. class MissingQueryArgument extends CoreException
  25. {
  26. }
  27. abstract class Expression
  28. {
  29. // recursive translation of identifiers
  30. abstract public function GetUnresolvedFields($sAlias, &$aUnresolved);
  31. abstract public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true);
  32. // recursive rendering (aArgs used as input by default, or used as output if bRetrofitParams set to True
  33. abstract public function Render(&$aArgs = null, $bRetrofitParams = false);
  34. // recursively builds an array of class => fieldname
  35. abstract public function ListRequiredFields();
  36. abstract public function IsTrue();
  37. public function RequiresField($sClass, $sFieldName)
  38. {
  39. // #@# todo - optimize : this is called quite often when building a single query !
  40. $aRequired = $this->ListRequiredFields();
  41. if (!in_array($sClass.'.'.$sFieldName, $aRequired)) return false;
  42. return true;
  43. }
  44. public function serialize()
  45. {
  46. return base64_encode($this->Render());
  47. }
  48. static public function unserialize($sValue)
  49. {
  50. return self::FromOQL(base64_decode($sValue));
  51. }
  52. static public function FromOQL($sConditionExpr)
  53. {
  54. $oOql = new OqlInterpreter($sConditionExpr);
  55. $oExpression = $oOql->ParseExpression();
  56. return $oExpression;
  57. }
  58. static public function FromSQL($sSQL)
  59. {
  60. $oSql = new SQLExpression($sSQL);
  61. return $oSql;
  62. }
  63. public function LogAnd($oExpr)
  64. {
  65. if ($this->IsTrue()) return clone $oExpr;
  66. if ($oExpr->IsTrue()) return clone $this;
  67. return new BinaryExpression($this, 'AND', $oExpr);
  68. }
  69. public function LogOr($oExpr)
  70. {
  71. return new BinaryExpression($this, 'OR', $oExpr);
  72. }
  73. }
  74. class SQLExpression extends Expression
  75. {
  76. protected $m_sSQL;
  77. public function __construct($sSQL)
  78. {
  79. $this->m_sSQL = $sSQL;
  80. }
  81. public function IsTrue()
  82. {
  83. return false;
  84. }
  85. // recursive rendering
  86. public function Render(&$aArgs = null, $bRetrofitParams = false)
  87. {
  88. return $this->m_sSQL;
  89. }
  90. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  91. {
  92. }
  93. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  94. {
  95. return clone $this;
  96. }
  97. public function ListRequiredFields()
  98. {
  99. return array();
  100. }
  101. }
  102. class BinaryExpression extends Expression
  103. {
  104. protected $m_oLeftExpr; // filter code or an SQL expression (later?)
  105. protected $m_oRightExpr;
  106. protected $m_sOperator;
  107. public function __construct($oLeftExpr, $sOperator, $oRightExpr)
  108. {
  109. if (!is_object($oLeftExpr))
  110. {
  111. throw new CoreException('Expecting an Expression object on the left hand', array('found_type' => gettype($oLeftExpr)));
  112. }
  113. if (!is_object($oRightExpr))
  114. {
  115. throw new CoreException('Expecting an Expression object on the right hand', array('found_type' => gettype($oRightExpr)));
  116. }
  117. if (!$oLeftExpr instanceof Expression)
  118. {
  119. throw new CoreException('Expecting an Expression object on the left hand', array('found_class' => get_class($oLeftExpr)));
  120. }
  121. if (!$oRightExpr instanceof Expression)
  122. {
  123. throw new CoreException('Expecting an Expression object on the right hand', array('found_class' => get_class($oRightExpr)));
  124. }
  125. $this->m_oLeftExpr = $oLeftExpr;
  126. $this->m_oRightExpr = $oRightExpr;
  127. $this->m_sOperator = $sOperator;
  128. }
  129. public function IsTrue()
  130. {
  131. // return true if we are certain that it will be true
  132. if ($this->m_sOperator == 'AND')
  133. {
  134. if ($this->m_oLeftExpr->IsTrue() && $this->m_oLeftExpr->IsTrue()) return true;
  135. }
  136. return false;
  137. }
  138. public function GetLeftExpr()
  139. {
  140. return $this->m_oLeftExpr;
  141. }
  142. public function GetRightExpr()
  143. {
  144. return $this->m_oRightExpr;
  145. }
  146. public function GetOperator()
  147. {
  148. return $this->m_sOperator;
  149. }
  150. // recursive rendering
  151. public function Render(&$aArgs = null, $bRetrofitParams = false)
  152. {
  153. $sOperator = $this->GetOperator();
  154. $sLeft = $this->GetLeftExpr()->Render($aArgs, $bRetrofitParams);
  155. $sRight = $this->GetRightExpr()->Render($aArgs, $bRetrofitParams);
  156. return "($sLeft $sOperator $sRight)";
  157. }
  158. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  159. {
  160. $this->GetLeftExpr()->GetUnresolvedFields($sAlias, $aUnresolved);
  161. $this->GetRightExpr()->GetUnresolvedFields($sAlias, $aUnresolved);
  162. }
  163. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  164. {
  165. $oLeft = $this->GetLeftExpr()->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  166. $oRight = $this->GetRightExpr()->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  167. return new BinaryExpression($oLeft, $this->GetOperator(), $oRight);
  168. }
  169. public function ListRequiredFields()
  170. {
  171. $aLeft = $this->GetLeftExpr()->ListRequiredFields();
  172. $aRight = $this->GetRightExpr()->ListRequiredFields();
  173. return array_merge($aLeft, $aRight);
  174. }
  175. }
  176. class UnaryExpression extends Expression
  177. {
  178. protected $m_value;
  179. public function __construct($value)
  180. {
  181. $this->m_value = $value;
  182. }
  183. public function IsTrue()
  184. {
  185. // return true if we are certain that it will be true
  186. return ($this->m_value == 1);
  187. }
  188. public function GetValue()
  189. {
  190. return $this->m_value;
  191. }
  192. // recursive rendering
  193. public function Render(&$aArgs = null, $bRetrofitParams = false)
  194. {
  195. if ($bRetrofitParams)
  196. {
  197. $iParamIndex = count($aArgs) + 1; // 1-based indexation
  198. $aArgs['param'.$iParamIndex] = $this->m_value;
  199. return ':param'.$iParamIndex;
  200. }
  201. else
  202. {
  203. return CMDBSource::Quote($this->m_value);
  204. }
  205. }
  206. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  207. {
  208. }
  209. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  210. {
  211. return clone $this;
  212. }
  213. public function ListRequiredFields()
  214. {
  215. return array();
  216. }
  217. }
  218. class ScalarExpression extends UnaryExpression
  219. {
  220. public function __construct($value)
  221. {
  222. if (!is_scalar($value))
  223. {
  224. throw new CoreException('Attempt to create a scalar expression from a non scalar', array('var_type'=>gettype($value)));
  225. }
  226. parent::__construct($value);
  227. }
  228. }
  229. class TrueExpression extends ScalarExpression
  230. {
  231. public function __construct()
  232. {
  233. parent::__construct(1);
  234. }
  235. public function IsTrue()
  236. {
  237. return true;
  238. }
  239. }
  240. class FalseExpression extends ScalarExpression
  241. {
  242. public function __construct()
  243. {
  244. parent::__construct(0);
  245. }
  246. public function IsTrue()
  247. {
  248. return false;
  249. }
  250. }
  251. class FieldExpression extends UnaryExpression
  252. {
  253. protected $m_sParent;
  254. protected $m_sName;
  255. public function __construct($sName, $sParent = '')
  256. {
  257. parent::__construct("$sParent.$sName");
  258. $this->m_sParent = $sParent;
  259. $this->m_sName = $sName;
  260. }
  261. public function IsTrue()
  262. {
  263. // return true if we are certain that it will be true
  264. return false;
  265. }
  266. public function GetParent() {return $this->m_sParent;}
  267. public function GetName() {return $this->m_sName;}
  268. // recursive rendering
  269. public function Render(&$aArgs = null, $bRetrofitParams = false)
  270. {
  271. if (empty($this->m_sParent))
  272. {
  273. return "`{$this->m_sName}`";
  274. }
  275. return "`{$this->m_sParent}`.`{$this->m_sName}`";
  276. }
  277. public function ListRequiredFields()
  278. {
  279. return array($this->m_sParent.'.'.$this->m_sName);
  280. }
  281. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  282. {
  283. if ($this->m_sParent == $sAlias)
  284. {
  285. // Add a reference to the field
  286. $aUnresolved[$this->m_sName] = $this;
  287. }
  288. }
  289. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  290. {
  291. if (!array_key_exists($this->m_sParent, $aTranslationData))
  292. {
  293. if ($bMatchAll) throw new CoreException('Unknown parent id in translation table', array('parent_id' => $this->m_sParent, 'translation_table' => array_keys($aTranslationData)));
  294. return clone $this;
  295. }
  296. if (!array_key_exists($this->m_sName, $aTranslationData[$this->m_sParent]))
  297. {
  298. if (!array_key_exists('*', $aTranslationData[$this->m_sParent]))
  299. {
  300. // #@# debug - if ($bMatchAll) MyHelpers::var_dump_html($aTranslationData, true);
  301. if ($bMatchAll) throw new CoreException('Unknown name in translation table', array('name' => $this->m_sName, 'parent_id' => $this->m_sParent, 'translation_table' => array_keys($aTranslationData[$this->m_sParent])));
  302. return clone $this;
  303. }
  304. $sNewParent = $aTranslationData[$this->m_sParent]['*'];
  305. $sNewName = $this->m_sName;
  306. if ($bMarkFieldsAsResolved)
  307. {
  308. $oRet = new FieldExpressionResolved($sNewName, $sNewParent);
  309. }
  310. else
  311. {
  312. $oRet = new FieldExpression($sNewName, $sNewParent);
  313. }
  314. }
  315. else
  316. {
  317. $oRet = $aTranslationData[$this->m_sParent][$this->m_sName];
  318. }
  319. return $oRet;
  320. }
  321. }
  322. // Has been resolved into an SQL expression
  323. class FieldExpressionResolved extends FieldExpression
  324. {
  325. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  326. {
  327. }
  328. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  329. {
  330. return clone $this;
  331. }
  332. }
  333. class VariableExpression extends UnaryExpression
  334. {
  335. protected $m_sName;
  336. public function __construct($sName)
  337. {
  338. parent::__construct($sName);
  339. $this->m_sName = $sName;
  340. }
  341. public function IsTrue()
  342. {
  343. // return true if we are certain that it will be true
  344. return false;
  345. }
  346. public function GetName() {return $this->m_sName;}
  347. // recursive rendering
  348. public function Render(&$aArgs = null, $bRetrofitParams = false)
  349. {
  350. if (is_null($aArgs))
  351. {
  352. return ':'.$this->m_sName;
  353. }
  354. elseif (array_key_exists($this->m_sName, $aArgs))
  355. {
  356. return CMDBSource::Quote($aArgs[$this->m_sName]);
  357. }
  358. elseif ($bRetrofitParams)
  359. {
  360. //$aArgs[$this->m_sName] = null;
  361. return ':'.$this->m_sName;
  362. }
  363. else
  364. {
  365. throw new MissingQueryArgument('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>$aArgs));
  366. }
  367. }
  368. }
  369. // Temporary, until we implement functions and expression casting!
  370. // ... or until we implement a real full text search based in the MATCH() expression
  371. class ListExpression extends Expression
  372. {
  373. protected $m_aExpressions;
  374. public function __construct($aExpressions)
  375. {
  376. $this->m_aExpressions = $aExpressions;
  377. }
  378. public static function FromScalars($aScalars)
  379. {
  380. $aExpressions = array();
  381. foreach($aScalars as $value)
  382. {
  383. $aExpressions[] = new ScalarExpression($value);
  384. }
  385. return new ListExpression($aExpressions);
  386. }
  387. public function IsTrue()
  388. {
  389. // return true if we are certain that it will be true
  390. return false;
  391. }
  392. public function GetItems()
  393. {
  394. return $this->m_aExpressions;
  395. }
  396. // recursive rendering
  397. public function Render(&$aArgs = null, $bRetrofitParams = false)
  398. {
  399. $aRes = array();
  400. foreach ($this->m_aExpressions as $oExpr)
  401. {
  402. $aRes[] = $oExpr->Render($aArgs, $bRetrofitParams);
  403. }
  404. return '('.implode(', ', $aRes).')';
  405. }
  406. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  407. {
  408. foreach ($this->m_aExpressions as $oExpr)
  409. {
  410. $oExpr->GetUnresolvedFields($sAlias, $aUnresolved);
  411. }
  412. }
  413. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  414. {
  415. $aRes = array();
  416. foreach ($this->m_aExpressions as $oExpr)
  417. {
  418. $aRes[] = $oExpr->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  419. }
  420. return new ListExpression($aRes);
  421. }
  422. public function ListRequiredFields()
  423. {
  424. $aRes = array();
  425. foreach ($this->m_aExpressions as $oExpr)
  426. {
  427. $aRes = array_merge($aRes, $oExpr->ListRequiredFields());
  428. }
  429. return $aRes;
  430. }
  431. }
  432. class FunctionExpression extends Expression
  433. {
  434. protected $m_sVerb;
  435. protected $m_aArgs; // array of expressions
  436. public function __construct($sVerb, $aArgExpressions)
  437. {
  438. $this->m_sVerb = $sVerb;
  439. $this->m_aArgs = $aArgExpressions;
  440. }
  441. public function IsTrue()
  442. {
  443. // return true if we are certain that it will be true
  444. return false;
  445. }
  446. public function GetVerb()
  447. {
  448. return $this->m_sVerb;
  449. }
  450. public function GetArgs()
  451. {
  452. return $this->m_aArgs;
  453. }
  454. // recursive rendering
  455. public function Render(&$aArgs = null, $bRetrofitParams = false)
  456. {
  457. $aRes = array();
  458. foreach ($this->m_aArgs as $oExpr)
  459. {
  460. $aRes[] = $oExpr->Render($aArgs, $bRetrofitParams);
  461. }
  462. return $this->m_sVerb.'('.implode(', ', $aRes).')';
  463. }
  464. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  465. {
  466. foreach ($this->m_aArgs as $oExpr)
  467. {
  468. $oExpr->GetUnresolvedFields($sAlias, $aUnresolved);
  469. }
  470. }
  471. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  472. {
  473. $aRes = array();
  474. foreach ($this->m_aArgs as $oExpr)
  475. {
  476. $aRes[] = $oExpr->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  477. }
  478. return new FunctionExpression($this->m_sVerb, $aRes);
  479. }
  480. public function ListRequiredFields()
  481. {
  482. $aRes = array();
  483. foreach ($this->m_aArgs as $oExpr)
  484. {
  485. $aRes = array_merge($aRes, $oExpr->ListRequiredFields());
  486. }
  487. return $aRes;
  488. }
  489. }
  490. class IntervalExpression extends Expression
  491. {
  492. protected $m_oValue; // expression
  493. protected $m_sUnit;
  494. public function __construct($oValue, $sUnit)
  495. {
  496. $this->m_oValue = $oValue;
  497. $this->m_sUnit = $sUnit;
  498. }
  499. public function IsTrue()
  500. {
  501. // return true if we are certain that it will be true
  502. return false;
  503. }
  504. public function GetValue()
  505. {
  506. return $this->m_oValue;
  507. }
  508. public function GetUnit()
  509. {
  510. return $this->m_sUnit;
  511. }
  512. // recursive rendering
  513. public function Render(&$aArgs = null, $bRetrofitParams = false)
  514. {
  515. return 'INTERVAL '.$this->m_oValue->Render($aArgs, $bRetrofitParams).' '.$this->m_sUnit;
  516. }
  517. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  518. {
  519. $this->m_oValue->GetUnresolvedFields($sAlias, $aUnresolved);
  520. }
  521. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  522. {
  523. return new IntervalExpression($this->m_oValue->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved), $this->m_sUnit);
  524. }
  525. public function ListRequiredFields()
  526. {
  527. return array();
  528. }
  529. }
  530. class CharConcatExpression extends Expression
  531. {
  532. protected $m_aExpressions;
  533. public function __construct($aExpressions)
  534. {
  535. $this->m_aExpressions = $aExpressions;
  536. }
  537. public function IsTrue()
  538. {
  539. // return true if we are certain that it will be true
  540. return false;
  541. }
  542. public function GetItems()
  543. {
  544. return $this->m_aExpressions;
  545. }
  546. // recursive rendering
  547. public function Render(&$aArgs = null, $bRetrofitParams = false)
  548. {
  549. $aRes = array();
  550. foreach ($this->m_aExpressions as $oExpr)
  551. {
  552. $sCol = $oExpr->Render($aArgs, $bRetrofitParams);
  553. // Concat will be globally NULL if one single argument is null !
  554. $aRes[] = "COALESCE($sCol, '')";
  555. }
  556. return "CAST(CONCAT(".implode(', ', $aRes).") AS CHAR)";
  557. }
  558. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  559. {
  560. foreach ($this->m_aExpressions as $oExpr)
  561. {
  562. $oExpr->GetUnresolvedFields($sAlias, $aUnresolved);
  563. }
  564. }
  565. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  566. {
  567. $aRes = array();
  568. foreach ($this->m_aExpressions as $oExpr)
  569. {
  570. $aRes[] = $oExpr->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  571. }
  572. return new CharConcatExpression($aRes);
  573. }
  574. public function ListRequiredFields()
  575. {
  576. $aRes = array();
  577. foreach ($this->m_aExpressions as $oExpr)
  578. {
  579. $aRes = array_merge($aRes, $oExpr->ListRequiredFields());
  580. }
  581. return $aRes;
  582. }
  583. }
  584. class CharConcatWSExpression extends CharConcatExpression
  585. {
  586. protected $m_separator;
  587. public function __construct($separator, $aExpressions)
  588. {
  589. $this->m_separator = $separator;
  590. parent::__construct($aExpressions);
  591. }
  592. // recursive rendering
  593. public function Render(&$aArgs = null, $bRetrofitParams = false)
  594. {
  595. $aRes = array();
  596. foreach ($this->m_aExpressions as $oExpr)
  597. {
  598. $sCol = $oExpr->Render($aArgs, $bRetrofitParams);
  599. // Concat will be globally NULL if one single argument is null !
  600. $aRes[] = "COALESCE($sCol, '')";
  601. }
  602. $sSep = CMDBSource::Quote($this->m_separator);
  603. return "CAST(CONCAT_WS($sSep, ".implode(', ', $aRes).") AS CHAR)";
  604. }
  605. }
  606. class QueryBuilderExpressions
  607. {
  608. protected $m_oConditionExpr;
  609. protected $m_aSelectExpr;
  610. protected $m_aJoinFields;
  611. public function __construct($aSelect, $oCondition)
  612. {
  613. $this->m_oConditionExpr = $oCondition;
  614. $this->m_aSelectExpr = $aSelect;
  615. $this->m_aJoinFields = array();
  616. }
  617. public function GetSelect()
  618. {
  619. return $this->m_aSelectExpr;
  620. }
  621. public function GetCondition()
  622. {
  623. return $this->m_oConditionExpr;
  624. }
  625. public function PopJoinField()
  626. {
  627. return array_pop($this->m_aJoinFields);
  628. }
  629. public function AddSelect($sAttAlias, $oExpression)
  630. {
  631. $this->m_aSelectExpr[$sAttAlias] = $oExpression;
  632. }
  633. //$oConditionTree = $oConditionTree->LogAnd($oFinalClassRestriction);
  634. public function AddCondition($oExpression)
  635. {
  636. $this->m_oConditionExpr = $this->m_oConditionExpr->LogAnd($oExpression);
  637. }
  638. public function PushJoinField($oExpression)
  639. {
  640. array_push($this->m_aJoinFields, $oExpression);
  641. }
  642. public function GetUnresolvedFields($sAlias, &$aUnresolved)
  643. {
  644. $this->m_oConditionExpr->GetUnresolvedFields($sAlias, $aUnresolved);
  645. foreach($this->m_aSelectExpr as $sColAlias => $oExpr)
  646. {
  647. $oExpr->GetUnresolvedFields($sAlias, $aUnresolved);
  648. }
  649. foreach($this->m_aJoinFields as $oExpression)
  650. {
  651. $oExpression->GetUnresolvedFields($sAlias, $aUnresolved);
  652. }
  653. }
  654. public function Translate($aTranslationData, $bMatchAll = true, $bMarkFieldsAsResolved = true)
  655. {
  656. $this->m_oConditionExpr = $this->m_oConditionExpr->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  657. foreach($this->m_aSelectExpr as $sColAlias => $oExpr)
  658. {
  659. $this->m_aSelectExpr[$sColAlias] = $oExpr->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  660. }
  661. foreach($this->m_aJoinFields as $index => $oExpression)
  662. {
  663. $this->m_aJoinFields[$index] = $oExpression->Translate($aTranslationData, $bMatchAll, $bMarkFieldsAsResolved);
  664. }
  665. }
  666. }
  667. ?>