本文整理汇总了PHP中db::init方法的典型用法代码示例。如果您正苦于以下问题:PHP db::init方法的具体用法?PHP db::init怎么用?PHP db::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delink
public function delink($user, $network)
{
db::init()->query("users.delink", array("user" => $user, "network" => $network));
$q = db::init()->query("users.linked", array("user" => $user));
$data = $q->fetch(PDO::FETCH_NUM);
return $data[0];
}
示例2: __construct
public function __construct()
{
if (!session_id()) {
session_start();
}
$this->connect = db::init();
}
示例3: init_db
/**
* initialise the database class
*/
function init_db($name = null)
{
require_once LIBRARY_DIR . "db.php";
if (!$name) {
$name = DB::DEFAULT_CONNECT_NAME;
}
db::init($name);
}
示例4: find
static function find($user, $hash = false)
{
$name = $hash ? "users.hashfind" : "users.find";
$q = db::init()->query($name, array("name" => $user));
if ($q->rowCount()) {
$data = $q->fetch(PDO::FETCH_NUM);
return $data[0];
}
return false;
}
示例5: listPatterns
function listPatterns($id)
{
$q = db::init()->query("pattern.getAll", array("id" => $id));
if ($q->rowCount()) {
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
$id = $row['patternID'];
echo "<tr><td>" . $row['pattern'] . "</td><td><img src='images/arrow.gif'/></td><td>" . $row['output'] . "</td>";
echo "<td><a href='nm-manage-set.php?action=remove&s={$id}'><img src='images/cross.png' /></a></td>";
}
} else {
echo "<tr><td colspan='4'><span>No Patterns</span></td></tr>";
}
}
示例6: listAllHistory
function listAllHistory($id)
{
$q = db::init()->query("epoch.getall", array("id" => $id));
if ($q->rowCount()) {
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>" . $row['iterations'] . "</td>";
echo "<td>" . $row['startMSE'] . "</td>";
echo "<td>" . $row['endMSE'] . "</td>";
echo "<td>" . date("j/m/Y g:i:s a", strtotime($row['epochDate'])) . "</td>";
echo "<td>" . $row['execTime'] . "</td>";
echo "<td>" . ($row['trainsetID'] == null ? "n" : "y") . "</td></tr>";
}
} else {
echo "<tr><td colspan='6'><span>No History</span></td></tr>";
}
}
示例7: Controller
<?php
/**
* Exports training set
* @author Louis Stowasser
*/
require "lib/controller.class.php";
$app = new Controller();
set_time_limit(300);
if (!$_POST['file']) {
die("No Post Data!");
}
$app->display("header");
$q = db::init()->query("pattern.getAll", array("id" => $_POST['id']));
file_put_contents("lib/cache/" . $_POST['file'] . ".nms", "");
//clear file
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
//Append data to file
file_put_contents("lib/cache/" . $_POST['file'] . ".nms", $row['pattern'] . ":" . $row['output'] . "\n", FILE_APPEND);
}
$app->assign("file", $_POST['file']);
$app->display("export");
$app->display("footer");
示例8: bigtitle
bigtitle();
/*If account creation is closed, do not show the page!*/
if ($account_creation_closed) {
die("Server Is Currently Closed To New Players");
}
##
##
## New Registration Process
##
##
$facebook = new facebook(array('appId' => FB_ID, 'secret' => FB_SECRET));
$request = $facebook->getSignedRequest();
if ($request) {
$register = $request['registration'];
try {
$db = db::init();
$fbId = isset($request['user_id']) ? $request['user_id'] : 0;
$user = new user();
if ($fbId != 0) {
if ($user->fbLogin($fbId)) {
/*They have account, throw them back to the main page*/
header('Location: index.php');
exit;
}
}
$sth = $db->prepare("SELECT * FROM " . $db_prefix . "account WHERE username = ?");
$sth->execute(array($register['username']));
if (!$sth->fetch()) {
$sth = $db->prepare("SELECT * FROM " . $db_prefix . "account WHERE email = ?");
$sth->execute(array($register['email']));
if (false != $sth->fetch() && $fbId != 0) {
示例9: quickCache
/**
* Quickly caches one pattern and output from the nmesh cache
* @param $id Network ID
* @param $input Input string
* @param $data Output array
*/
function quickCache($id, $input, $data)
{
db::init()->query("cache.save", array("id" => $id . implode("|", trim($input)), "network" => $id, "data" => implode("|", $data)));
}
示例10: initDb
public static function initDb()
{
$db = db::init();
$db->initDb('initdata/tables.sql');
unset($db);
}
示例11: Controller
<?php
/**
* Import training set
* @author Louis Stowasser
*/
require "lib/controller.class.php";
$app = new Controller();
$data = $app->model->val->add($_POST, $_FILES);
$app->model->val->run("import", $data);
$content = file_get_contents($_FILES['file']['tmp_name']);
$data = explode("\n", $content);
foreach ($data as $line) {
$input = substr($line, 0, strpos($line, ":"));
$output = substr($line, strpos($line, ":") + 1, strlen($line));
if (validation::is_binary($input) && validation::is_binary($output)) {
db::init()->query("pattern.add", array("id" => $_POST['id'], "pattern" => $input, "output" => $output));
}
}
Model::direct();
示例12: init
class db {
public static $connection = NULL;
private static $host = MYSQL_HOST;
private static $username = MYSQL_USER;
private static $passwd = MYSQL_PASS;
private static $db = MYSQL_DBNAME;
public static function init() {
if(!self::$connection) {
self::$connection = new mysqli(self::$host, self::$username, self::$passwd, self::$db);
}
}
public static function escape($string) {
return self::$connection->real_escape_string($string);
}
public static function ping() {
if(!self::$connection->ping()) {
self::$connection->close();
self::$connection = NULL;
self::init();
}
}
}
db::init();
?>
示例13: die
if (strpos($_SERVER['SCRIPT_NAME'], 'install') !== false) {
db::init($dbhost, $dbuser, $dbpass, null);
} else {
include_once APP_DIR . '/sessions.php';
global $mode;
if ($mode != 'single') {
$info = $subdomain = Auth::getClientSite();
if ($subdomain == 'auth') {
$dbname = 'prosper_master';
db::init($dbhost, $dbuser, $dbpass, $dbname);
} else {
if (isset($_SERVER['subdomain'])) {
$subdomain = $_SERVER['subdomain'];
}
$name = $subdomain == $reservedSubDomain ? 'prosper_master' : "prosper_{$subdomain}";
db::init($dbhost, $dbuser, $dbpass, $name);
}
} else {
if ($dbname == '<insert db host here>') {
die('Please configure the system config file');
}
}
$dbname = "`{$dbname}`";
$config = new Config(0);
}
//try to connect to memcache server
if (ini_get('memcache.default_port')) {
$memcacheInstalled = true;
$memcache = new Memcache();
if (@$memcache->connect($mchost, 11211)) {
$memcacheWorking = true;
示例14: Controller
<?php
require "lib/controller.class.php";
$app = new Controller();
switch ($_GET['action']) {
case "remove":
Model::loadProxy("train")->validate($_GET['s']);
db::init()->query("pattern.remove", array("id" => $_GET['s']));
break;
case "add":
$app->model->val->run("trainingset", $_POST);
db::init()->query("pattern.add", array("pattern" => $_POST['input'], "id" => $_POST['id'], "output" => $_POST['output']));
break;
case "rename":
$app->model->val->run("setrename", $_POST);
db::init()->query("train.update", array("label" => $_POST['label'], "id" => $_POST['id']));
break;
case "delete":
Model::loadProxy("train")->validate($_GET['s']);
db::init()->query("train.remove", array("id" => $_GET['s']));
break;
case "new":
$app->model->val->run("newset", $_POST);
db::init()->query("train.add", array("id" => $_POST['n'], "label" => $_POST['label']));
break;
}
Model::direct($_SERVER['HTTP_REFERER']);
示例15: buildTree
function buildTree($id, $nn)
{
$uuid = 0;
$output = "<ul>";
$lcount = count($nn->layer);
for ($l = 0; $l < $lcount; $l++) {
$output .= "<li class='layer'><a href='javascript:void(0);' onclick=\"toggle('ul" . ($uuid + 1) . "',this);\">-</a> Layer " . ($l + 1);
$ncount = count($nn->layer[$l]->neuron);
for ($n = 0; $n < $ncount; $n++) {
$uuid++;
if ($n == 0) {
$output .= "<ul id='ul{$uuid}'>";
}
$output .= "<li class='neuron'><a href='javascript:void(0);' onclick=\"toggle('ul" . ($uuid + 1) . "',this);\">+</a> Neuron " . ($n + 1);
$scount = count($nn->layer[$l]->neuron[$n]->synapse);
for ($s = 0; $s < $scount; $s++) {
$uuid++;
if ($s == 0) {
$output .= "<ul id='ul{$uuid}' style='display:none'>";
}
$output .= "<li class='synapse'>Synapse " . ($s + 1) . "</li>";
if ($s == $scount - 1) {
$output .= "</ul>";
}
}
$output .= "</li>";
if ($n == $ncount - 1) {
$output .= "</ul>";
}
}
$output .= "</li>";
}
$output .= "</ul>";
db::init()->query("cache.save", array("id" => $id . "tree", "network" => $id, "data" => $output));
return $output;
}