当前位置: 首页>>代码示例>>PHP>>正文


PHP fetchAll函数代码示例

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


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


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