本文整理汇总了PHP中DBConnection::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::getInstance方法的具体用法?PHP DBConnection::getInstance怎么用?PHP DBConnection::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init($host, $user, $pw, $db)
{
self::$connection = DBConnection::getInstance("main");
if (!self::$connection->isOpen()) {
self::$connection->init($host, $user, $pw, $db);
}
}
示例2: __construct
function __construct($link = null)
{
global $simplepo_config;
$this->sql = "";
$this->table_prefix = $simplepo_config['table_prefix'];
if (!$link) {
$this->link = DBConnection::getInstance();
}
}
示例3: getCountBySearch
/**
* Standard interface for search via full text index (with group constraint).
*
* @api
*
* @param string $query
* @param string $user_groups (optional) comma separated groups
*
* @return int
*/
public static function getCountBySearch($query, $user_groups)
{
if (empty($query)) {
return false;
}
$stmt = DBConnection::getInstance()->prepare("\n SELECT COUNT(*)\n FROM " . self::$TABLE . "\n WHERE\n fti @@ plainto_tsquery(:query)\n AND group_id IN (" . $user_groups . ")\n ");
$stmt->assign('query', $query);
return $stmt->fetchColumn();
}
示例4: save
public function save()
{
try {
$imageInsert = DBConnection::getInstance()->insert('tbl_home_page_image_slider', array('image_path' => $this->getImagePath(), 'file_name' => $this->getFileName(), 'upload_date' => $this->getUploadDate(), 'modified_by' => $this->getModifiedBy(), 'modification_date' => $this->getModificationDate()));
if (!DBConnection::getInstance()->insert('tbl_home_page_image_slider', $imageInsert)) {
throw new Exception('There was a problem sending email.');
}
} catch (Exception $ex) {
error_log($ex->__toString());
}
}
示例5: find
public function find($mail = null)
{
if ($mail) {
$field = is_numeric($mail) ? 'mail_id' : 'username';
$data = DBConnection::getInstance()->get('tbl_mail', array($field, '=', $mail));
if ($data->count()) {
$this->data = $data->first();
return $this->data;
}
}
return false;
}
示例6: customPrepare
public function customPrepare($query, $varType, $index)
{
$conn = DBConnection::getInstance()->getConnection();
$stat = $conn->prepare($query);
$stat->bind_param($varType, $index);
$stat->execute();
$result = $stat->get_result();
if ($result) {
return $result;
} else {
die($conn->error);
}
}
示例7: GetUID
public function GetUID()
{
if ($this->isLoggedIn() == true) {
$username = $this->WhoIsLoggedOn();
$sql = "SELECT uid FROM members WHERE mail=?";
$stmt = DBConnection::getInstance()->Prepare($sql);
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
$object = $result->fetch_object();
return $object->uid;
}
return null;
}
示例8: setUp
/**
* @copydoc PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
// Switch off xdebug screaming (there are
// errors in adodb...).
PKPTestHelper::xdebugScream(false);
// Make sure we have a db connection (some tests
// might close it and that affects the next ones).
DBConnection::getInstance()->reconnect();
// Backup affected tables.
$affectedTables = $this->getAffectedTables();
if (is_array($affectedTables)) {
PKPTestHelper::backupTables($affectedTables, $this);
}
parent::setUp();
}
示例9: setTestConfiguration
/**
* Set a non-default test configuration
* @param $config string the id of the configuration to use
* @param $configPath string (optional) where to find the config file, default: 'config'
* @param $dbConnect (optional) whether to try to re-connect the data base, default: true
*/
protected function setTestConfiguration($config, $configPath = 'config', $dbConnect = true)
{
// Get the configuration file belonging to
// this test configuration.
$configFile = $this->getConfigFile($config, $configPath);
// Avoid unnecessary configuration switches.
if (Config::getConfigFileName() != $configFile) {
// Switch the configuration file
Config::setConfigFileName($configFile);
// Re-open the database connection with the
// new configuration.
if ($dbConnect && class_exists('DBConnection')) {
DBConnection::getInstance(new DBConnection());
}
}
}
示例10: GetLinks
public function GetLinks()
{
$link = new link();
$sql = "\n\t\tSELECT lid, header, www, description, type, date\n\t\tFROM links\n\t\t";
$stmt = DBConnection::getInstance()->Prepare($sql);
if ($stmt = DBConnection::getInstance()->Prepare($sql)) {
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_OBJ);
}
if (is_array($result)) {
foreach ($result as $object) {
$m_links[] = $link->createLink($object->lid, $object->header, $object->www, $object->description, $object->type, $object->date);
}
}
return $m_links;
}
示例11: __construct
/**
* Constructor will normalize the lang and the path as specified as parameters.
* The path can be a folder or a file.
*
* @param $lang '/' netural
* @param $path with leading and tailing '/'
* @param $name '/' netural
*/
public function __construct($lang = '', $path = '')
{
$appConf = AccountManager::getInstance()->appConf;
$project = AccountManager::getInstance()->project;
// Security
$path = str_replace('..', '', $path);
$path = str_replace('//', '/', $path);
$this->lang = $lang = trim($lang, '/');
$path = trim($path, '.');
$path = trim($path, '/');
// Find if the path is a folder or a file. As it, if the path contains an extension, we assume the path is a file.
// Else, it's a folder.
$path_parts = pathinfo($path);
if (!isset($path_parts['extension'])) {
$this->isDir = true;
$this->isFile = false;
$this->name = '';
$path_parts['dirname'] = isset($path_parts['dirname']) ? $path_parts['dirname'] : '';
$path = $path_parts['dirname'] . '/' . $path_parts['basename'];
} else {
$this->isDir = false;
$this->isFile = true;
$this->name = $path_parts['basename'];
$path = $path_parts['dirname'];
}
$path = trim($path, '.');
$path = trim($path, '/');
$path = trim($path, '.');
if (strlen($path) > 0) {
$this->path = "/{$path}/";
$this->full_path = $appConf[$project]['vcs.path'] . $lang . '/' . $path . '/' . $this->name;
$this->full_new_path = $appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $lang . '/' . $path . '/' . $this->name;
$this->full_path_dir = $appConf[$project]['vcs.path'] . $lang . '/' . $path . '/';
$this->full_new_path_dir = $appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $lang . '/' . $path . '/';
// The fallback file : if the file don't exist, we fallback to the EN file witch should always exist
$this->full_path_fallback = $appConf[$project]['vcs.path'] . 'en/' . $path . '/' . $this->name;
} else {
$this->path = '/';
$this->full_path = $appConf[$project]['vcs.path'] . $lang . '/' . $this->name;
$this->full_new_path = $appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $lang . '/' . $this->name;
$this->full_path_dir = $appConf[$project]['vcs.path'] . $lang . '/';
$this->full_new_path_dir = $appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $lang . '/';
$this->full_path_fallback = $appConf[$project]['vcs.path'] . 'en/' . $this->name;
}
$this->conn = DBConnection::getInstance();
}
示例12: userExist
function userExist($user, $password)
{
$sql = "SELECT Idperfil, Nombrecompleto FROM Usuario WHERE Nombreusuario='" . $user . "' AND Contrasenia=MD5('" . $password . "') AND Activo=1 AND Conectado=0";
$dbh = DBConnection::getInstance();
$statement = $dbh->prepare($sql);
$statement->execute();
$result = $statement->fetchAll();
if (count($result) == 0) {
return false;
} else {
$_SESSION['user'] = $user;
$_SESSION['password'] = $password;
$_SESSION['profile'] = $result[0][0];
$_SESSION['username'] = $result[0][1];
return true;
}
}
示例13: insertMessages
public function insertMessages($datas, $company)
{
Logger::info('Entering insert messages');
$dbh = DBConnection::getInstance();
Logger::info('Connection object');
try {
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->beginTransaction();
foreach ($datas as $data) {
$sql = "INSERT INTO Enviomensaje (Numerotelefono, Mensaje, Fechaenvio, Compania, Usuario) VALUES ('" . '505' . $data->phone . "', '" . $data->message . "', '" . date('c') . "', '" . $company . "', '" . $_SESSION['user'] . "');";
$dbh->exec($sql);
}
$dbh->commit();
} catch (Exception $e) {
$dbh->rollBack();
return false;
}
return true;
}
示例14: getAutomaticNumberFromTable
public static function getAutomaticNumberFromTable($tableName, $pkField)
{
$result = DBConnection::getInstance()->getAllRecordsFromTable($tableName, $pkField);
if (!empty($result)) {
$maxId = $result->count();
echo 'max id is: ' . $maxId;
return $maxId + 1;
} else {
return 1;
}
if ($result) {
$row = mysql_fetch_array($result);
$nextId = $row[0];
$nextId++;
return $nextId;
} else {
return 0;
}
}
示例15: initSystem
/**
* Perform basic system initialization.
* Initializes configuration variables, database connection, and user session.
*/
function initSystem()
{
$microTime = Core::microtime();
Registry::set('system.debug.startTime', $microTime);
$notes = array();
Registry::set('system.debug.notes', $notes);
if (Config::getVar('general', 'installed')) {
// Initialize database connection
$conn =& DBConnection::getInstance();
if (!$conn->isConnected()) {
if (Config::getVar('database', 'debug')) {
$dbconn =& $conn->getDBConn();
fatalError('Database connection failed: ' . $dbconn->errorMsg());
} else {
fatalError('Database connection failed!');
}
}
}
}