Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
How can I make the model class a variable, with Propel?
$c = new Criteria();
$c->add(WssOracleUserCoursePeer::USER_ID, $userid);
$c->add(WssOracleUserCoursePeer::COURSE_ID, $courseId);
$userCourse = WssOracleUserCoursePeer::doSelectOne($c);
if ($userCourse->getStatus() == "C") {
return false;
}Now I want to change WssOracleUserCoursePeer to a variable that changes depending on circumstance. Simply doing this gives parse errors:
$c = new Criteria();
$c->add($model::USER_ID, $userid);
$c->add($model::COURSE_ID, $courseId);
$userCourse = $model::doSelectOne($c);
if ($userCourse->getStatus() == "C") {
return false;
}and this also fails:
$c = new Criteria();
$c->add({$model}::USER_ID, $userid);
$c->add({$model}::COURSE_ID, $courseId);
$userCourse = {$model}::doSelectOne($c);
if ($userCourse->getStatus() == "C") {
return false;
}So how do I do this?
This question has been answered.
Lawrence Krubner | 06/25/10 at 4:28pm
Edit
(4) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
06/27/10
1:16pmPascal says:Hi, you can try :
$c = new Criteria();
$c->add(constant($model . '::USER_ID'), $userid);
$c->add(constant($model . '::COURSE_ID'), $courseId);
$userCourse = call_user_func(array($model, 'doSelectOne'), $c);
if ($userCourse->getStatus() == "C") {
return false;
}
-

Last edited:
06/25/10
4:38pmArturo Linares says:That is fixed on PHP 5.3.
Try using the function constant($model.'::USER_ID'); in prior versions.
-
Last edited:
06/25/10
4:39pmFrancesco Tassi says:it's not really propel related but php related:
you can get constant value using
constant($model.'::COURSE_ID');
and call the doSelectXXX methods using (not sure if both work)
call_user_func($model.'::doSelectOne', $c);
call_user_func(array($method, 'doSelectOne'), $c);Previous versions of this answer: 06/25/10 at 4:39pm
-

Last edited:
06/25/10
10:20pmGlobalOrangeLab says:Try this:
$oCriteria = new Criteria();
$oCriteria->add(constant($model . '::USER_ID'), $userid);
$oCriteria->add(constant($model . '::COURSE_ID'), $courseId);
$userCourse = call_user_func(array($model, 'doSelectOne'), $oCriteria);
if ($userCourse->getStatus() == "C") {
return false;
}
Hope this helps you!
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
