Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezquestionchoice.php
Go to the documentation of this file.
1 <?php
4 Class eZQuestionChoice
5 {
6 function __construct( $id = "-1" )
7 {
8 if ( $id != -1 )
9 {
10 $this->ID = $id;
11 $this->get( $this->ID );
12 }
13 }
14
15 function get( $id = "-1" )
16 {
17 $SqlQuery = "SELECT
18 ID,
19 QuestionID,
20 Content,
21 Value
22 FROM
23 eZSurvey_QuestionChoice
24 WHERE
25 ID = '$id'";
26
27 $db =& eZDB::globalDatabase();
28
29 $db->array_query( $object_array, $SqlQuery );
30 if ( count( $object_array ) > 1 )
31 {
32 die( "Error: More than one object with the same ID found." );
33 }
34 elseif ( count( $object_array ) == 1 )
35 {
36 $this->ID = $object_array[ 0 ][ "ID" ];
37 $this->QuestionID = $object_array[ 0 ][ "QuestionID" ];
38 $this->Content = $object_array[ 0 ][ "Content" ];
39 $this->Value = $object_array[ 0 ][ "Value" ];
40
41 return $this;
42 }
43 }
44
45 function store()
46 {
47 $ret = false;
48 $db =& eZDB::globalDatabase();
49 $db->begin();
50
51 if ( !isSet( $this->ID) )
52 {
53 // create
54 $db->lock( "eZSurvey_QuestionChoice" );
55 $this->ID = $db->nextID( "eZSurvey_QuestionChoice", "ID" );
56 $res[] = $db->query( "INSERT INTO eZSurvey_QuestionChoice
57 (ID, QuestionID, Content, Value)
58 VALUES (
59 '$this->ID',
60 '$this->QuestionID',
61 '$this->Content',
62 '$this->Value'
63 )");
64
65 $db->unlock();
66 }
67 else
68 {
69 // update
70 $db->lock( "eZSurvey_QuestionChoice" );
71 $res[] = $db->query( "UPDATE eZSurvey_QuestionChoice set
72 ID = '$this->ID',
73 QuestionID = '$this->QuestionID',
74 Content = '$this->Content',
75 Value = '$this->Value'
76 WHERE ID = '$this->ID'");
77
78 $db->unlock();
79 }
80 eZDB::finish( $res, $db );
81 return true;
82 }
83
84 function delete()
85 {
86 $db =& eZDB::globalDatabase();
87 $db->begin();
88
89 $res[] = $db->query( "DELETE FROM eZSurvey_QuestionChoice WHERE ID='$this->ID'" );
90
91 eZDB::finish( $res, $db );
92 }
93
94 function isOther()
95 {
96 if ( strtolower($this->Content) == "!other" )
97 return true;
98 else
99 return false;
100 }
101
102 // get functions
103 function id() { return $this->ID; }
104 function questionID() { return $this->QuestionID; }
105 function content() { return $this->Content; }
106 function value() { return $this->Value; }
107
108 // set functions
109 function setID( $value ) { $this->ID = $value; }
110 function setQuestionID( $value ) { $this->QuestionID = $value; }
111 function setContent( $value ) { $this->Content = $value; }
112 function setValue( $value ) { $this->Value = $value; }
113
114 // internal variables
115 var $ID;
116 var $QuestionID;
117 var $Content;
118 var $Value;
119 }
120
121 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$Content
$Content
Definition: ezquestionchoice.php:117
eZQuestionChoice
Class eZQuestionChoice
Definition: ezquestionchoice.php:5
$Value
$Value
Definition: ezquestionchoice.php:118
$QuestionID
$QuestionID
Definition: ezquestionchoice.php:116
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.