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


PHP Config::getConnection方法代码示例

本文整理汇总了PHP中Config::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getConnection方法的具体用法?PHP Config::getConnection怎么用?PHP Config::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Config的用法示例。


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

示例1: validaUsuario

/**
 * Função que valida um usuário e senha
 *
 * @param string $usuario - O usuário a ser validado
 * @param string $senha - A senha a ser validada
 *
 * @return bool - Se o usuário foi validado ou não (true/false)
 */
function validaUsuario($user, $password)
{
    //Instância do banco de dados.
    $database = new Config();
    $db = $database->getConnection();
    global $_SG;
    //$cS = ($_SG['caseSensitive']) ? 'BINARY' : '';
    // Usa a função addslashes para escapar as aspas
    //    $nusuario = addslashes($user);
    //    $nsenha = addslashes($password);
    $usuario = new Usuario($db);
    $usuario->readName($user);
    if (empty($usuario->cd_usuario)) {
        // Nenhum registro foi encontrado => o usuário é inválido
        return false;
    } else {
        if (password_verify($password, $usuario->nm_senha_usuario)) {
            $_SESSION['usuarioID'] = $usuario->cd_usuario;
            // Pega o valor da coluna 'id do registro encontrado no MySQL
            $_SESSION['usuarioNome'] = $usuario->nm_usuario;
            // Pega o valor da coluna 'nome' do registro encontrado no MySQL
            // Verifica a opção se sempre validar o login
            if ($_SG['validaSempre'] == true) {
                // Definimos dois valores na sessão com os dados do login
                $_SESSION['usuarioLogin'] = $user;
                $_SESSION['usuarioSenha'] = $password;
            }
            return true;
        } else {
            return false;
        }
    }
}
开发者ID:ADS-Fatec,项目名称:Projeto-dos-Ingressos,代码行数:41,代码来源:security.php

示例2: save

 public function save()
 {
     $config = new Config();
     $conn = $config->getConnection();
     $query = "INSERT INTO admin (username,password,pathname)\n\t\t\t\tVALUES ('{$this->username}','{$this->password}', '{$this->pathname}')";
     if ($conn->query($query) !== TRUE) {
         echo 'user cannot add to databse';
     }
 }
开发者ID:AliEksi,项目名称:DokuDok,代码行数:9,代码来源:adminUser.php

示例3: __construct

 /**
  * @param Spider\Component\Config
  */
 public function __construct(Config $Config)
 {
     $Storage = $Config->getStorage();
     $Connection = $Config->getConnection();
     $this->script = escapeshellarg(__DIR__ . "/../bin/weeve.php");
     $this->conn = base64_encode($Connection->sleep());
     $this->storage = base64_encode($Storage->sleep());
     $this->memory = $Config->getMemory();
     $this->table = $Config->getTable();
     $this->trace = $Config->getTrace();
 }
开发者ID:jessecascio,项目名称:spider,代码行数:14,代码来源:Nest.php

示例4: get_pathname

function get_pathname()
{
    $config = new Config();
    $conn = $config->getConnection();
    $query = "SELECT pathname from admin";
    $result = $conn->query($query);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            return $row["pathname"];
        }
    }
}
开发者ID:AliEksi,项目名称:DokuDok,代码行数:12,代码来源:client_functions.php

示例5: save

 public function save()
 {
     $config = new Config();
     $conn = $config->getConnection();
     $exist_q = "SELECT docname FROM books WHERE docname = '{$this->docName}'";
     if (mysqli_num_rows($conn->query($exist_q)) != 0) {
         return;
     }
     $query = "INSERT INTO books (docname, title, pagenum)\n\t\t\t\tVALUES ('{$this->docName}', '{$this->title}', '{$this->pageNum}')";
     if ($conn->query($query) !== TRUE) {
         echo 'something bad happened while saving';
     }
 }
开发者ID:AliEksi,项目名称:DokuDok,代码行数:13,代码来源:document.php

示例6: titleToDocName

 public static function titleToDocName($title)
 {
     $query = "SELECT docname,title from books";
     $conn = new Config();
     $result = $conn->getConnection()->query($query);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             if ($row["title"] == $title) {
                 return $row["docname"];
             }
         }
     }
 }
开发者ID:AliEksi,项目名称:DokuDok,代码行数:13,代码来源:viewer_model.php

示例7: searchUser

 public static function searchUser($passwd)
 {
     $config = new Config();
     $conn = $config->getConnection();
     $sql = "SELECT id, password FROM users";
     $result = $conn->query($sql);
     if ($result->num_rows > 0) {
         // output data of each row
         while ($row = $result->fetch_assoc()) {
             // echo "id: " . $row["id"]. " - Name: " . $row["password"]. "<br>";
             if ($passwd == $row["password"]) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:AliEksi,项目名称:DokuDok,代码行数:17,代码来源:users.php

示例8: verify_admin

function verify_admin()
{
    $config = new Config();
    $conn = $config->getConnection();
    $query = "SELECT username,password from admin";
    $result = $conn->query($query);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            if ($_POST['username'] == $row['username'] && $_POST['password'] == $row['password']) {
                session_start();
                $_SESSION['username'] = $_POST['username'];
                $_SESSION['password'] = $_POST['password'];
                return TRUE;
            }
        }
    }
    return FALSE;
}
开发者ID:AliEksi,项目名称:DokuDok,代码行数:18,代码来源:admin_functions.php

示例9: removeOlds

 private function removeOlds()
 {
     $conf = new Config();
     $conn = $conf->getConnection();
     $sql = "SELECT docname from books";
     $result = $conn->query($sql);
     if ($result->num_rows > 0) {
         # code...
         while ($row = $result->fetch_assoc()) {
             if (!in_array($row["docname"], $this->fileArray)) {
                 $delSql = "DELETE FROM books WHERE docname='" . $row['docname'] . "'";
                 if ($conn->query($delSql) === TRUE) {
                     echo "Deleted : " . $row["docname"] . "<br>";
                 } else {
                     echo "Error : " . $row["docname"] . "<br>";
                 }
             }
         }
     }
 }
开发者ID:AliEksi,项目名称:DokuDok,代码行数:20,代码来源:list.php

示例10: session_getUid

/**
  Returns the UserId for the current session or dies.
  It is strongly advised to check if the session is valid first.
*/
function session_getUid()
{
    if (!isset($_SESSION['UserId'])) {
        Config::error('UserId is not set in validate.php:session_getUid()');
    }
    return Config::getConnection()->escape_string($_SESSION['UserId']);
}
开发者ID:pombredanne,项目名称:soundcomparisons,代码行数:11,代码来源:validate.php

示例11: CONCAT

 /**
   @param $studyId String CONCAT(StudyIx, FamilyIx)
   @return $defaults [ language => LanguageIx
                     , word => CONCAT(IxElicitation,IxMorpholigcalInstance)
                     , languages => [LanguageIx]
                     , words => [CONCAT(IxElicitation,IxMorpholigcalInstance)]
                     , excludeMap => [LanguageIx]]
   Given a studyId, this method fetches the default words and languages.
 */
 public static function getDefaults($studyId)
 {
     $db = Config::getConnection();
     $sId = $db->escape_string($studyId);
     $ret = array();
     //Single queries:
     foreach (array('language' => "SELECT LanguageIx FROM Default_Languages " . "WHERE CONCAT(StudyIx, FamilyIx) = {$sId} LIMIT 1", 'word' => "SELECT IxElicitation, IxMorphologicalInstance FROM Default_Words " . "WHERE CONCAT(StudyIx, FamilyIx) = {$sId} LIMIT 1") as $k => $q) {
         $ret[$k] = $db->query($q)->fetch_assoc();
     }
     //Multiple queries:
     foreach (array('languages' => "SELECT LanguageIx FROM Default_Multiple_Languages " . "WHERE CONCAT(StudyIx, FamilyIx) = {$sId}", 'words' => "SELECT IxElicitation, IxMorphologicalInstance FROM Default_Multiple_Words " . "WHERE CONCAT(StudyIx, FamilyIx) = {$sId}", 'excludeMap' => "SELECT LanguageIx FROM Default_Languages_Exclude_Map " . "WHERE CONCAT(StudyIx, FamilyIx) = {$sId}") as $k => $q) {
         $ret[$k] = static::fetchAll($q);
     }
     return $ret;
 }
开发者ID:pombredanne,项目名称:soundcomparisons,代码行数:24,代码来源:dataProvider.php

示例12: array

<?php

/*
  This script harvests wikipediaLinks and stores them in the database.
  Links are searched for every ISO code and every Translation in the db.
*/
require_once '../config.php';
$dbConnection = Config::getConnection();
/*
  We need the ISOCodes from all studies,
  so we first need all studies:
*/
$studies = array();
$set = $dbConnection->query('SELECT Name FROM Studies');
while ($r = $set->fetch_row()) {
    array_push($studies, $r[0]);
}
//Looking for ISOCodes and LinkParts:
$targets = array();
foreach ($studies as $study) {
    $q = "SELECT ISOCode, WikipediaLinkPart FROM Languages_{$study} WHERE ISOCODE != ''";
    $set = $dbConnection->query($q);
    while ($r = $set->fetch_row()) {
        $targets[implode(',', $r)] = $r;
    }
}
echo "Targets loaded:\t" . count($targets) . "\n";
/*
  They are originally used to determine the browser language,
  but for now I'll use them also to figure out the wikipedia language
  necessary for that translation.
开发者ID:pombredanne,项目名称:soundcomparisons,代码行数:31,代码来源:wikipediaLinks.php

示例13: getStatement

 /**
  * Generate a prepare statement
  *
  * @param $sql
  *
  * @return \PDOStatement
  */
 protected static function getStatement($sql)
 {
     return Config::getConnection()->prepare($sql);
 }
开发者ID:ptejada,项目名称:userid-core,代码行数:11,代码来源:ModelAbstract.php

示例14: search

 /**
   @param $tId TranslationId the Translation to search
   @param $searchText String the Text to search
   @param $searchStrategy {'both','translation','original'}
   @return $ret [obj] || Exception
   obj will be arrays resembling JSON objects following this syntax:
   {
     Description: {Req: '', Description: ''}
   , Original: ''
   , Translation: {TranslationId: 5, Translation: '', Payload: '', TranslationProvider: ''}
   }
   Searches for the given $searchText and returns array to allow translation for found entries.
   $searchStrategy specifies if the originals, the translations or both should be searched.
 */
 public function search($tId, $searchText, $searchStrategy = 'both')
 {
     //Sanitizing $tId:
     $tId = is_numeric($tId) ? $tId : 1;
     //Sanitizing $searchText:
     $searchText = Config::getConnection()->escape_string($searchText);
     //Sanitizing $searchStrategy:
     if (preg_match('/^(both|translation|original)$/', $searchStrategy) === 0) {
         return new Exception("Invalid \$searchStrategy: '{$searchStrategy}'");
     }
     //Table to use:
     $tableName = $this->getTable();
     //Study to use:
     $study = $this->getStudy();
     // String || null
     //Column specific code:
     return $this->withColumn(function ($column) use($tId, $searchText, $searchStrategy, $tableName, $study) {
         $category = $column['category'];
         //Description to use for entries:
         $description = TranslationTableProjection::fetchDescription($column);
         //Payload -> $entry to prevent duplicates
         $payloadMap = array();
         //Searching in originals:
         if ($searchStrategy === 'both' || $searchStrategy === 'original') {
             $columnName = $column['columnName'];
             $fieldSelect = $column['fieldSelect'];
             $q = "SELECT {$columnName} AS columnName, {$fieldSelect} AS fieldSelect " . "FROM {$tableName} " . "WHERE {$columnName} LIKE '%{$searchText}%'";
             $originals = DataProvider::fetchAll($q);
             foreach ($originals as $original) {
                 $fieldSelect = $original['fieldSelect'];
                 if ($study !== null) {
                     $fieldSelect = "{$study}-{$fieldSelect}";
                 }
                 //Stub for $entry:
                 $entry = array('Description' => $description, 'Original' => $original['columnName'], 'Translation' => array('TranslationId' => $tId, 'Translation' => '', 'Payload' => $fieldSelect, 'TranslationProvider' => $category));
                 if ($study !== null) {
                     $entry['Study'] = $study;
                 }
                 //Trying to add existing translation:
                 $entry = $this->addTranslation($entry);
                 //Putting $entry into map:
                 $payloadMap[$fieldSelect] = $entry;
             }
         }
         //Searching in translations:
         if ($searchStrategy === 'both' || $searchStrategy === 'translation') {
             //Setting $columnName and $fieldSelect:
             $columnName = $column['columnName'];
             $fieldSelect = $column['fieldSelect'];
             //Need to fetch all originals to find matching translations:
             $q = "SELECT {$columnName} AS columnName, {$fieldSelect} AS fieldSelect " . "FROM {$tableName} ";
             $originals = DataProvider::fetchAll($q);
             foreach ($originals as $original) {
                 $fieldSelect = $original['fieldSelect'];
                 if ($study !== null) {
                     $fieldSelect = "{$study}-{$fieldSelect}";
                 }
                 //Preventing possible duplicates:
                 if (array_key_exists($fieldSelect, $payloadMap)) {
                     continue;
                 }
                 //Checking for translation:
                 $q = "SELECT Trans FROM Page_DynamicTranslation " . "WHERE TranslationId = {$tId} " . "AND Category = '{$category}' " . "AND Field = '{$fieldSelect}' " . "AND Trans LIKE '%{$searchText}%' " . "LIMIT 1";
                 foreach (DataProvider::fetchAll($q) as $r) {
                     //foreach works as if
                     $entry = array('Description' => $description, 'Original' => $original['columnName'], 'Translation' => array('TranslationId' => $tId, 'Translation' => $r['Trans'], 'Payload' => $fieldSelect, 'TranslationProvider' => $category));
                     if ($study !== null) {
                         $entry['Study'] = $study;
                     }
                     $payloadMap[$fieldSelect] = $entry;
                 }
             }
         }
         //Done:
         return array_values($payloadMap);
     });
 }
开发者ID:pombredanne,项目名称:soundcomparisons,代码行数:91,代码来源:translationColumnProjection.php

示例15: getRfcLanguages

 /**
   Since we don't have a RfcLanguages nor a Languages view anymore,
   this is going to be a little more complicated:
   We need to iterate all Languages_<study> tables,
   and select all RfcLanguages from them.
   @return array LanguageIx => ShortName
 */
 public static function getRfcLanguages()
 {
     $dbConnection = Config::getConnection();
     $set = $dbConnection->query('SELECT Name FROM Studies');
     $studies = array();
     while ($r = $set->fetch_row()) {
         array_push($studies, $r[0]);
     }
     $ret = array();
     foreach ($studies as $study) {
         $q = "SELECT ShortName, LanguageIx FROM Languages_{$study} " . "WHERE LanguageIx = ANY (" . "SELECT DISTINCT RfcLanguage FROM Languages_{$study} " . "WHERE RfcLanguage IS NOT NULL)";
         $set = $dbConnection->query($q);
         if ($set === false) {
             //May fail if a studies entry exists but no Lanugage_$study table…
             Config::error("Problem with query: {$q}", false, false);
         } else {
             while ($r = $set->fetch_row()) {
                 $ret[$r[1]] = $r[0];
             }
         }
     }
     return $ret;
 }
开发者ID:pombredanne,项目名称:soundcomparisons,代码行数:30,代码来源:translationClass.php


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