View Issue Details

This issue affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
12479Bug reportsDocumentationpublic2026-11-19 22:23
ReporterDenisChenu Assigned Touser14106 
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Summary12479: Add DB property in models
Description

DB property can be added in model to set default value : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/models/Survey.php#L99
But i think we have to add it in the phpDoc way and then have it in api : https://api.limesurvey.org/classes/Survey.html#sid

Steps To Reproduce

Maybe start by survey : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/models/Survey.php#L19

And set all of this in real @property

/**

  • @property integer $sid primary key
    */
    public $sid;

I'm totally unsure of the result ;)

Additional Information

I have to update too http://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_survey_properties but link \Survey must go to Survey with properties

TagsNo tags attached.
Bug heat6
Complete LimeSurvey version number (& build)
I will donate to the project if issue is resolved
Browser
Database type & version
Server OS (if known)
Webserver software & version (if known)
PHP Version
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2017-06-20 11:00

developer   ~43950

And add all the inherited doc too

DenisChenu

DenisChenu

2017-06-26 12:15

developer   ~43976

Ok, thanks to Carsten : link is https://api.limesurvey.org/classes/Survey.html#property_format

Then : seems better with @property than with @var . I'i unsure if we can use @property fo format (for example) because need a default ?

I make a test . @t6nnp6nn : fo you have an advice ?

user14106

2017-07-03 13:50

  ~44012

I'm not sure

What you want to achieve?

by default gii does not generate it in suggested way for Yii1 nor Yii2. It only generates the Class phpDoc with @property.

defining as class properties like

/**

  • @property integer $sid primary key
    */
    public $sid;

... changes how yii treats the properties in a way.

EG: in survey model we have a * @property string $state
and a method public function getState()

now state can be accessed dierectly via $oSurvey->state

But. If you add to class public $state;
then $oSurvey->state will be NULL and it will not use the getState().

It is not the case with DB properties but anyway - it does not seem to be the default yii way.

DenisChenu

DenisChenu

2017-07-04 00:35

developer   ~44019

I just want something better here :)

See https://api.limesurvey.org/classes/Survey.html#property_format and https://api.limesurvey.org/classes/Survey.html#property_htmlemail

Using property : loosing string ? Or i made an error ?
Using var : using the var name :/

https://github.com/LimeSurvey/LimeSurvey/blob/master/application/models/Survey.php#L96

I test with @var string $format A : All in one, G : Group by group, Q : question by question */
=> Same we loose the var name.

Maybe

/*

  • @var string
  • A : All in one, G : Group by group, Q : question by question
    */

? in description ?

user14106

2017-07-04 08:43

  ~44021

see
https://github.com/TonisOrmisson/LimeSurvey/commit/af862c3ab83c37d8aa273289e860a4f78e4acacc

put the docs in class docs and set default values in init()

?

DenisChenu

DenisChenu

2017-07-04 10:45

developer   ~44022

Don't like it, but if auto doc is better. @c_schmitz : https://api.limesurvey.org is up to date ?

user14106

2017-07-04 10:50

  ~44023

Don't like it why?

DenisChenu

DenisChenu

2017-07-04 11:13

developer   ~44024

Think it's more clear in class directly when looking at file

user14106

2017-07-04 11:23

  ~44025

What I suggest is the Yii way as far as I understand. As I said - defining a class property as you suggested makes Yii actually work differently (not just look differently)

DenisChenu

DenisChenu

2017-07-04 11:32

developer   ~44026

But we can always use use

$Survey= new Survey;
$Survey->admin = "The new one"

It's the DB property here :). I talk currently only for db property :).

user14106

2017-07-04 11:43

  ~44027

I also talk regarding the DB properties :) and by DB properties I mean the class properties that directly relate to DB columns.

DenisChenu

DenisChenu

2017-07-04 12:34

developer   ~44028

Then : DB properties are publicly accessible, no ?

user14106

2017-07-04 12:38

  ~44029

Yes, should be by Yii design
http://www.yiiframework.com/wiki/167/understanding-virtual-attributes-and-get-set-methods/

DenisChenu

DenisChenu

2017-07-04 12:59

developer   ~44030

Oh right, it's dynamic properties/attribute. You convinced me : “ put the docs in class docs and set default values in init()” seems the best solution :)

user14106

2017-07-04 13:10

  ~44031

:D

user14106

2017-07-04 13:49

  ~44032

https://github.com/LimeSurvey/LimeSurvey/pull/743

c_schmitz

c_schmitz

2026-11-19 22:23

administrator   ~87732

In LimeSurvey 7 the database columns of the models are documented with @property tags in the class docblocks, as agreed here (started with PR #743). Closing as done.

Issue History

Date Modified Username Field Change
2017-06-20 10:57 DenisChenu New Issue
2017-06-20 10:57 DenisChenu Status new => assigned
2017-06-20 10:57 DenisChenu Assigned To => Mazi
2017-06-20 10:58 DenisChenu Assigned To Mazi =>
2017-06-20 10:58 DenisChenu Status assigned => new
2017-06-20 11:00 DenisChenu Note Added: 43950
2017-06-26 12:15 DenisChenu Assigned To => user14106
2017-06-26 12:15 DenisChenu Status new => feedback
2017-06-26 12:15 DenisChenu Note Added: 43976
2017-07-03 13:50 user14106 Note Added: 44012
2017-07-04 00:35 DenisChenu Note Added: 44019
2017-07-04 00:35 DenisChenu Status feedback => assigned
2017-07-04 00:35 DenisChenu Status assigned => feedback
2017-07-04 08:43 user14106 Note Added: 44021
2017-07-04 10:45 DenisChenu Note Added: 44022
2017-07-04 10:45 DenisChenu Status feedback => assigned
2017-07-04 10:50 user14106 Note Added: 44023
2017-07-04 11:13 DenisChenu Note Added: 44024
2017-07-04 11:23 user14106 Note Added: 44025
2017-07-04 11:32 DenisChenu Note Added: 44026
2017-07-04 11:43 user14106 Note Added: 44027
2017-07-04 12:34 DenisChenu Note Added: 44028
2017-07-04 12:38 user14106 Note Added: 44029
2017-07-04 12:59 DenisChenu Note Added: 44030
2017-07-04 13:10 user14106 Note Added: 44031
2017-07-04 13:49 user14106 Note Added: 44032
2026-11-19 22:23 c_schmitz Note Added: 87732
2026-11-19 22:23 c_schmitz Bug heat 4 => 6
2026-11-19 22:23 c_schmitz Status assigned => closed
2026-11-19 22:23 c_schmitz Resolution open => fixed