PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/messigdp/include/Object/Messo.class.php

http://antilophpe.googlecode.com/
PHP | 375 lines | 203 code | 17 blank | 155 comment | 0 complexity | eb0af0eed84b3b43e1c2e2282a2ab420 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-3.0
  1. <?php
  2. /**
  3. * File Messo.class.php
  4. *
  5. * This file contains the definition of the class object
  6. * type Messo and at the end of the file,
  7. * a way to test the class (simply passing sending test = 1
  8. * via GET or POST ).
  9. * @author Marco Novo <mnovo@ncfsistemi.com>
  10. * @version 1.0
  11. */
  12. /**
  13. * This class defines fields and methods of Messo
  14. */
  15. class Messo {
  16. /**
  17. * $resourceLinkID
  18. * @access private
  19. * @var resource
  20. */
  21. private $resourceLinkID;
  22. /**
  23. * id
  24. * @access private
  25. * @var integer
  26. */
  27. private $id;
  28. /**
  29. * nome
  30. * @access private
  31. * @var string
  32. */
  33. private $nome;
  34. /**
  35. * idUtente
  36. * @access private
  37. * @var integer
  38. */
  39. private $idUtente;
  40. /**
  41. * idUtente_denomination
  42. * @access private
  43. * @var string
  44. */
  45. private $idUtente_denomination;
  46. /**
  47. * active
  48. * @access private
  49. * @var integer
  50. */
  51. private $active;
  52. /**
  53. * deleted
  54. * @access private
  55. * @var integer
  56. */
  57. private $deleted;
  58. /**
  59. * Set the value of resourceLinkID
  60. * @param resource $resourceLinkID
  61. */
  62. function setResourceLinkID($resourceLinkID){
  63. $this->resourceLinkID=$resourceLinkID;
  64. }
  65. /**
  66. * Get the value of resourceLinkID
  67. * @return resource
  68. */
  69. function getResourceLinkID(){
  70. return $this->resourceLinkID;
  71. }
  72. /**
  73. * Sets the value of field id
  74. * @param integer $id
  75. */
  76. function setId($id){
  77. $this->id=$id;
  78. }
  79. /**
  80. * Gets the value of field id
  81. * @return integer
  82. */
  83. function getId(){
  84. return $this->id;
  85. }
  86. /**
  87. * Sets the value of field nome
  88. * @param string $nome
  89. */
  90. function setNome($nome){
  91. $this->nome=$nome;
  92. }
  93. /**
  94. * Gets the value of field nome
  95. * @return string
  96. */
  97. function getNome(){
  98. return $this->nome;
  99. }
  100. /**
  101. * Sets the value of field idUtente
  102. * @param integer $idUtente
  103. */
  104. function setIdUtente($idUtente){
  105. $this->idUtente=$idUtente;
  106. }
  107. /**
  108. * Gets the value of field idUtente
  109. * @return integer
  110. */
  111. function getIdUtente(){
  112. return $this->idUtente;
  113. }
  114. /**
  115. * Sets the value of foreign field idUtente_denomination
  116. * @param string $idUtente_denomination
  117. */
  118. function setIdUtente_denomination($idUtente_denomination){
  119. $this->idUtente_denomination=$idUtente_denomination;
  120. }
  121. /**
  122. * Gets the value of foreign field idUtente_denomination
  123. * @return string
  124. */
  125. function getIdUtente_denomination(){
  126. return $this->idUtente_denomination;
  127. }
  128. /**
  129. * Sets the value of field active
  130. * @param integer $active
  131. */
  132. function setActive($active){
  133. $this->active=$active;
  134. }
  135. /**
  136. * Gets the value of field active
  137. * @return integer
  138. */
  139. function getActive(){
  140. return $this->active;
  141. }
  142. /**
  143. * Sets the value of field deleted
  144. * @param integer $deleted
  145. */
  146. function setDeleted($deleted){
  147. $this->deleted=$deleted;
  148. }
  149. /**
  150. * Gets the value of field deleted
  151. * @return integer
  152. */
  153. function getDeleted(){
  154. return $this->deleted;
  155. }
  156. /**
  157. * Constructor of the class
  158. */
  159. function __construct($resourceLinkID='',
  160. $id='',
  161. $nome='',
  162. $idUtente='',
  163. $idUtente_denomination='',
  164. $active='',
  165. $deleted='') {
  166. $this->resourceLinkID = $resourceLinkID;
  167. $this->id = $id;
  168. $this->nome = $nome;
  169. $this->idUtente = $idUtente;
  170. $this->idUtente_denomination = $idUtente_denomination;
  171. $this->active = $active;
  172. $this->deleted = $deleted;
  173. }
  174. /**
  175. * Destructor of the class
  176. */
  177. function __destruct() {
  178. }
  179. /**
  180. * Get the value of descriptive field
  181. * @return string
  182. */
  183. function getDescriptiveFields(){
  184. return trim(' (id: '.$this->getId().')');
  185. }
  186. /**
  187. * Get the name and the value of mail fields
  188. * @return string
  189. */
  190. function getMailFields(){
  191. return trim("Id: ".$this->getId()."\n"."Nome: ".$this->getNome()."\n"."Utente: ".$this->getIdUtente()."\n"."Active: ".$this->getActive()."\n"."Deleted: ".$this->getDeleted()."\n"."");
  192. }
  193. /**
  194. * Persistence selectById method (try to select)
  195. * @return true|false
  196. */
  197. function selectById(){
  198. $query='SELECT "ant_Messo".*,
  199. "ant_Utente"."denomination"
  200. FROM "ant_Messo"
  201. LEFT JOIN "ant_Utente" ON "ant_Utente"."id" = "ant_Messo"."idUtente"
  202. WHERE "ant_Messo"."id" = '.$this->getId();
  203. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo`: '.var_dump(oci_error()));
  204. oci_execute($result, OCI_DEFAULT);
  205. $messo_array=oci_fetch_array($result);
  206. $this->id = $messo_array['id'];
  207. $this->nome = $messo_array['nome'];
  208. $this->idUtente = $messo_array['idUtente'];
  209. $this->idUtente_denomination = $messo_array['denomination'];
  210. $this->active = $messo_array['active'];
  211. $this->deleted = $messo_array['deleted'];
  212. }
  213. /**
  214. * Persistence selectAsArrayById method (try to select)
  215. * @return true|false
  216. */
  217. function selectAsArrayById(){
  218. $query='SELECT "ant_Messo".*,
  219. "ant_Utente"."denomination"
  220. FROM "ant_Messo"
  221. LEFT JOIN "ant_Utente" ON "ant_Utente"."id" = "ant_Messo"."idUtente"
  222. WHERE "ant_Messo"."id" = '.$this->getId();
  223. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo`: '.var_dump(oci_error()));
  224. oci_execute($result, OCI_DEFAULT);
  225. $messo_array=oci_fetch_array($result);
  226. return $messo_array;
  227. }
  228. /**
  229. * Persistence listSelectablesByAndFields method (try to select)
  230. * @param array with filedName as key and fieldValue as value
  231. * @return list/array
  232. */
  233. function listSelectablesByAndFields($fieldsArray){
  234. foreach($fieldsArray as $key => $value)
  235. $whereString.=' AND "'.$key.'"="'.str_replace("'","''",$value).'"';
  236. $query='SELECT "ant_Messo".*,
  237. "ant_Utente"."denomination"
  238. FROM "ant_Messo"
  239. LEFT JOIN "ant_Utente" ON "ant_Utente"."id" = "ant_Messo"."idUtente"
  240. WHERE "ant_Messo"."active"=1
  241. AND "ant_Messo"."deleted"=0
  242. '.$whereString;
  243. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo`: '.var_dump(oci_error()));
  244. oci_execute($result, OCI_DEFAULT);
  245. $listRow=array();
  246. while($arrayRow=oci_fetch_array($result)){
  247. array_push($listRow,$arrayRow);
  248. }
  249. return $listRow;
  250. }
  251. /**
  252. * Persistence listSelectablesByOrFields method (try to select)
  253. * @param array with filedName as key and fieldValue as value
  254. * @return list/array
  255. */
  256. function listSelectablesByOrFields($fieldsArray){
  257. foreach($fieldsArray as $key => $value)
  258. $whereString.=' OR "'.$key.'"="'.str_replace("'","''",$value).'"';
  259. $query='SELECT "ant_Messo".*,
  260. "ant_Utente"."denomination"
  261. FROM "ant_Messo"
  262. LEFT JOIN "ant_Utente" ON "ant_Utente"."id" = "ant_Messo"."idUtente"
  263. WHERE "ant_Messo"."active"=1
  264. AND "ant_Messo"."deleted"=0
  265. AND (0 '.$whereString.');';
  266. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo`: '.var_dump(oci_error()));
  267. oci_execute($result, OCI_DEFAULT);
  268. $listRow=array();
  269. while($arrayRow=oci_fetch_array($result)){
  270. array_push($listRow,$arrayRow);
  271. }
  272. return $listRow;
  273. }
  274. /**
  275. * Persistence selectFiles method (try to select)
  276. * @return array
  277. */
  278. function selectFiles(){
  279. $query='SELECT "ant_Messo_File".*
  280. FROM "ant_Messo_File"
  281. WHERE "ant_Messo_File"."idTableObject"= '.$this->getId().'
  282. AND "ant_Messo_File"."tableObject"=\'ant_Messo\'';
  283. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo_File`: '.var_dump(oci_error()));
  284. oci_execute($result, OCI_DEFAULT);
  285. $filesList=array();
  286. while($messo_File_array=oci_fetch_array($result)){
  287. array_push($filesList, $messo_File_array);
  288. }
  289. return $filesList;
  290. }
  291. /**
  292. * Persistence selectFileById method (try to select)
  293. * @return array
  294. */
  295. function selectFileById($fileId){
  296. $query='SELECT "ant_Messo_File".*
  297. FROM "ant_Messo_File"
  298. WHERE "ant_Messo_File"."id"='.$fileId;
  299. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection file in table `ant_Messo_File`: '.var_dump(oci_error()));
  300. oci_execute($result, OCI_DEFAULT);
  301. $messo_File_array=oci_fetch_array($result);
  302. return $messo_File_array;
  303. }
  304. /**
  305. * Persistence selectCountFiles method (try to select)
  306. * @return array
  307. */
  308. function selectCountFiles(){
  309. $query='SELECT COUNT(*)
  310. FROM "ant_Messo_File"
  311. WHERE "ant_Messo_File"."idTableObject"= '.$this->getId().'
  312. AND "ant_Messo_File"."tableObject"=\'ant_Messo\'';
  313. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo_File`: '.var_dump(oci_error()));
  314. oci_execute($result, OCI_DEFAULT);
  315. $messo_File_array=oci_fetch_array($result);
  316. return $messo_File_array[0];
  317. }
  318. /**
  319. * Persistence selectCountLogs method (try to select count)
  320. * @return integer
  321. */
  322. function selectCountLogs(){
  323. $query='SELECT COUNT(*)
  324. FROM "ant_Messo_Log"';
  325. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during select count from table `ant_Messo_Log`: '.var_dump(oci_error()));
  326. oci_execute($result, OCI_DEFAULT);
  327. $messo_Log_array=oci_fetch_array($result);
  328. return $messo_Log_array[0];
  329. }
  330. /**
  331. * Persistence selectCountTrashes method (try to select count)
  332. * @return integer
  333. */
  334. function selectCountTrashes(){
  335. $query='SELECT COUNT(*)
  336. FROM "ant_Messo"
  337. WHERE "deleted" = 1';
  338. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during select count from table `ant_Messo`: '.var_dump(oci_error()));
  339. oci_execute($result, OCI_DEFAULT);
  340. $messo_array=oci_fetch_array($result);
  341. return $messo_array[0];
  342. }
  343. /**
  344. * Persistence selectByFileId method (try to select)
  345. * @return true|false
  346. */
  347. function selectByFileId($idFile){
  348. $query='SELECT "ant_Messo_File".*
  349. FROM "ant_Messo_File"
  350. WHERE "ant_Messo_File"."id" = '.$idFile;
  351. $result = oci_parse($this->getResourceLinkId(), $query) or die('Query:<hr/> '.$query.'<hr/>Error during selection in table `ant_Messo_File`: '.var_dump(oci_error()));
  352. oci_execute($result, OCI_DEFAULT);
  353. return oci_fetch_array($result);
  354. }
  355. }
  356. ?>