本文整理汇总了PHP中database::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP database::instance方法的具体用法?PHP database::instance怎么用?PHP database::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database
的用法示例。
在下文中一共展示了database::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new self();
}
return self::$instance;
}
示例2: get_instance
public static function get_instance()
{
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
示例3: userData
public function userData($matricule)
{
$this->database = database::instance();
$this->auth = authentification::instance();
$this->matricule = $matricule;
$this->getUserData();
}
示例4: getInstance
static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例5: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
$object = __CLASS__;
self::$instance = new $object();
}
return self::$instance;
}
示例6: get_instance
public static function get_instance($dsn = null, $user = null, $pass = null)
{
if (null == self::$instance || $dsn != null) {
self::$instance = new database($dsn, $user, $pass);
}
//var_dump(self::$instance->dbh);
return self::$instance->dbh;
}
示例7: getSpecifiedCount
private static function getSpecifiedCount($field, $value)
{
$database = database::instance();
$whereClause = !isset($value) ? "" : "WHERE {$field} = '{$value}'";
$result = $database->requete("SELECT count(" . demande::MATRICULE_DB_FIELD . ") as nb FROM st_demande {$whereClause}");
$result = mysql_fetch_array($result);
return $result['nb'];
}
示例8: instance
/**
* Short description of method instance
*
* @access public
* @return void
*/
public static function instance()
{
if (!database::$instance) {
database::$instance = new database();
database::$instance->init();
database::$instance->connect();
}
return database::$instance;
}
示例9: error_reporting
<?php
error_reporting(E_ALL);
require_once 'class.authentification.php';
require_once 'class.database.php';
require_once 'class.util.php';
$statusId = util::getParam($_POST, 'statusId');
$db = database::instance();
$result = $db->requete("SELECT description FROM st_status WHERE st_status.statusId={$statusId}");
$resultArray = mysql_fetch_array($result);
print util::cleanUTF8($resultArray['description']);
示例10: error_reporting
error_reporting(E_ALL);
require_once "header.php";
require_once "class.util.php";
require_once "class.userData.php";
require_once "class.validation.php";
require_once "class.database.php";
$message = "";
if (isset($_GET['sendmail']) && $_GET['sendmail'] == 1) {
$matricule = $_POST['matricule'];
if (isset($matricule) && validation::matricule($matricule)) {
$user = new userData($_POST['matricule']);
if ($user->getExist()) {
$password = util::generatePassword();
$pregArray = array(array('key' => "/@@FIRSTNAME@@/", 'value' => $user->getFirstName()), array('key' => "/@@LASTNAME@@/", 'value' => $user->getLastName()), array('key' => "/@@PASSWORD@@/", 'value' => $password));
$database = database::instance();
$database->requete("UPDATE st_authentication SET password='" . md5($password) . "' WHERE matricule='" . $matricule . "'");
util::sendEmail($user->getEmail(), 'accessrecovery.txt', $pregArray, "Stationnement AEP - Demande de nouveau mot de passe");
$message = util::UTF8toISO8859("Un courriel avec votre nouveau mot de passe vous a été envoyé");
} else {
$message = 'Utilisateur non existant';
}
} else {
$message = 'Matricule invalide';
}
}
?>
<div>
<?php
if ($message != "") {
echo $message . '</br></br>';
示例11: add
/**
* This is the task code that adds photos and albums. It first examines all the target files
* and creates a set of Server_Add_File_Models, then runs through the list of models and adds
* them one at a time.
*/
static function add($task)
{
$mode = $task->get("mode", "init");
$start = microtime(true);
switch ($mode) {
case "init":
$task->set("mode", "build-file-list");
$task->percent_complete = 0;
$task->status = t("Starting up");
batch::start();
break;
case "build-file-list":
// 0% to 10%
// We can't fit an arbitrary number of paths in a task, so store them in a separate table.
// Don't use an iterator here because we can't get enough control over it when we're dealing
// with a deep hierarchy and we don't want to go over our time quota. The queue is in the
// form [path, parent_id] where the parent_id refers to another Server_Add_File_Model. We
// have this extra level of abstraction because we don't know its Item_Model id yet.
$queue = $task->get("queue");
while ($queue && microtime(true) - $start < 0.5) {
list($file, $parent_entry_id) = array_shift($queue);
$entry = ORM::factory("server_add_file");
$entry->task_id = $task->id;
$entry->file = $file;
$entry->parent_id = $parent_entry_id;
$entry->save();
foreach (glob("{$file}/*") as $child) {
if (is_dir($child)) {
$queue[] = array($child, $entry->id);
} else {
$ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
$child_entry = ORM::factory("server_add_file");
$child_entry->task_id = $task->id;
$child_entry->file = $child;
$child_entry->parent_id = $entry->id;
$child_entry->save();
}
}
}
}
// We have no idea how long this can take because we have no idea how deep the tree
// hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go
// over 10% in percent_complete.
$task->set("queue", $queue);
$task->percent_complete = min($task->percent_complete + 0.1, 10);
$task->status = t2("Found one file", "Found %count files", Database::instance()->where("task_id", $task->id)->count_records("server_add_files"));
if (!$queue) {
$task->set("mode", "add-files");
$task->set("total_files", database::instance()->count_records("server_add_files", array("task_id" => $task->id)));
$task->percent_complete = 10;
}
break;
case "add-files":
// 10% to 100%
$completed_files = $task->get("completed_files", 0);
$total_files = $task->get("total_files");
// Ordering by id ensures that we add them in the order that we created the entries, which
// will create albums first. Ignore entries which already have an Item_Model attached,
// they're done.
$entries = ORM::factory("server_add_file")->where("task_id", $task->id)->where("item_id", null)->orderby("id", "ASC")->limit(10)->find_all();
if ($entries->count() == 0) {
// Out of entries, we're done.
$task->set("mode", "done");
}
$owner_id = user::active()->id;
foreach ($entries as $entry) {
if (microtime(true) - $start > 0.5) {
break;
}
// Look up the parent item for this entry. By now it should exist, but if none was
// specified, then this belongs as a child of the current item.
$parent_entry = ORM::factory("server_add_file", $entry->parent_id);
if (!$parent_entry->loaded) {
$parent = ORM::factory("item", $task->get("item_id"));
} else {
$parent = ORM::factory("item", $parent_entry->item_id);
}
$name = basename($entry->file);
$title = item::convert_filename_to_title($name);
if (is_dir($entry->file)) {
$album = album::create($parent, $name, $title, null, $owner_id);
$entry->item_id = $album->id;
} else {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
$photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
$entry->item_id = $photo->id;
} else {
if (in_array($extension, array("flv", "mp4"))) {
$movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
$entry->item_id = $movie->id;
} else {
// This should never happen, because we don't add stuff to the list that we can't
// process. But just in, case.. set this to a non-null value so that we skip this
//.........这里部分代码省略.........
示例12: init
/**
* Short description of method instance
*
* @access private
* @return void
*/
private function init()
{
$this->objDatabase = database::instance();
$this->objLog = log::instance();
session_save_path(config::PhpSessionPath);
session_set_cookie_params(0);
session_start();
$this->estIdentifie();
}
示例13: loadFromServer
public function loadFromServer($matricule, $fileDbFieldName)
{
$database = database::instance();
$results = $database->requete("SELECT * from st_demande WHERE matricule = '{$matricule}'");
$resultsArray = mysql_fetch_array($results);
$url = $resultsArray[$fileDbFieldName];
$this->loadFromUrl($url);
}
示例14: getDemandStatusNameFromId
public static function getDemandStatusNameFromId($statusId)
{
$database = database::instance();
$results = $database->requete("\tSELECT " . demandStatus::STATUS_NAME_DB_FIELD . " \n\t\t\t\t\t\t\t\t\t\tFROM st_status \n\t\t\t\t\t\t\t\t\t\tWHERE " . demandStatus::STATUS_ID_DB_FIELD . " = '{$statusId}' ");
$results = mysql_fetch_array($results);
return $results[demandStatus::STATUS_NAME_DB_FIELD];
}
示例15: _create_database_config
/**
* Creates and verifies a database configuration.
* @param String $hostname
* @param String $database
* @param String $username
* @param String $password
* @return Array Error message. None if successful.
* @throws Exception If Bad data.
*/
private function _create_database_config($hostname, $database, $username, $password)
{
$config = array('type' => 'mysql', 'connection' => array('hostname' => $hostname, 'database' => $database, 'username' => $username, 'password' => $password, 'persistent' => FALSE), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, 'profiling' => TRUE);
try {
$db = database::instance('test', $config);
$db->connect();
// Make sure this is empty.
$tables = $db->query(Database::SELECT, 'SHOW TABLES;', TRUE);
if (count($tables)) {
throw new Exception("That database already has tables loaded. Please select a different database or empty this database.<br>\n\t\t\t\t\tIf you absolutely must use this database then please follow the manual configuration instructions in README.md.");
}
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
return $config;
}