View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Supportez nous sur Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - [API Bug] Values of SqlElements inside a SqlElements aren't fetched - ProjeQtOr

Prochaines Sessions

Les prochaines formations et démonstrations sont ouvertes, inscrivez-vous rapidement !

 

Démonstration de ProjeQtOr

(gratuit, sur inscription)
 

13 mai 2025 (10h30-12h)

5 juin 2025 (16h-17h30)

 
 

Planifiez avec ProjeQtOr

14 et 15 mai 2025 (9h-12h30)

18 et 19 juin 2025 (9h-12h30)

 
 

Administrez avec ProjeQtOr

20 et 21 mai (9h-12h30)

25 et 26 juin (9h-12h30)

 

 

 

[API Bug] Values of SqlElements inside a SqlElements aren't fetched

More
21 Fév 2014 16:58 - 21 Fév 2014 17:03 #1 by Simon Tremblay
Hello,

I was trying the new API from version 4.1. I tried to retrieve progress of all of my projects and it happened that it returns to me 0. I found that progress is not a variable from Project but it is a variable from a PlanningElement that is a member variable of Project.



So I assumed that only the data for Project was retrieved from database and not the one for the other sql elements inside a Project...

You will find my attempt to fix that bug with a patch attached with this post (I work with git).

Basically, I defined a new function
getAllSqlElementsFromCriteria

We must define it for each SqlElements containing other SqlElements. Surely there is a better way to achieve that...

Here it is how I fixed Project (I know there is other SqlElements than Project that contains SqlElements but I don't use them for now):
public function getAllSqlElementsFromCriteria($critArray, $initializeIfEmpty=false, $clauseWhere=null, $clauseOrderBy=null, 
                                                $getIdInKey=false, $withoutDependentObjects=false, $maxElements=null) {
      $projects = array();
      $projects = parent::getAllSqlElementsFromCriteria($critArray, $initializeIfEmpty, $clauseWhere, $clauseOrderBy,
              $getIdInKey, $withoutDependentObjects, $maxElements);
      foreach ($projects as $project) {
        $project->ProjectPlanningElement = SqlElement::getSingleSqlElementFromCriteria('ProjectPlanningElement', array('refType'=>'Project', 'refId'=>$project->id));
      }
      
      return $projects;
  }

The patch:

File Attachment:

File Name: fix_api_bu...atch.zip
File Size:2 KB
Attachments:
Last edit: 21 Fév 2014 17:03 by Simon Tremblay.

Please Connexion or Create an account to join the conversation.

More
23 Fév 2014 12:16 #2 by babynus
Hi,

Thanks for this analysis.

Your solution is a good workaround, but as you wrote, I think there is more simple.
I'll have a look.

Ticket 1306 recorded.

Babynus
Administrator of ProjeQtOr web site

Please Connexion or Create an account to join the conversation.

More
01 Mar 2014 13:55 - 01 Mar 2014 13:56 #3 by babynus
In the end, fixing is much more simple. :woohoo:
In /model/persistence/SqlElement.php, replace lines 1458 :
if (! $withoutDependentObjects) {
	$obj->getDependantSqlElement($col_name);
}
with
if (! $withoutDependentObjects) {
	$obj->$col_name=$obj->getDependantSqlElement($col_name);
}

In fact, it was a bug :(
and an old one... :blush:

Babynus
Administrator of ProjeQtOr web site
Last edit: 01 Mar 2014 13:56 by babynus.

Please Connexion or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.049 seconds

Paramétrages de cookies

×

Cookies fonctionnels

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Veuillez vous connecter pour voir vos activités!

Autres cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.