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


PHP createTable函数代码示例

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


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

示例1: import

function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("npcitems");
    foreach ($c as $t) {
        list($id, $item, $count, $condition) = explode("|", $t);
        $id = hexdec($id);
        $item = hexdec($item);
        if ($id == 0) {
            continue;
        }
        $prep = $db->prepare("insert into npcitems (baseID,item,count,condition,dlc) values (?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $item, $count, $condition, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:28,代码来源:f3_npcitems.php

示例2: import

function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("npcs");
    foreach ($c as $t) {
        list($id, $female, $race, $essential, $deathitem, $template, $flags) = explode("|", $t);
        $id = hexdec($id);
        $race = hexdec($race);
        $deathitem = hexdec($deathitem);
        $template = hexdec($template);
        $flags = hexdec($flags);
        if ($id == 0) {
            continue;
        }
        $prep = $db->prepare("insert into npcs (baseID,essential,female,race,template,flags,deathitem,dlc) values (?, ?, ?, ?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $essential, $female, $race, $template, $flags, $deathitem, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
开发者ID:Oxymoron290,项目名称:vaultmp,代码行数:31,代码来源:f3_npcs.php

示例3: renderResults

/**
 * @var \Zend\Db\Adapter\Driver\Pdo\Result $results
 * @var \Zend\Db\Adapter\Driver\StatementInterface $statement
 */
function renderResults(Result $results, StatementInterface $statement = null)
{
    $headers = [];
    $queryInformation = null;
    $outputData = null;
    $resultContents = null;
    if ($statement) {
        $queryInformation = SqlFormatter::format($statement->getSql());
        if ($statement->getParameterContainer()->count()) {
            $queryInformation .= createTable(array_keys($statement->getParameterContainer()->getNamedArray()), [array_values($statement->getParameterContainer()->getNamedArray())]);
        }
    }
    if ($results->count()) {
        foreach ($results as $result) {
            $headers = array_keys($result);
            $outputData[] = $result;
        }
    }
    // Results
    if ($outputData) {
        $resultContents = createTable([$headers], $outputData);
    }
    // Wrapper Table
    $table = new Table(new ConsoleOutput());
    $table->setHeaders([['Query Results', 'Generated SQL']])->setRows([[$resultContents, $queryInformation]])->render();
}
开发者ID:settermjd,项目名称:powerful-and-flexible-sql-generation-without-the-hassle,代码行数:30,代码来源:output-results.php

示例4: addCity

function addCity()
{
    $arr = $_POST;
    $city_get = getTemp($arr['city']);
    $city_info['city'] = $arr['city'];
    $city_info['pinyin'] = $city_get['pinyin'];
    $city_info['pubDate'] = $city_get['date'];
    $city_info['longitude'] = $city_get['longitude'];
    $city_info['latitude'] = $city_get['latitude'];
    $city_info['altitude'] = $city_get['altitude'];
    $city_info['pId'] = $arr['pId'];
    $city_info['totalCap'] = 0;
    $cName = $city_info['city'];
    $pinyin = $city_info['pinyin'];
    $str = "<?php" . "\r\n" . "require_once '../lib/mysql.func.php';\r\n" . "require_once '../lib/temp.func.php';\r\n" . "\r\n" . "mysql_connect(\"localhost:/tmp/mysql.sock\",\"root\",\"\");\r\n" . "mysql_set_charset(\"utf8\");\r\n" . "mysql_select_db(\"biogas\");\r\n" . "\r\n" . "\$res = getItem('" . $cName . "');\r\n" . "\$res_insert = array();\r\n" . "\$res_insert['date'] = \$res['date'];\r\n" . "\$res_insert['l_tmp'] = \$res['l_tmp'];\r\n" . "\$res_insert['h_tmp'] = \$res['h_tmp'];\r\n" . "insert(\$res['pinyin'].\"_tmp\", \$res_insert);";
    $filename = '../tmp_update/' . $pinyin . '_update.php';
    if (insert("biogas_city", $city_info)) {
        createTable($city_info['pinyin']);
        //(1) 创建城市温度表
        file_put_contents($filename, $str);
        //(2) 创建温度更新脚本
        chmod($filename, 0777);
        $mes = "添加成功!<br/><a href='addCity.php'>继续添加!</a>|<a href='listCity.php'>查看列表!</a>";
    } else {
        $mes = "添加失败!<br/><a href='addCity.php'>重新添加!</a>|<a href='listCity.php'>查看列表!</a>";
    }
    return $mes;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:28,代码来源:city.inc.php

示例5: import

function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("interiors");
    foreach ($c as $t) {
        list($id, $x1, $y1, $z1, $x2, $y2, $z2) = explode("|", $t);
        if ($id == 0) {
            continue;
        }
        $prep = $db->prepare("insert into interiors (baseID,x1,y1,z1,x2,y2,z2) values (?, ?, ?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $x1, $y1, $z1, $x2, $y2, $z2, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:26,代码来源:f3_incells.php

示例6: createTokenTable

/**
* Creates the basic token table for a survey
*
* @param mixed $iSurveyID
* @param mixed $aAttributeFields
* @return False if failed , else DB object
*/
function createTokenTable($iSurveyID, $aAttributeFields = array())
{
    Yii::app()->loadHelper('database');
    $fields = array('tid' => 'pk', 'participant_id' => 'varchar(50)', 'firstname' => 'varchar(40)', 'lastname' => 'varchar(40)', 'email' => 'text', 'emailstatus' => 'text', 'token' => 'varchar(35)', 'language' => 'varchar(25)', 'blacklisted' => 'varchar(17)', 'sent' => "varchar(17) DEFAULT 'N'", 'remindersent' => "varchar(17) DEFAULT 'N'", 'remindercount' => 'integer DEFAULT 0', 'completed' => "varchar(17) DEFAULT 'N'", 'usesleft' => 'integer DEFAULT 1', 'validfrom' => 'datetime', 'validuntil' => 'datetime', 'mpid' => 'integer');
    foreach ($aAttributeFields as $sAttributeField) {
        $fields[$sAttributeField] = 'string';
    }
    try {
        $sTableName = "{{tokens_" . intval($iSurveyID) . "}}";
        createTable($sTableName, $fields);
        try {
            Yii::app()->db->createCommand()->createIndex("idx_token_token_{$iSurveyID}_" . rand(1, 50000), "{{tokens_" . intval($iSurveyID) . "}}", 'token');
        } catch (Exception $e) {
        }
        // create fields for the custom token attributes associated with this survey
        $tokenattributefieldnames = Survey::model()->findByPk($iSurveyID)->tokenAttributes;
        foreach ($tokenattributefieldnames as $attrname => $attrdetails) {
            Yii::app()->db->createCommand(Yii::app()->db->getSchema()->addColumn("{{tokens_" . intval($iSurveyID) . "}}", $attrname, 'VARCHAR(255)'))->execute();
        }
        Yii::app()->db->schema->getTable($sTableName, true);
        // Refresh schema cache just in case the table existed in the past
        return true;
    } catch (Exception $e) {
        return false;
    }
}
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:33,代码来源:token_helper.php

示例7: import

function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("exteriors");
    foreach ($c as $t) {
        list($name, $id, $x, $y, $wrld) = explode("|", $t);
        $id = hexdec($id);
        $wrld = hexdec($wrld);
        if ($id == 0) {
            continue;
        }
        $name = trim($name);
        $prep = $db->prepare("insert into exteriors (baseID,x,y,wrld,dlc) values (?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $x, $y, $wrld, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
开发者ID:Oxymoron290,项目名称:vaultmp,代码行数:29,代码来源:f3_extcells.php

示例8: import

function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    foreach ($c as $t) {
        list($tb, $id, $name, $description) = explode("|", $t);
        $id = hexdec($id);
        createTable($tb);
        $prep = $db->prepare("insert into {$tb} (baseID,name,description,dlc) values (?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $name, $description, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:25,代码来源:f3.php

示例9: import

function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("races");
    foreach ($c as $t) {
        list($id, $name, $child, $younger, $older) = explode("|", $t);
        $id = hexdec($id);
        $younger = hexdec($younger);
        $older = hexdec($older);
        if ($id == 0) {
            continue;
        }
        $prep = $db->prepare("insert into races (baseID,child,younger,older,dlc) values (?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $child, $younger, $older, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
开发者ID:Oxymoron290,项目名称:vaultmp,代码行数:29,代码来源:f3_races.php

示例10: import

function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    $tb = 'crefs';
    createTable($tb);
    foreach ($c as $t) {
        list($empty, $eid, $ref, $base, $count, $health, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $lock, $key, $link) = explode("|", $t);
        $ref = hexdec($ref);
        $base = hexdec($base);
        $cell = hexdec($cell);
        $flags = hexdec($flags);
        if (!$ref) {
            continue;
        }
        $prep = $db->prepare("insert into {$tb} (editor,refID,baseID,cell,x,y,z,ax,ay,az,flags,dlc) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $db->errorInfo()[2];
            continue;
        }
        $r = $prep->execute(array($eid, $ref, $base, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
开发者ID:rockhowse,项目名称:vaultmp,代码行数:32,代码来源:f3_acre.php

示例11: arenaInstal

function arenaInstal()
{
    $sql = "CREATE TABLE  %tabname% (\n        id mediumint(9) NOT NULL AUTO_INCREMENT,\n        countUsers TINYINT  NOT NULL,\n        price float  DEFAULT '1' NOT NULL,\n        idUser bigint(20) NOT NULL,\n        timeCreate DATETIME NOT NULL,\n        won ENUM('A', 'B', 'W','?') NOT NULL, \n        url VARCHAR(128) NOT NULL,\n        UNIQUE KEY id (id)\n    );";
    /* W - wait check, ? - begining */
    createTable($sql, ARENA_TABLE_ORDERS);
    $sql = "CREATE TABLE  %tabname% (\n        idUser bigint(20) NOT NULL,\n        idOrder mediumint(9) NOT NULL,\n        team ENUM('A', 'B') NOT NULL\n    );";
    createTable($sql, ARENA_TABLE_USER2ORDER);
    $sql = "CREATE TABLE  %tabname% (\n        id mediumint(9) NOT NULL AUTO_INCREMENT,\n        idUser bigint(20) NOT NULL,\n        timeCreate DATETIME NOT NULL,\n        info text NOT NULL,\n        UNIQUE KEY id (id)\n         \n    );";
    createTable($sql, ARENA_TABLE_COMMENTS);
    $sql = "CREATE TABLE  %tabname% (\n        idComment mediumint(9) NOT NULL,\n        idOrder mediumint(9) NOT NULL \n    );";
    createTable($sql, ARENA_TABLE_COMMENT2ORDER);
}
开发者ID:alexandrtkachuk,项目名称:arena,代码行数:12,代码来源:arena.php

示例12: createTokenTable

/**
* Creates the basic token table for a survey
*
* @param mixed $iSurveyID
* @param mixed $aAttributeFields
* @return False if failed , else DB object
*/
function createTokenTable($iSurveyID, $aAttributeFields = array())
{
    Yii::app()->loadHelper('database');
    $fields = array('tid' => 'pk', 'participant_id' => 'varchar(50)', 'firstname' => 'varchar(40)', 'lastname' => 'varchar(40)', 'email' => 'text', 'emailstatus' => 'text', 'token' => 'varchar(35)', 'language' => 'varchar(25)', 'blacklisted' => 'varchar(17)', 'sent' => "varchar(17) DEFAULT 'N'", 'remindersent' => "varchar(17) DEFAULT 'N'", 'remindercount' => 'integer DEFAULT 0', 'completed' => "varchar(17) DEFAULT 'N'", 'usesleft' => 'integer DEFAULT 1', 'validfrom' => 'datetime', 'validuntil' => 'datetime', 'mpid' => 'integer');
    foreach ($aAttributeFields as $sAttributeField) {
        $fields[$sAttributeField] = 'string';
    }
    try {
        createTable("{{tokens_" . intval($iSurveyID) . "}}", $fields);
        return true;
    } catch (Exception $e) {
        return false;
    }
}
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:21,代码来源:token_helper.php

示例13: connectLTI

function connectLTI()
{
    //Check if the LTI table exists and if it doesn't created it now
    createTable('LTI');
    //Make the LTI connection | the Secret | Store as Session | Redirect after success
    $context = new BLTI($GLOBALS['ltiSecret'], true, false);
    //Valid LTI connection
    if ($context->valid == true) {
        //Check if nonce exists within 90 minute timeline
        if (secureLTI($_REQUEST['oauth_nonce'], $_REQUEST['oauth_timestamp'])) {
        }
    } else {
        echo "Unable to make a valid LTI connection. Refresh and try again.";
        die;
    }
    //LTI connection made successfully and nonce is OK. Return the LTI object
    return $context;
}
开发者ID:kingmook,项目名称:easyLTI,代码行数:18,代码来源:easyLTI.php

示例14: fileToDatabase

function fileToDatabase($txtfile, $tablename)
{
    $file = fopen($txtfile, "r");
    while (!feof($file)) {
        $line = fgets($file);
        $pieces = explode(",", $line);
        $date = $pieces[0];
        $open = $pieces[1];
        $high = $pieces[2];
        $low = $pieces[3];
        $close = $pieces[4];
        $volume = $pieces[5];
        // $adj_close = $pieces[6];
        $change = $close - $open;
        $percent_change = $change / $open * 100;
        createTable($tablename);
        $sql = "SELECT * FROM {$tablename}";
        require '../includes/connect.php';
        $result = mysqli_query($connect, $sql);
        //creates table if one doesnt exist
        if (!$result) {
            $sql3 = "INSERT INTO {$tablename} (date, open, high, low, close, volume, amount_change, percent_change)\n        VALUES ('{$date}','{$open}','{$high}','{$low}','{$close}','{$volume}','{$change}','{$percent_change}')";
            $result3 = mysqli_query($connect, $sql3);
            ini_set('max_execution_time', 60);
            //300 seconds = 5 minutes
            if ($result3) {
            } else {
                echo '<br />' . "error with the database " . mysqli_error($connect);
                return false;
            }
        } elseif ($result) {
            $sql3 = "INSERT IGNORE INTO {$tablename} (date, open, high, low, close, volume, amount_change, percent_change)\n             VALUES ('{$date}','{$open}','{$high}','{$low}','{$close}','{$volume}','{$change}','{$percent_change}')";
            $result3 = mysqli_query($connect, $sql3);
            ini_set('max_execution_time', 60);
            //300 seconds = 5 minutes
            if ($result3) {
            } else {
                echo '<br />' . "error with the database " . mysqli_error($connect);
                return false;
            }
        }
    }
    fclose($file);
}
开发者ID:Andrew365,项目名称:Php-Stock-analyzer-v2,代码行数:44,代码来源:stockDownloader.php

示例15: createOutput

function createOutput($records, $sql, $description)
{
    //Report Number and Name
    echo "<h3>" . $description . "</h3>";
    echo "SQL Statement:";
    echo "<p class='sqlStatement'> " . formatSQL($sql) . "</p>";
    echo "<br>";
    //Get Size of Data Array
    //get row count
    $row = sizeof($records);
    //get column count
    /*Count Recursive counts all elements in the array, But every row in the array has a title and data row
      thats why you have to divide with 2 and then divide with the amount of array rows*/
    $column = (count($records, COUNT_RECURSIVE) - $row) / 2 / $row;
    //Get Titles
    $titles = getTitles($records);
    //Create Table
    createTable($records, $row, $column, $titles);
}
开发者ID:steffen-gutzeit,项目名称:OnlineCatalog,代码行数:19,代码来源:reports.php


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