本文整理汇总了PHP中DataQuery::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DataQuery::create方法的具体用法?PHP DataQuery::create怎么用?PHP DataQuery::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataQuery
的用法示例。
在下文中一共展示了DataQuery::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postUp
public function postUp($manager)
{
$pdo = $manager->getAdapterConnection('rokfor');
// populate relative fields: _issues
foreach (array('_singleplugin', '_allplugin', '_rtfplugin', '_xmlplugin', '_narrationplugin') as $_field) {
$datasets = IssuesQuery::create()->find();
$count = 0;
foreach ($datasets as $issue) {
$sql = "SELECT " . $_field . " FROM _issues WHERE id = " . $issue->getId();
$stmt = $pdo->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
foreach ($this->_splitTextListData($result[$_field]) as $key) {
$p = PluginsQuery::create()->findPk($key);
if ($p) {
echo "Add Plugin with id " . $key . " from " . $_field . "\n";
switch ($_field) {
case '_singleplugin':
$issue->addSinglePlugin($p);
break;
case '_allplugin':
$issue->addAllPlugin($p);
break;
case '_rtfplugin':
$issue->addRtfPlugin($p);
break;
case '_xmlplugin':
$issue->addXmlPlugin($p);
break;
case '_narrationplugin':
$issue->addNarrationPlugin($p);
break;
}
}
}
$issue->save($pdo);
}
}
$datasets = RightsQuery::create()->find();
$count = 0;
foreach ($datasets as $right) {
$sql = "SELECT * FROM _rights WHERE id = " . $right->getId();
$stmt = $pdo->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
foreach (array('_fortemplate', '_forissue', '_forbook', '_foruser') as $_field) {
foreach ($this->_splitTextListData($result[$_field]) as $key) {
if ($key) {
switch ($_field) {
case '_fortemplate':
$p = TemplatenamesQuery::create()->findPk($key);
if ($p) {
$right->addTemplatenames($p);
}
break;
case '_forissue':
$p = IssuesQuery::create()->findPk($key);
if ($p) {
$right->addIssues($p);
}
break;
case '_forbook':
$p = BooksQuery::create()->findPk($key);
if ($p) {
$right->addBooks($p);
}
break;
case '_foruser':
$p = UsersQuery::create()->findPk($key);
if ($p) {
$right->addUsers($p);
}
break;
}
}
}
}
$right->save($pdo);
}
$datasets = BatchQuery::create()->find();
$count = 0;
foreach ($datasets as $batch) {
$sql = "SELECT * FROM _batch WHERE id = " . $batch->getId();
$stmt = $pdo->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
foreach (array('_forbook') as $_field) {
foreach ($this->_splitTextListData($result[$_field]) as $key) {
if ($key) {
switch ($_field) {
case '_forbook':
$p = BooksQuery::create()->findPk($key);
if ($p) {
$batch->addBooks($p);
}
break;
}
}
}
}
//.........这里部分代码省略.........
示例2: getHistory
/**
* creates history values for reference fields
*
* @return void
* @author Urs Hofer
*/
function getHistory()
{
$thisfield = $this->getTemplates();
$contribution = $this->getContributions();
$settings = json_decode($thisfield->getConfigSys(), true);
$retval = [];
if ($settings['fromfield']) {
$field = \TemplatesQuery::create()->findPk($settings['fromfield']);
} else {
$field = $thisfield;
}
if ($settings['fromtemplate']) {
$template = \TemplatenamesQuery::create()->findPk($settings['fromtemplate']);
} else {
$template = $thisfield->getTemplatenames();
}
if ($settings['fromissue']) {
$issue = \IssuesQuery::create()->findPk($settings['fromissue']);
} else {
$issue = $contribution->getIssues();
}
if ($settings['frombook']) {
$book = \BooksQuery::create()->findPk($settings['frombook']);
} else {
$book = $contribution->getIssues()->getBooks();
}
if ($settings['fromchapter']) {
$chapter = \FormatsQuery::create()->findPk($settings['fromchapter']);
} else {
$chapter = $contribution->getFormats();
}
if (!$chapter || !$book || !$issue || !$template || !$field) {
array_push($retval, ["id" => -1, "value" => "Error - adjust template settings"]);
} else {
switch ($settings['history_command']) {
//
// BOOK HISTORY
// needs : -
// option : -
// Returns books
//
case 'books':
foreach (\BooksQuery::create() as $_b) {
array_push($retval, ["id" => $_b->getId(), "value" => $_b->getName()]);
}
break;
//
// ISSUES HISTORY
// option : frombook(string), otherwise self
// option : restrict_to_open(bool)
// Returns issues of a book
//
//
// ISSUES HISTORY
// option : frombook(string), otherwise self
// option : restrict_to_open(bool)
// Returns issues of a book
//
case 'issues':
$issues = \IssuesQuery::create()->_if($settings['restrict_to_book'])->filterByBooks($book)->_endif()->_if($settings['restrict_to_open'])->filterByStatus('open')->_endif();
foreach ($issues as $_b) {
array_push($retval, ["id" => $_b->getId(), "value" => $_b->getName()]);
}
break;
//
// CHAPTERS HISTORY
// option : frombook(string), otherwise self
// Returns chapters of a book
//
//
// CHAPTERS HISTORY
// option : frombook(string), otherwise self
// Returns chapters of a book
//
case 'chapters':
$formats = \FormatsQuery::create()->_if($settings['restrict_to_book'])->filterByBooks($book)->_endif();
foreach ($formats as $_b) {
array_push($retval, ["id" => $_b->getId(), "value" => $_b->getName()]);
}
break;
//
// CLOUD HISTORY
// TODO
// Returns cloud matrix data for a field.
//
//
// CLOUD HISTORY
// TODO
// Returns cloud matrix data for a field.
//
case 'cloud':
array_push($retval, ["id" => -1, "value" => "not yet implemented"]);
//
// OTHER HISTORY
//.........这里部分代码省略.........