本文整理汇总了PHP中Mysql::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::fetchAll方法的具体用法?PHP Mysql::fetchAll怎么用?PHP Mysql::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::fetchAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAll
/**
* 获取全部数据
*
* @example
* $obj = \Comm\Db::simple('db_alias', 'table');
* $obj->wAnd(['category_id'=>1])->order('id', SORT_DESC)->limit(0,20)->fetchAll();
*
* @param string $field 要获取的字段,默认是*
* @param boolean $use_master 是否强制使用主库
*
* @return \array
*/
public function fetchAll($field = '*', $use_master = false)
{
$use_master && $this->_db->setWrite();
$sql = self::fetchSql("SELECT {$field}");
$result = $this->_db->fetchAll($sql, $this->_params);
$use_master && $this->_db->setAuto();
return $result;
}
示例2: getArticlesByIssue
public static function getArticlesByIssue($issue)
{
$mysql = new Mysql();
$mysql->connect(Config::$bd_servidor, Config::$bd_esquema, Config::$bd_usuario, Config::$bd_contrasena);
$query = "select pa.article_id article_id, fojsbus_articlesetting(pa.article_id,'title','es_ES') title\n from published_articles pa\n where pa.issue_id=" . $issue->getId() . ";";
$resultSet = $mysql->query($query);
$myArticles = array();
foreach ($mysql->fetchAll($resultSet) as $articleData) {
$article = new Article($issue, $articleData['article_id'], $articleData['title']);
$myArticles[] = $article;
}
if (empty($myArticles)) {
return null;
}
return $myArticles;
}
示例3: getJournalById
public static function getJournalById($journal)
{
$myJournal = $journal;
$mysql = new Mysql();
$mysql->connect(Config::$bd_servidor, Config::$bd_esquema, Config::$bd_usuario, Config::$bd_contrasena);
$query = "select j.journal_id journal_id, j.path path, fojsbus_journalsetting(j.journal_id,'title','es_ES') title\n from journals j\n where j.journal_id=" . $myJournal->getId() . ";";
$resultSet = $mysql->query($query);
if ($resultSet != false) {
$journalData = $mysql->fetchAll($resultSet);
if ($journalData[0]['journal_id'] != null && $journalData[0]['journal_id'] != '') {
$myJournal->setTitle($journalData[0]['title']);
$myJournal->setUrl(Config::$ojs . "/" . $journalData[0]['path']);
$myJournal->setIssues(IssueDAO::getIssuesByJournal($myJournal));
return $myJournal;
}
}
return null;
}
示例4: getIssuesByJournal
public static function getIssuesByJournal($journal)
{
$mysql = new Mysql();
$mysql->connect(Config::$bd_servidor, Config::$bd_esquema, Config::$bd_usuario, Config::$bd_contrasena);
$query = "select i.issue_id issue_id, i.volume volume, i.number number, i.year year, fojsbus_issuesetting(i.issue_id,'title','es_ES') title\n from issues i LEFT JOIN custom_issue_orders o ON (o.issue_id = i.issue_id) \n where i.journal_id=" . $journal->getId() . "\n and i.published = 1 \n order by o.seq ASC, i.current DESC, i.date_published DESC;";
$resultSet = $mysql->query($query);
$myIssues = array();
if ($resultSet != false) {
foreach ($mysql->fetchAll($resultSet) as $issueData) {
$issue = new Issue($journal, $issueData['issue_id'], $issueData['volume'], $issueData['number'], $issueData['year'], $issueData['title']);
$issue->setArticles(ArticleDAO::getArticlesByIssue($issue));
$myIssues[] = $issue;
}
}
if (empty($myIssues)) {
return null;
}
return $myIssues;
}
示例5: Mysql
?>
<?php
try {
// <<<<-------------- try
$mysql = new Mysql();
$mysql->connect("HOST", "DATABASE", "USER", "PASSWORD");
// change this line here
$query = "select * from categories";
// and table name here
$result = $mysql->query($query);
?>
<ul>
<?php
foreach ($mysql->fetchAll($result) as $category) {
?>
<li><?php
print_r($category);
?>
</li>
<?php
}
?>
</ul>
<h3>Everything's OK</h3>