• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP fetchAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中fetchAll函数的典型用法代码示例。如果您正苦于以下问题:PHP fetchAll函数的具体用法?PHP fetchAll怎么用?PHP fetchAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fetchAll函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getAllAdmin

/**
 * 获取所有管理员
 * @return multitype
 */
function getAllAdmin()
{
    //$where = $where==null?null:$where;
    $sql = "select id,username,email from imooc_admin";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:kevins1022,项目名称:shop,代码行数:11,代码来源:admin.inc.php


示例2: checkMilestone

function checkMilestone($class, $action)
{
    if (!$class) {
        $action();
        return;
    }
    $milestones = fetchAll("SELECT points FROM milestone ORDER BY points ASC");
    $startPoints = array_pop(calculatePoints($class)["points"]);
    $action();
    $endPoints = array_pop(calculatePoints($class)["points"]);
    $achieved = [];
    foreach ($milestones as $stone) {
        if ($stone->points > $endPoints) {
            break;
        }
        if ($stone->points > $startPoints) {
            array_push($achieved, $stone->points);
        }
    }
    if (empty($achieved)) {
        return;
    }
    $classInfo = fetch("SELECT c.name, u.email FROM class AS c JOIN user AS u ON c.teacher = u.id");
    $n = "";
    if (count($achieved) > 1) {
        $n = "n";
    }
    foreach (fetchAll("SELECT email FROM user WHERE role = :admin", ["admin" => ADMIN]) as $admin) {
        own_mail($admin->email, "Etappe{$n} erreicht", "Guten Tag,\r\nDie Klasse \"{$classInfo->name}\" hat die Etappe{$n} " . implode(", ", $achieved) . " erreicht!\r\nDie Lehrkraft ist: {$classInfo->email} \r\n\r\nNachhaltige Grüße\r\nIhre Weltfairsteher-Website");
    }
    own_mail($classInfo->email, "Etappe{$n} erreicht", "Herzlichen Glückwunsch, Ihre  Klasse \"{$classInfo->name}\" hat bei WeltFAIRsteher die Etappe{$n} " . implode(", ", $achieved) . " erreicht!\r\nSie erhalten demnächst eine Überraschung per Post\r\n\r\nNachhaltige Grüße\r\nIhr WeltFAIRsteher-Team");
}
开发者ID:MackieLoeffel,项目名称:weltfairsteher,代码行数:32,代码来源:include.php


示例3: month_total_fee

function month_total_fee($month)
{
    $year = explode('-', $month)[0];
    $mon = explode('-', $month)[1];
    //获取需要的月份相应交费记录并计算总费用
    $sql = "select fee,date,dueDate from hh_fee";
    $rows = fetchAll($sql);
    $total = 0;
    foreach ($rows as $row) {
        $day1 = $row['date'];
        $day2 = $row['dueDate'];
        $fee = $row['fee'];
        $T = ceil($fee / days_dis($day1, $day2));
        //$T为 该笔学费每天的收入
        $days = month_days($day1, $day2, $month);
        if ($days) {
            $total = $days * $T + $total;
        }
    }
    $arr = array('year' => $year, 'month' => $mon, 'total' => $total);
    //如果已存在相应日期记录,则进行更新操作,否则进行插入
    $sql = "select count(total) from hh_totalFee where year={$year} and month={$mon}";
    $result = fetchOne($sql)['count(total)'];
    if ($result >= 1) {
        update('hh_totalFee', $arr, "year={$year} and month={$mon}");
    } else {
        insert('hh_totalFee', $arr);
    }
}
开发者ID:hardihuang,项目名称:happyhome_admin,代码行数:29,代码来源:analyze.inc.php


示例4: getAdminByPage

function getAdminByPage($page, $pageSize = 2)
{
    $sql = "select * from imooc_admin";
    //得到所有记录的记录数,这里把$totalRows变成全局变量,是方便listAdmin在判断总记录数,并判断显示页码时调用
    global $totalRows;
    $totalRows = getResultNum($sql);
    //$pageSize记录每页显示几条,
    $pageSize = 2;
    //得到总页码数,这里把$totalPage设为全局变量,是方便listAdmin.php的总页数调用显示
    global $totalPage;
    $totalPage = ceil($totalRows / $pageSize);
    //设置当前默认页数,这里把$page设为全局变量,是方便page.func.php在获取当前页时调用
    global $page;
    //判断是否小于1,是否为空,或者不是数字,则都为$page都为1
    if ($page < 1 || $page == null || !is_numeric($page)) {
        $page = 1;
    }
    if ($page >= $totalPage) {
        $page = $totalPage;
    }
    $offset = ($page - 1) * $pageSize;
    $sql = "select id,username,email from imooc_admin limit {$offset},{$pageSize}";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:juststart2015,项目名称:Electronic-commerce-system,代码行数:25,代码来源:admin.inc.php


示例5: getMyArticles

 public function getMyArticles()
 {
     //$vConex = conexSys();
     $tipos = $this->prepareTypes($this->types);
     $Q_EPUB = "SELECT AR.Titulo as Titulo,\n            AR.Descripcion as Descripcion,\n            CA.Descripcion as categorias,\n            AL.TipoProducto as TipProducto,\n            AR.ProductoFab As Producto,\n            AL.AlmacenCod As CodAlmacen,\n            CA.CategoriCod as categoryId,\n            CA.Imagen,\n            CA.Descripcion as CategoryTitle,\n            TP.Descripcion as DescripTipoProd,\n            MA.IdFacturasCab,\n            CA.Color\n            FROM matriculas MA \n            INNER JOIN almacen AL ON MA.Producto = AL.AlmacenCod \n            INNER JOIN articulos AR ON AR.Producto = AL.Producto \n            INNER JOIN categorias CA on AR.Categoria = CA.CategoriCod\n            INNER JOIN tipoproducto TP on AL.TipoProducto = TP.TipoProductoId \n             ";
     if ($this->usuarioEntidad != null && $this->usuarioEntidad != '') {
         $Q_EPUB .= " WHERE MA.Estado = 'Matriculado' AND MA.Cliente = '" . $this->usuarioEntidad . "Alumno' ";
     } else {
         if ($this->CodAlmacen != null && $this->CodAlmacen != '') {
             $Q_EPUB .= " WHERE AL.AlmacenCod = '" . $this->CodAlmacen . "' ";
         }
     }
     $Q_EPUB .= " AND (" . $tipos . ") ";
     $MxEPUB = fetchAll($Q_EPUB);
     //Creando un array para almacenar los cursos del programa
     $jsonData = $this->getDefault($this->types);
     foreach ($MxEPUB as $EPUB) {
         foreach ($this->types as $key => $value) {
             if ($EPUB->TipProducto == $value) {
                 $articlesType = $jsonData[$value]["articles"];
                 array_push($articlesType, $EPUB);
                 $jsonData[$value]["articles"] = $articlesType;
             }
         }
     }
     $jsonData["success"] = true;
     WE(json_encode($jsonData));
 }
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:28,代码来源:f_json_my_articles.php


示例6: getUser

function getUser($ar)
{
    if (empty($ar['email']) || empty($ar['password'])) {
        echo json_encode(['error' => 'empty parameter']);
        return;
    }
    $res = fetchAll('SELECT * FROM users WHERE email=? AND password=?', [$ar['email'], $ar['password']]);
    if (!empty($res)) {
        foreach ($res as $key => $value) {
            unset($res[$key]['password']);
        }
    } else {
        echo json_encode(['error' => 'wrong combination']);
    }
    echo json_encode($res);
}
开发者ID:EmmanuelMarti,项目名称:ZendAixplore,代码行数:16,代码来源:androidRequests.php


示例7: __call

 public function __call($name, $arguments)
 {
     if (in_array($name, $this->query) && $arguments) {
         if (count($arguments) == 2) {
             return $this->database->{$name}($this->table, $arguments[0], $arguments[1]);
         } elseif (count($arguments) == 1) {
             return $this->database->{$name}($this->table, $arguments[0]);
         }
     } elseif (in_array($name, $this->advanced) && $arguments) {
         if ($name == 'query' && $arguments[1] == true) {
             return $this->database->{$name}($arguments[0]) > fetchAll();
         } else {
             return $this->database->{$name}($arguments[0]);
         }
     } else {
         throw new \Exception("暂不支持此操作", 1);
     }
 }
开发者ID:xiaobeicn,项目名称:cfphp,代码行数:18,代码来源:Model.php


示例8: getAdminByPage

function getAdminByPage($pageSize = 2)
{
    $sql = "select * from myshop_admin";
    $totalRows = getResultNum($sql);
    $pageSize = 2;
    $totalPage = ceil($totalRows / $pageSize);
    $page = $_REQUEST['page'] ? (int) $_REQUEST['page'] : 1;
    if ($page < 1 || $page == null || !is_numeric($page)) {
        $page = 1;
    }
    if ($page >= $totalPage) {
        $page = $totalPage;
    }
    $offset = ($page - 1) * $pageSize;
    $sql = "select id,username,email from myshop_admin limit {$offset},{$pageSize}";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:xc1129,项目名称:myshop,代码行数:18,代码来源:admin.inc.php


示例9: getAdminByPage

function getAdminByPage($page, $pageSize = 2)
{
    $sql = "select * from imooc_admin";
    global $totalRows;
    $totalRows = getResultNum($sql);
    global $totalPage;
    $totalPage = ceil($totalRows / $pageSize);
    if ($page < 1 || $page == null || !is_numeric($page)) {
        $page = 1;
    }
    if ($page >= $totalPage) {
        $page = $totalPage;
    }
    $offset = ($page - 1) * $pageSize;
    $sql = "select id,username,email from imooc_admin limit {$offset},{$pageSize}";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:qiancs1101,项目名称:Recommend-Purchase,代码行数:18,代码来源:admin.inc.php


示例10: toggleArrow

                   background-color:#1BAB3F;
        padding: 10px;
                   height: auto;
                   text-align: center">
        <h4 style="color: white;">Feedback: Einzelne Challenges bewerten</h4>
        <a href="javascript:void(0)" onclick="return toggleArrow(this, '#feedback')" style="background-color: white; margin-top: 10px;
         border: 2px solid white; border-radius: 30px;"

        ><i class="fa fa-arrow-down"></i></a><br>
        <span id="feedback" style="display:none; font-size: 12px;">
        Bitte jede Challenge-Bewertung einzeln abschicken. Die Daten gehen anonym ein.<br><br>
        <form id="addFeedback" action="javascript:void(0);" onsubmit="sendForm(this)">

          <b>Die Challenge:</b> <select style="color: black;" name="challenge">
            <?php 
foreach (fetchAll("SELECT id, name FROM challenge") as $c) {
    ?>
                <option style="color: black;" value="<?php 
    echo e($c->id);
    ?>
"><?php 
    echo e($c->name);
    ?>
</option><br>
            <?php 
}
?>
</select>
            <br><br>
            <b>...machte den Schüler*innen Spaß:</b><br>
        Nein:<input class="" type="radio" name="fun" value="1" /><br>
开发者ID:MackieLoeffel,项目名称:weltfairsteher,代码行数:31,代码来源:teacher.php


示例11: getPageNumByPid

function getPageNumByPid($uid, $pid)
{
    $sql = "select pid from zhx_post where uid={$uid} order by date desc";
    $rows = fetchAll($sql);
    $i = 0;
    $n = 0;
    foreach ($rows as $row) {
        if ($i % pageSize == 0) {
            $n++;
            // echo $n." ".$i." and ".$row['pid']."<br>";
            if ($row['pid'] < $pid) {
                return $n - 1;
            }
        }
        $i++;
    }
    return $n;
}
开发者ID:hardihuang,项目名称:zihuaxiang,代码行数:18,代码来源:post.inc.php


示例12: editPro

function editPro($active, $pro_id)
{
    if ($active == 'editDetails') {
        $arr = $_POST;
        $sql = "select id,album_path from tuhao_album where pid={$pro_id}";
        $rows = fetchAll($sql);
        $srcNum = count($rows);
        $path = "../uploads";
        $uploadFiles = uploadFile($path);
        $uploadNum = count($uploadFiles);
        if ($uploadNum < $srcNum) {
            $i = 0;
            foreach ($uploadFiles as $uploadFile) {
                $array = array('album_path' => $uploadFile['name']);
                unlink("../uploads/" . $rows[$i]['album_path']);
                update("tuhao_album", $array, "id={$rows[$i]['id']}");
                $i++;
            }
            for ($j = $i; $j < $srcNum; $j++) {
                delete("tuhao_album", "id={$rows[$j]['id']}");
                unlink("../uploads/" . $rows[$j]['album_path']);
            }
        } elseif ($uploadNum == $srcNum) {
            $i = 0;
            foreach ($uploadFiles as $uploadFile) {
                $updateArr = array('album_path' => $uploadFile['name']);
                unlink("../uploads/" . $rows[$i]['album_path']);
                update("tuhao_album", $updateArr, "id={$rows[$i]['id']}");
                $i++;
            }
        } elseif ($uploadNum > $srcNum) {
            $i = 0;
            foreach ($rows as $row) {
                $updateArr = array('album_path' => $uploadFiles[$i]['name']);
                unlink("../uploads/" . $row['album_path']);
                update("tuhao_album", $updateArr, "id={$row['id']}");
                $i++;
            }
            for ($j = $i; $j < $uploadNum; $j++) {
                $insertArr = array('pid' => $pro_id, 'album_path' => $uploadFiles[$j]['name']);
                insert("tuhao_album", $insertArr);
            }
        }
        if (update("tuhao_pro", $arr, "id={$pro_id}")) {
            $message = array('success' => true, 'mes' => "编辑成功", 'pro_id' => $pro_id);
        } else {
            $message = array('success' => false, 'mes' => "编辑失败", 'pro_id' => $pro_id);
        }
    } elseif ($active == 'delete') {
        if (delete("tuhao_pro", "id={$pro_id}") && delete("tuhao_album", "pid={$pro_id}") && delete("tuhao_comm", "pro_id={$pro_id}")) {
            $message = array('success' => true, 'mes' => "删除成功");
        } else {
            $message = array('success' => false, 'mes' => "删除失败");
        }
    }
    return json_encode($message);
}
开发者ID:JimmyVV,项目名称:TuhaoWeb,代码行数:57,代码来源:product.inc.php


示例13: getProInfo

/**
 *得到商品ID和商品名称
 * @return array
 */
function getProInfo()
{
    $sql = "select id,pName from imooc_pro order by id asc";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:Wumingla,项目名称:shopImooc,代码行数:10,代码来源:pro.inc.php


示例14: fetchAll

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
	<h1>商品列表</h1>
	<?php 
if ($pageCount) {
    // 获取页码,以计算偏移值
    $pageno = (int) $_GET['pageno'];
    $pageno = $pageno <= 0 ? 1 : $pageno;
    $pageno = $pageno > $pageCount ? $pageCount : $pageno;
    $offset = ($pageno - 1) * $pagesize;
    $sql = "SELECT id,proName,proPrice,status FROM products " . $where . " LIMIT {$offset},{$pagesize}";
    $rowset = fetchAll($sql);
    ?>
	<table width="100%" cellpadding="10" cellspacing="0" border="1">
		<tr>
			<td width="30">?</td>
			<td>商品名称</td>
			<td>销售价格</td>
			<td>状态</td>
			<td>操作</td>
		</tr>
		<?php 
    foreach ($rowset as $row) {
        ?>
		<tr>
			<td width="30">?</td>
			<td><?php 
开发者ID:denson7,项目名称:phpstudy,代码行数:31,代码来源:listPro.php


示例15: getSubTemas

function getSubTemas()
{
    $sql = 'SELECT rs.* FROM (
                            SELECT
                                    st.SubTemaCod, st.Descripcion, st.TituloArticulo,
                                    st.NombreArchivo, st.Formato, st.TipoSubtema,
                                    st.TipoTema, st.ContenidoArticulo, st.Entidad,
                      Ue.Codigo, ue.Usuario, ue.EntidadCreadora,
                      Us.Nombres AS EmpresaNombre, u.Carpeta, u.Nombres AS username, st.Tema, t.Curso
                            FROM    subtema st
                            INNER JOIN tema t ON t.CodTema = st.Tema
                            INNER JOIN usuarios u ON st.Entidad = u.IdUsuario
                            INNER JOIN usuario_entidad ue ON u.Usuario = ue.Usuario
                            INNER JOIN usuarios us ON ue.EntidadCreadora = us.Usuario

                            WHERE
                                    st.Componente IN (0, \'\')
                            AND st.TipoTema IN ( \'Documento\', \'Video\', \'Embebido\' )
            ) AS rs
            LEFT JOIN archivocontenido ac ON rs.NombreArchivo = ac.Archivo
            WHERE
             ac.Archivo IS NULL';
    return fetchAll($sql);
}
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:24,代码来源:adminTablasForms.php


示例16: getAllCate

/**
 * 得到所有分类
 * @return array
 */
function getAllCate()
{
    $sql = "select id,cName from imooc_cate";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:juedaiyuer,项目名称:codeworkplace,代码行数:10,代码来源:cate.inc.php


示例17: getAllAdmin

function getAllAdmin()
{
    $sql = "select id,username,email from biogas_admin";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:6,代码来源:admin.inc.php


示例18: fetchAll

<?php

/**
 * Created by PhpStorm.
 * User: ray
 * Date: 7/29/15
 * Time: 11:30 AM
 */
require_once '../include.php';
$cityname = fetchAll("select id,city from biogas_city");
$num_city = count($cityname);
$cName = array();
$cId = array();
$cGas = array();
$gas_total = 0;
for ($i = 0; $i < $num_city; $i++) {
    $cName[$i] = $cityname[$i]['city'];
    $cGas[$i] = queryTotalGas($cityname[$i]['id']);
    $gas_total = $gas_total + $cGas[$i];
}
$res = array();
foreach ($cName as $k => $r) {
    $res[] = array($cName[$k], $cGas[$k]);
}
$json_res = json_encode($res);
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:31,代码来源:temp_char_all_city.php


示例19: fetchAll

                </div>
                <!--/.col-xs-6.col-lg-4-->

            </div>
            <!--/row-->
        </div>
        <!--/.col-xs-12.col-sm-9-->

        <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar">
            <div class="list-group">
                <h2>点击排行</h2>
                <ul class="list-inline row text-center">
<?php 
$sql = "select * from video where type = {$_GET['type']} order by hint desc limit 0,6";
$rows = fetchAll($sql);
for ($i = 0; $i < count($rows); $i++) {
    ?>
                    <li class="col-xs-12 col-lg-6">
                        <img src="assets/images/<?php 
    echo $rows[$i]['pic'];
    ?>
" class="responsive img-thumbnail"/>

                        <p><a href="show.php?id=<?php 
    echo $rows[$i]['id'];
    ?>
"><?php 
    echo $rows[$i]['name'];
    ?>
</a>
开发者ID:pzyyll,项目名称:Linux_bak,代码行数:30,代码来源:list.php


示例20: getSmallProsByCid

function getSmallProsByCid($cid)
{
    $sql = "select p.id,p.pName,p.iPrice from imooc_pro as p join imooc_cate c on p.cId=c.id where p.cid={$cid} limit 4,4";
    $rows = fetchAll($sql);
    return $rows;
}
开发者ID:juedaiyuer,项目名称:codeworkplace,代码行数:6,代码来源:test.php



注:本文中的fetchAll函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP fetchAllPages函数代码示例发布时间:2022-05-15
下一篇:
PHP fetch函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap