本文整理匯總了PHP中Variable::setValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::setValue方法的具體用法?PHP Variable::setValue怎麽用?PHP Variable::setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Variable
的用法示例。
在下文中一共展示了Variable::setValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: query
public function query($relation, array $instances)
{
$term = term($relation);
$letters = up_letter_gen();
$to_project = array();
foreach ($instances as $i) {
if (strcmp($i, '?') == 0) {
$to_project[] = $letters->current();
$term->addVariableByName($letters->current());
} else {
$v = new Variable($letters->current());
$v->setValue($i);
$term->addVariable($v);
}
$letters->next();
}
// all variables have value, no need to generate/iterate candidates
if ($term->readyForResolve()) {
return $this->isTrue($relation, $term->getInstances());
}
/* ---------Have to fill the variables with a candidate value ----------- */
try {
if ($this->isRule($relation)) {
$candidates = $this->instance_generator_for_rule($term);
} else {
$candidates = $this->instance_generator_for_fact($term);
}
} catch (Exception $e) {
echo "no candidates for: \n";
echo " " . $term->toString() . "\n";
return array();
}
//foreach($candidates as $i) print_r($i);
$candidate_table = $this->getRelationTable($term->arity());
foreach ($candidates as $_instances) {
if ($this->isTrue($relation, $_instances)) {
$candidate_table->insert_row_array($_instances, TRUE);
}
}
return $candidate_table->project($to_project)->tuples();
}
示例2: setVariable
public function setVariable()
{
try {
if (fRequest::get('remove', 'boolean')) {
$variable = new Variable(fRequest::get('name'));
$variable->delete();
fMessaging::create('success', 'Variable removed successfully.');
} else {
try {
$variable = new Variable(fRequest::get('name'));
} catch (fNotFoundException $e) {
$variable = new Variable();
$variable->setName(fRequest::get('name'));
}
$variable->setValue(fRequest::get('value'));
$variable->store();
fMessaging::create('success', 'Variable set successfully.');
}
} catch (fException $e) {
fMessaging::create('error', $e->getMessage());
}
fURL::redirect(Util::getReferer());
}