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


PHP TempNam函数代码示例

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


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

示例1: testdb

function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
    global $ADODB_vers, $ADODB_CACHE_DIR, $ADODB_FETCH_MODE, $ADODB_COUNTRECS;
    //adodb_pr($db);
    ?>
	<form method=GET>
	</p>
	<table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
	</p>
<?php 
    $create = false;
    /*$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
    	
    	$rs = $db->Execute('select lastname,firstname,lastname,id from ADOXYZ');
    	$arr = $rs->GetAssoc();
    	echo "<pre>";print_r($arr);
    	die();*/
    if (!$db) {
        die("testdb: database not inited");
    }
    global $EXECS, $CACHED;
    $EXECS = 0;
    $CACHED = 0;
    //$db->Execute("drop table adodb_logsql");
    if (rand() % 3 == 0) {
        @$db->Execute("delete from adodb_logsql");
    }
    $db->debug = 1;
    $db->fnExecute = 'CountExecs';
    $db->fnCacheExecute = 'CountCachedExecs';
    if (empty($_GET['nolog'])) {
        echo "<h3>SQL Logging enabled</h3>";
        $db->LogSQL();
        /*
        		$sql =
        "SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant, 
        t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage, 
        t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm 
        FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4` 
        	WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic) 
        	AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0')) 
        	ORDER BY t1.time DESC";
        		$db->SelectLimit($sql);
        		echo $db->ErrorMsg();*/
    }
    $ADODB_CACHE_DIR = dirname(TempNam('/tmp', 'testadodb'));
    $db->debug = false;
    //print $db->UnixTimeStamp('2003-7-22 23:00:00');
    $phpv = phpversion();
    if (defined('ADODB_EXTENSION')) {
        $ext = ' &nbsp; Extension ' . ADODB_EXTENSION . ' installed';
    } else {
        $ext = '';
    }
    print "<h3>ADODB Version: {$ADODB_vers} Host: <i>{$db->host}</i> &nbsp; Database: <i>{$db->database}</i> &nbsp; PHP: {$phpv} {$ext}</h3>";
    flush();
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('Asia/Kuala_Lumpur');
    }
    $arr = $db->ServerInfo();
    print_r($arr);
    echo E_ALL, ' ', E_STRICT, "<br>";
    $e = error_reporting(E_ALL | E_STRICT);
    echo error_reporting(), '<p>';
    flush();
    #$db->debug=1;
    $tt = $db->Time();
    if ($tt == 0) {
        echo '<br><b>$db->Time failed</b>';
    } else {
        echo "<br>db->Time: " . date('d-m-Y H:i:s', $tt);
    }
    echo '<br>';
    echo "Date=", $db->UserDate('2002-04-07'), '<br>';
    print "<i>date1</i> (1969-02-20) = " . $db->DBDate('1969-2-20');
    print "<br><i>date1</i> (1999-02-20) = " . $db->DBDate('1999-2-20');
    print "<br><i>date1.1</i> 1999 = " . $db->DBDate("'1999'");
    print "<br><i>date2</i> (1970-1-2) = " . $db->DBDate(24 * 3600) . "<p>";
    print "<i>ts1</i> (1999-02-20 13:40:50) = " . $db->DBTimeStamp('1999-2-20 1:40:50 pm');
    print "<br><i>ts1.1</i> (1999-02-20 13:40:00) = " . $db->DBTimeStamp('1999-2-20 13:40');
    print "<br><i>ts2</i> (1999-02-20) = " . $db->DBTimeStamp('1999-2-20');
    print "<br><i>ts3</i> (1970-1-2 +/- timezone) = " . $db->DBTimeStamp(24 * 3600);
    print "<br> Fractional TS (1999-2-20 13:40:50.91): " . $db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
    $dd = $db->UnixDate('1999-02-20');
    print "<br>unixdate</i> 1999-02-20 = " . date('Y-m-d', $dd) . "<p>";
    print "<br><i>ts4</i> =" . ($db->UnixTimeStamp("19700101000101") + 8 * 3600);
    print "<br><i>ts5</i> =" . $db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
    print "<br><i>ts6</i> =" . $db->UserTimeStamp("20040110092123");
    print "<br><i>ts7</i> =" . $db->DBTimeStamp("20040110092123");
    flush();
    // mssql too slow in failing bad connection
    if (false && $db->databaseType != 'mssql') {
        print "<p>Testing bad connection. Ignore following error msgs:<br>";
        $db2 = ADONewConnection();
        $rez = $db2->Connect("bad connection");
        $err = $db2->ErrorMsg();
        print "<i>Error='{$err}'</i></p>";
        if ($rez) {
            print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
        }
//.........这里部分代码省略.........
开发者ID:mvpphet,项目名称:IntranetPaper,代码行数:101,代码来源:test.php

示例2: testdb

function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
    global $ADODB_vers, $ADODB_CACHE_DIR;
    ?>
	<form>
	</p>
	<table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
	</p>
<?php 
    $create = false;
    $ADODB_CACHE_DIR = dirname(TempNam('/tmp', 'testadodb'));
    $db->debug = false;
    $phpv = phpversion();
    print "<h3>ADODB Version: {$ADODB_vers} Host: <i>{$db->host}</i> &nbsp; Database: <i>{$db->database}</i> &nbsp; PHP: {$phpv}</h3>";
    $e = error_reporting(63 - E_WARNING);
    print "<p>Testing bad connection. Ignore following error msgs:<br>";
    $db2 = ADONewConnection();
    $rez = $db2->Connect("bad connection");
    $err = $db2->ErrorMsg();
    error_reporting($e);
    print "<i>Error='{$err}'</i></p>";
    if ($rez) {
        print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
    }
    $rs = $db->Execute('select * from adoxyz');
    if ($rs === false) {
        $create = true;
    } else {
        $rs->Close();
    }
    //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
    if ($create) {
        if ($db->databaseType == 'ibase') {
            print "<b>Please create the following table for testing:</b></p>{$createtab}</p>";
            return;
        } else {
            $db->Execute($createtab);
        }
    }
    $rs =& $db->Execute("delete from ADOXYZ");
    // some ODBC drivers will fail the drop so we delete
    if ($rs) {
        if (!$rs->EOF) {
            print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
        }
        $rs->Close();
    } else {
        print "err=" . $db->ErrorMsg();
    }
    print "<p>Test select on empty table</p>";
    $rs =& $db->Execute("select * from ADOXYZ where id=9999");
    if ($rs && !$rs->EOF) {
        print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";
    }
    if ($rs) {
        $rs->Close();
    }
    $db->debug = false;
    print "<p>Testing Commit: ";
    $time = $db->DBDate(time());
    if (!$db->BeginTrans()) {
        print '<b>Transactions not supported</b></p>';
    } else {
        /* COMMIT */
        $rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',{$time})");
        if ($rs && $db->CommitTrans()) {
            $rs->Close();
            $rs =& $db->Execute("select * from ADOXYZ where id=99");
            if ($rs === false || $rs->EOF) {
                print '<b>Data not saved</b></p>';
                $rs =& $db->Execute("select * from ADOXYZ where id=99");
                print_r($rs);
                die;
            } else {
                print 'OK</p>';
            }
            if ($rs) {
                $rs->Close();
            }
        } else {
            print "<b>Commit failed</b></p>";
        }
        /* ROLLBACK */
        if (!$db->BeginTrans()) {
            print "<p><b>Error in BeginTrans</b>()</p>";
        }
        print "<p>Testing Rollback: ";
        $db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',{$time})");
        if ($db->RollbackTrans()) {
            $rs = $db->Execute("select * from ADOXYZ where id=100");
            if ($rs && !$rs->EOF) {
                print '<b>Fail: Data should rollback</b></p>';
            } else {
                print 'OK</p>';
            }
            if ($rs) {
                $rs->Close();
            }
        } else {
            print "<b>Commit failed</b></p>";
//.........这里部分代码省略.........
开发者ID:qoire,项目名称:portal,代码行数:101,代码来源:test.php

示例3: testdb

function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
    global $ADODB_vers, $ADODB_CACHE_DIR, $ADODB_FETCH_MODE, $HTTP_GET_VARS, $ADODB_COUNTRECS;
    ?>
	<form method=GET>
	</p>
	<table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
	</p>
<?php 
    $create = false;
    global $EXECS, $CACHED;
    $EXECS = 0;
    $CACHED = 0;
    $db->fnExecute = 'CountExecs';
    $db->fnCacheExecute = 'CountCachedExecs';
    $ADODB_CACHE_DIR = dirname(TempNam('/tmp', 'testadodb'));
    $db->debug = false;
    //print $db->UnixTimeStamp('2003-7-22 23:00:00');
    $phpv = phpversion();
    if (defined('ADODB_EXTENSION')) {
        $ext = ' &nbsp; Extension ' . ADODB_EXTENSION . ' installed';
    } else {
        $ext = '';
    }
    print "<h3>ADODB Version: {$ADODB_vers} Host: <i>{$db->host}</i> &nbsp; Database: <i>{$db->database}</i> &nbsp; PHP: {$phpv} {$ext}</h3>";
    $arr = $db->ServerInfo();
    print_r($arr);
    $e = error_reporting(E_ALL - E_WARNING);
    flush();
    print "<i>date1</i> (1969-02-20) = " . $db->DBDate('1969-2-20');
    print "<br><i>date1</i> (1999-02-20) = " . $db->DBDate('1999-2-20');
    print "<br><i>date2</i> (1970-1-2) = " . $db->DBDate(24 * 3600) . "<p>";
    print "<i>ts1</i> (1999-02-20 3:40:50) = " . $db->DBTimeStamp('1999-2-20 13:40:50');
    print "<br><i>ts2</i> (1999-02-20) = " . $db->DBTimeStamp('1999-2-20');
    print "<br><i>ts3</i> (1970-1-2 +/- timezone) = " . $db->DBTimeStamp(24 * 3600);
    print "<br> Fractional TS (1999-2-20 13:40:50.91): " . $db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
    $dd = $db->UnixDate('1999-02-20');
    print "<br>unixdate</i> 1999-02-20 = " . date('Y-m-d', $dd) . "<p>";
    // mssql too slow in failing bad connection
    if ($db->databaseType != 'mssql') {
        print "<p>Testing bad connection. Ignore following error msgs:<br>";
        $db2 = ADONewConnection();
        $rez = $db2->Connect("bad connection");
        $err = $db2->ErrorMsg();
        print "<i>Error='{$err}'</i></p>";
        if ($rez) {
            print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
        }
    }
    error_reporting($e);
    flush();
    //$ADODB_COUNTRECS=false;
    $rs = $db->Execute('select * from adoxyz order by id');
    //print_r($rs);
    //OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
    //print_r($rez);
    //die();
    if ($rs === false) {
        $create = true;
    } else {
        $rs->Close();
    }
    //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
    if ($create) {
        if (false && $db->databaseType == 'ibase') {
            print "<b>Please create the following table for testing:</b></p>{$createtab}</p>";
            return;
        } else {
            $db->debug = 1;
            $e = error_reporting(E_ALL - E_WARNING);
            $db->Execute($createtab);
            error_reporting($e);
        }
    }
    $rs =& $db->Execute("delete from ADOXYZ");
    // some ODBC drivers will fail the drop so we delete
    if ($rs) {
        if (!$rs->EOF) {
            print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
        }
        $rs->Close();
    } else {
        print "err=" . $db->ErrorMsg();
    }
    print "<p>Test select on empty table</p>";
    $rs =& $db->Execute("select * from ADOXYZ where id=9999");
    if ($rs && !$rs->EOF) {
        print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";
    }
    if ($rs) {
        $rs->Close();
    }
    flush();
    //$db->debug=true;
    print "<p>Testing Commit: ";
    $time = $db->DBDate(time());
    if (!$db->BeginTrans()) {
        print '<b>Transactions not supported</b></p>';
        if ($db->hasTransactions) {
            Err("hasTransactions should be false");
//.........这里部分代码省略.........
开发者ID:alexpagnoni,项目名称:adodb,代码行数:101,代码来源:test.php

示例4: testdb

function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
    global $ADODB_vers, $ADODB_CACHE_DIR, $ADODB_FETCH_MODE, $HTTP_GET_VARS;
    ?>
	<form>
	</p>
	<table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
	</p>
<?php 
    $create = false;
    $ADODB_CACHE_DIR = dirname(TempNam('/tmp', 'testadodb'));
    $db->debug = false;
    $phpv = phpversion();
    print "<h3>ADODB Version: {$ADODB_vers} Host: <i>{$db->host}</i> &nbsp; Database: <i>{$db->database}</i> &nbsp; PHP: {$phpv}</h3>";
    $e = error_reporting(E_ALL - E_WARNING);
    print "<i>date1</i> (1999-02-20) = " . $db->DBDate('1999-2-20');
    print "<br><i>date2</i> (1970-1-2) = " . $db->DBDate(24 * 3600) . "<p>";
    print "<i>ts1</i> (1999-02-20 3:40:50) = " . $db->DBTimeStamp('1999-2-20 3:40:50');
    print "<br><i>ts2</i> (1999-02-20) = " . $db->DBTimeStamp('1999-2-20');
    print "<br><i>ts3</i> (1970-1-2 +/- timezone) = " . $db->DBTimeStamp(24 * 3600) . "<p>";
    print "<p>Testing bad connection. Ignore following error msgs:<br>";
    $db2 = ADONewConnection();
    $rez = $db2->Connect("bad connection");
    $err = $db2->ErrorMsg();
    error_reporting($e);
    print "<i>Error='{$err}'</i></p>";
    if ($rez) {
        print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
    }
    $rs = $db->Execute('select * from adoxyz');
    if ($rs === false) {
        $create = true;
    } else {
        $rs->Close();
    }
    //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
    if ($create) {
        if ($db->databaseType == 'ibase') {
            print "<b>Please create the following table for testing:</b></p>{$createtab}</p>";
            return;
        } else {
            $db->Execute($createtab);
        }
    }
    $rs =& $db->Execute("delete from ADOXYZ");
    // some ODBC drivers will fail the drop so we delete
    if ($rs) {
        if (!$rs->EOF) {
            print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
        }
        $rs->Close();
    } else {
        print "err=" . $db->ErrorMsg();
    }
    print "<p>Test select on empty table</p>";
    $rs =& $db->Execute("select * from ADOXYZ where id=9999");
    if ($rs && !$rs->EOF) {
        print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";
    }
    if ($rs) {
        $rs->Close();
    }
    $db->debug = false;
    print "<p>Testing Commit: ";
    $time = $db->DBDate(time());
    if (!$db->BeginTrans()) {
        print '<b>Transactions not supported</b></p>';
    } else {
        /* COMMIT */
        $rs = $db->Execute("insert into ADOXYZ values (99,'Should Not','Exist (Commit)',{$time})");
        if ($rs && $db->CommitTrans()) {
            $rs->Close();
            $rs =& $db->Execute("select * from ADOXYZ where id=99");
            if ($rs === false || $rs->EOF) {
                print '<b>Data not saved</b></p>';
                $rs =& $db->Execute("select * from ADOXYZ where id=99");
                print_r($rs);
                die;
            } else {
                print 'OK</p>';
            }
            if ($rs) {
                $rs->Close();
            }
        } else {
            print "<b>Commit failed</b></p>";
        }
        /* ROLLBACK */
        if (!$db->BeginTrans()) {
            print "<p><b>Error in BeginTrans</b>()</p>";
        }
        print "<p>Testing Rollback: ";
        $db->Execute("insert into ADOXYZ values (100,'Should Not','Exist (Rollback)',{$time})");
        if ($db->RollbackTrans()) {
            $rs = $db->Execute("select * from ADOXYZ where id=100");
            if ($rs && !$rs->EOF) {
                print '<b>Fail: Data should rollback</b></p>';
            } else {
                print 'OK</p>';
            }
//.........这里部分代码省略.........
开发者ID:qoire,项目名称:portal,代码行数:101,代码来源:test.php


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