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


PHP Database::fetch方法代码示例

本文整理汇总了PHP中Database::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::fetch方法的具体用法?PHP Database::fetch怎么用?PHP Database::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


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

示例1: testFetch

 /**
  * Tests Database->fetch()
  */
 public function testFetch()
 {
     $obj = $this->Database->query('select 1');
     $result = $this->Database->fetch($obj);
     if (!$result[1] == 1) {
         $this->fail();
     }
 }
开发者ID:swat30,项目名称:safeballot,代码行数:11,代码来源:DatabaseTest.php

示例2: isCurrentPanelMembersArchived

 public static function isCurrentPanelMembersArchived()
 {
     $DB = new Database();
     $sql = "SELECT UID FROM userids WHERE Responsibility != 'Member'";
     $result = $DB->query($sql);
     while ($row = $DB->fetch($result)) {
         $sql = "SELECT UID FROM panelmembers WHERE UID = '" . $row['UID'] . "'";
         $res = $DB->query($sql);
         $ret = $DB->fetch($res);
         if (!$ret['UID']) {
             return false;
         }
     }
     return true;
 }
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:15,代码来源:PanelMember.php

示例3: buildCache

 public function buildCache()
 {
     $this->pathCache = array();
     $pathModel = new Database();
     $pathModel->fetch(array('table' => 'table.paths'), array('function' => array($this, 'pushPathData')));
     mgExportArrayToFile(__CACHE__ . '/permalink/permalink.php', $this->pathCache, 'permalink');
 }
开发者ID:baijd,项目名称:magike,代码行数:7,代码来源:kernel.permalink.php

示例4: listar

 /**
  *lista todos os transmissaoes cadastrados
  *
  * @return Transmissao[]
  */
 public function listar()
 {
     $this->sql = "SELECT * FROM transmissao ORDER BY descricao";
     $this->values = array();
     $this->fields = array();
     return parent::fetch();
 }
开发者ID:tricardo,项目名称:CartorioPostal_old,代码行数:12,代码来源:TransmissaoDAO.php

示例5: count

 public static function count()
 {
     $db = new Database();
     $sql = "SELECT COUNT(UID) FROM userids";
     $result = $db->query($sql);
     $row = $db->fetch($result);
     $db->close();
     return intval($row['COUNT(UID)']) - 1;
 }
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:9,代码来源:Member.php

示例6: count

 public static function count()
 {
     $db = new Database();
     $sql = "SELECT COUNT(*) FROM events  WHERE TimeNDate<date(NOW())";
     $result = $db->query($sql);
     $row = $db->fetch($result);
     $db->close();
     return $row['COUNT(*)'];
 }
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:9,代码来源:Event.php

示例7: testFetch

 /**
  * @covers DataBase::fetch
  */
 public function testFetch()
 {
     $result = $this->db->fetch("SELECT * FROM test ORDER BY id");
     $this->assertInternalType('array', $result);
     $this->assertEquals(3, $this->db->rowCount());
     $this->assertEquals(2, count($result));
     $this->assertEquals(array('id', 'name'), array_keys($result));
     $this->assertEquals(1, $result['id']);
     $this->assertEquals('value 1', $result['name']);
     $r1 = $this->db->fetch();
     $this->assertEquals(array('id', 'name'), array_keys($r1));
     $this->assertEquals(2, $r1['id']);
     $this->assertEquals('value 2', $r1['name']);
     $r3 = $this->db->fetch();
     // 3 linha
     $this->assertEquals(3, $r3['id']);
     $this->assertEquals('value 3', $r3['name']);
     $this->assertEmpty($this->db->fetch());
     $r2 = $this->db->fetch("SELECT * FROM testecase WHERE id > ?", 10);
     $this->assertInternalType('array', $r2);
     $this->assertEmpty($r2);
 }
开发者ID:diego3,项目名称:myframework-core,代码行数:25,代码来源:DataBaseTest.php

示例8: urlencode

     echo "<td class='tdheader'>";
     echo "<a href='?action=row_view&amp;table=" . urlencode($target_table) . "&amp;sort=" . urlencode($result[$i]['name']);
     if (isset($_SESSION[COOKIENAME . 'sortRows'])) {
         $orderTag = $_SESSION[COOKIENAME . 'sortRows'] == $result[$i]['name'] && $_SESSION[COOKIENAME . 'orderRows'] == "ASC" ? "DESC" : "ASC";
     } else {
         $orderTag = "ASC";
     }
     echo "&amp;order=" . $orderTag;
     echo "'>" . htmlencode($result[$i]['name']) . "</a>";
     if (isset($_SESSION[COOKIENAME . 'sortRows']) && $_SESSION[COOKIENAME . 'sortRows'] == $result[$i]['name']) {
         echo $_SESSION[COOKIENAME . 'orderRows'] == "ASC" ? " <b>&uarr;</b>" : " <b>&darr;</b>";
     }
     echo "</td>";
 }
 echo "</tr>";
 for ($i = 0; $row = $db->fetch($table_result); $i++) {
     // -g-> $pk will always be the last columns in each row of the array because we are doing "SELECT *, PK_1, typeof(PK_1), PK2, typeof(PK_2), ... FROM ..."
     $pk_arr = array();
     for ($col = $pkFirstCol; array_key_exists($col, $row); $col = $col + 2) {
         // in $col we have the type and in $col-1 the value
         if ($row[$col] == 'integer' || $row[$col] == 'real') {
             // json encode as int or float, not string
             $pk_arr[] = $row[$col - 1] + 0;
         } else {
             // encode as json string
             $pk_arr[] = $row[$col - 1];
         }
     }
     $pk = json_encode($pk_arr);
     $tdWithClass = "<td class='td" . ($i % 2 ? "1" : "2") . "'>";
     $tdWithClassLeft = "<td class='td" . ($i % 2 ? "1" : "2") . "' style='text-align:left;'>";
开发者ID:techtronics,项目名称:pla,代码行数:31,代码来源:index.php

示例9: Database

<?php 
include "config.php";
include_once "Database.php";
$db = new Database();
/*
* Insert Example
*/
$post = array('email_user' => 'nirav.trivedi29@gmail.com', 'password' => 'test');
$db->insert('users', $post);
echo "Inseted Row ID is :: " . $db->InserId;
echo "<br>";
/*
* Select Example
*/
$db->select('users');
while ($r = $db->fetch()) {
    echo $r['email_user'];
    echo "<br>";
}
echo "<br>";
print_r($r);
echo "Total Rows : ", $db->NumRows();
echo "<br><br>";
/*
* Select with where
* You can use various conditions here such as like , regexp and etc...
*/
$db->select('users', '*', 'id = 1');
$r = $db->fetch();
print_r($r);
echo "<br><br>";
开发者ID:niravtrivedi,项目名称:database-class,代码行数:31,代码来源:index.php

示例10: Database

require_once 'config/config.php';
require_once DIR_COMMON . 'common.php';
require_once DIR_DATABASE . "mysqli-db-obj.php";
require_once DIR_DATABASE . 'mysqli-db-obj.php';
$db = new Database();
// There are so many ways this can go wrong. Assume it is wrong first.
$something_wrong = true;
// To protect against CSRF attacks.
$form_token = base64_encode(openssl_random_pseudo_bytes(32));
$_SESSION['form_token'] = $form_token;
$post_id = $_GET['Post_ID'];
// Connect to the database and retrieve the post.
$stmt = "SELECT Title, Contents FROM _posts WHERE Post_ID = ?";
$types = "i";
$array_of_binds = array($post_id);
$result = $db->fetch($stmt, $types, $array_of_binds);
if ($result !== false) {
    $title = $result[0]['Title'];
    $contents = $result[0]['Contents'];
    $something_wrong = false;
}
// Form the site, according to whether one is logged or not
$navbar = "<a class='blog-nav-item' href='index.php'>Home</a>";
$navbar .= "<a class='blog-nav-item' href='addpost.php'>Add Post</a>";
$navbar .= "<a class='blog-nav-item' href='logout.php'>Logout</a>";
// Form main content
if ($something_wrong) {
    $main = $db->error();
} else {
    $main = '
		<div class="col-sm-8 blog-main">
开发者ID:donjar,项目名称:cvwo-assignment-1,代码行数:31,代码来源:editpost.php

示例11: Database

    echo $row['eMail'];
    ?>
"></div></a>
                            </div>
                        </div>
                    </div>
                    <?php 
}
$db->close();
?>
                </div>
                <?php 
$DB = new Database();
$sql = "SELECT * FROM gamingcontest";
$result = $DB->query($sql);
if ($DB->fetch($result)) {
    ?>
                <div>
                    <form method="post" action="<?php 
    echo pure_it($_SERVER['PHP_SELF']);
    ?>
">
                        <input class="button" type="submit" value="Archive" name="archive_pcp" />
                    </form>
                </div>
                <?php 
}
?>
            </div>
        </section>
    </main>
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:31,代码来源:gparticipants.php

示例12: initStaticValue

 private function initStaticValue()
 {
     $staticModel = new Database();
     $this->staticVar = array();
     $staticModel->fetch(array('table' => 'table.statics'), array('function' => array($this, 'pushStaticValue')));
 }
开发者ID:baijd,项目名称:magike,代码行数:6,代码来源:kernel.static_var.php

示例13: pure_it

                                                                >Event Deleted!</div><?php 
}
?>
    <main>
        <section>
            <div class="container">
                <div class="row">
                    <form method="post" action="<?php 
echo pure_it($_SERVER['PHP_SELF']);
?>
">
                        <?php 
$DB = new Database();
$sql = "SELECT * FROM events ORDER BY TimeNDate DESC";
$result = $DB->query($sql);
while ($Data = $DB->fetch($result)) {
    extract($Data);
    $date = new DateTime($TimeNDate);
    $TimeNDate = $date->format('h:i A, dS F, Y');
    ?>
                        <div class="columns six">
                            <div class="box">
                                <div class="title"><?php 
    echo $Title;
    ?>
</div>
                                <p class="info"><span class="bold">Time &amp Date:</span><br><?php 
    echo $TimeNDate;
    ?>
</p>
                                <p class="info"><span class="bold">Venue:</span><br><?php 
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:31,代码来源:events.php

示例14: isStudentIDExist

         $StudentID_Exist = isStudentIDExist($StudentID, 'userids_temp', $r_error);
         $StudentID_Exist = $StudentID_Exist ? "We already have this ID in pending request" : "";
     }
     // Checking if File Size Exceded Limit:
     $ImageSize_err = validate_image_size($_FILES["Image"]["size"], $r_error);
     // Checking if the File is Invalid:
     $ImageType_err = validate_image_type($_FILES["Image"]["type"], $r_error);
     // Checking if the Student is from Dept. of CSE:
     $NonDept_err = validateStudentID($StudentID, $r_error);
 }
 if (!$r_missing && !$r_error) {
     // Creating the Values:
     $db = new Database();
     $sql = "SELECT MAX(UID) FROM userids_temp";
     $result = $db->query($sql);
     $row = $db->fetch($result);
     $num = intval($row['MAX(UID)']);
     // Inserting Values into Temporary UserIDs Table:
     $extension = end(explode(".", $_FILES["Image"]["name"]));
     $newFileName = "members/" . ++$num . "_temp." . $extension;
     move_uploaded_file($_FILES["Image"]["tmp_name"], $newFileName);
     $DateOfBirth = $_POST['YOB'] . "/" . $_POST['MOB'] . "/" . $_POST['DOB'];
     $data = array();
     $data['StudentID'] = $StudentID;
     $data['Image'] = $newFileName;
     $data['FirstName'] = $FirstName;
     $data['LastName'] = $LastName;
     $data['dateOfBirth'] = $DateOfBirth;
     $data['ContactNo'] = $Phone;
     $data['eMail'] = $Mail;
     $r_success = $db->insert('userids_temp', $data);
开发者ID:sabbirrahman,项目名称:uuictclub,代码行数:31,代码来源:register.php

示例15: Database

    }
}
//end of class
// Create Connection
$obj = new Database("localhost", "root", "", "student_info");
// Assign table name
$tablename = "student";
// Create table query
$CreateTableSql = "CREATE TABLE {$tablename}(Roll INT,Name CHAR(50),Marks DOUBLE)";
//Call Create Table
$obj->CreateTable($CreateTableSql);
//Associative array for insert function
$InsColumnVal = array("Roll" => 4, "Name" => 'Zahan', "Marks" => 64.8);
//Call insert function to insert record
$obj->insert($tablename, $InsColumnVal);
//Associative array for delete function
$DelColumnVal = array("Roll" => 4, "Name" => 'Zahan');
//Call Delete function
$obj->delete($tablename, $DelColumnVal);
//Associative array to set query for update function
$set = array("Roll" => 5, "Marks" => 75.3);
//Associative array to condition query for update function
$condition = array("Roll" => 3, "Name" => 'Hatim');
//call update function
$obj->update($tablename, $set, $condition);
// Fetch data from the table
$show = $obj->fetch($tablename, array("Roll", "Name", "Marks"));
// Show data from table
echo "<pre>";
print_r($show);
echo "</pre>";
开发者ID:bzz86,项目名称:tourney,代码行数:31,代码来源:database.php


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