本文整理汇总了PHP中ConnectionFactory::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionFactory::getConnection方法的具体用法?PHP ConnectionFactory::getConnection怎么用?PHP ConnectionFactory::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionFactory
的用法示例。
在下文中一共展示了ConnectionFactory::getConnection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFunctional
public function testFunctional()
{
$pdo = $this->factory->getConnection();
$this->assertInstanceOf('PDO', $pdo);
$pdo->exec("CREATE TABLE `foo`(`id` int,`name` varchar)");
$pdo->exec("insert into `foo` VALUES (1,'foo')");
$repo = new FooRepository($this->factory);
$entity = $repo->getById(1);
$expected = new FooEntity();
$expected->id = 1;
$expected->name = 'foo';
$this->assertEquals($expected, $entity);
}
示例2: inScriptPermissionsCheck
public static function inScriptPermissionsCheck($user_id, $showMenuIfFailed)
{
$pageURI = $_SERVER['REQUEST_URI'];
if (!Permissions::hasPermissionsForScript($user_id, $pageURI)) {
if ($showMenuIfFailed) {
include dirname(dirname(__FILE__)) . '/include/header.include.php';
} else {
echo '<html><head></head><body>';
}
echo '<h3>You need the following permissions to use this page:</h3>';
echo '<ul>';
$fileCache = self::createFileCache();
$db = null;
$ps = new PreparedStatement('select description from appperm where perm_name = ?');
foreach (Permissions::getRequiredPermissionsForScript($pageURI) as $p) {
$cacheKey = sprintf('apppermDesc%s', $p);
if (($desc = $fileCache->get($cacheKey)) === false) {
if ($db === null) {
$db = ConnectionFactory::getConnection();
}
$ps->clearParams();
$ps->setString($p);
if (($row = $db->fetchObject($db->executeQuery($ps), true)) !== false) {
$desc = $row->description;
} else {
$desc = $p;
}
$fileCache->set($cacheKey, $desc);
}
echo '<li>';
echo htmlspecialchars($desc);
echo '</li>';
}
if ($db !== null) {
$db->close();
}
echo '</ul>';
if ($showMenuIfFailed) {
include dirname(dirname(__FILE__)) . '/include/footer.include.php';
} else {
echo '</body></html>';
}
exit;
}
}
示例3: dirname
// If you need to customize this file, please edit the corresponding
// yaml file in the gencfg directory, and then re-generate this file
// by running searchgen, passing in the table name.
include dirname(dirname(dirname(__FILE__))) . '/jax/include/l10n.include.php';
loadResourceBundle(dirname(dirname(dirname(__FILE__))) . '/jax/resources/system');
loadResourceBundle(dirname(dirname(dirname(__FILE__))) . '/resources/system');
loadResourceBundle(__FILE__);
if (isset($command) && $command == 'searchPostingtypes_getSearchableColumns') {
header('Content-Type: application/json');
$searchableColumns = array((object) array('name' => 'id', 'pfx' => 'pri.', 'title' => _t('postingtype_search.searchableColumn.id.title', 'Id'), 'sqlType' => 'integer', 'queryOperator' => '='), (object) array('name' => 'description', 'pfx' => 'pri.', 'title' => _t('postingtype_search.searchableColumn.description.title', 'Description'), 'sqlType' => 'varchar', 'queryOperator' => 'contains'), (object) array('name' => 'normal_sign', 'pfx' => 'pri.', 'title' => _t('postingtype_search.searchableColumn.normal_sign.title', 'Normal Sign'), 'sqlType' => 'char', 'queryOperator' => 'contains'));
echo json_encode($searchableColumns);
exit;
}
if (isset($command) && $command == 'searchPostingtypes') {
header('Content-Type: application/json');
$db = ConnectionFactory::getConnection();
$returnColumns = isset($params['sColumns']) ? explode(',', preg_replace('/[^a-zA-Z0-9_$,]/', '', $params['sColumns'])) : array();
$sEcho = isset($params['sEcho']) ? (int) $params['sEcho'] : 0;
$offset = isset($params['iDisplayStart']) ? (int) $params['iDisplayStart'] : 0;
$limit = isset($params['iDisplayLength']) ? (int) $params['iDisplayLength'] : 0;
if ($limit < 1 || $limit > 100) {
$limit = 100;
}
$orderBy = '';
if (isset($params['iSortingCols']) && ($nsc = (int) $params['iSortingCols']) > 0) {
for ($i = 0; $i < $nsc; $i++) {
$sci = isset($params['iSortCol_' . $i]) ? (int) $params['iSortCol_' . $i] : 0;
if ($sci < 0 || $sci >= count($returnColumns)) {
$sci = 0;
}
$scd = isset($params['sSortDir_' . $i]) ? strtolower($params['sSortDir_' . $i]) : 'asc';
示例4: __construct
/**
* コンストラクタ
* @access public
*/
function __construct()
{
$this->db = ConnectionFactory::getConnection();
}
示例5: set
/**
* Set string param
*
* @param String $value value to set
*/
public function set($value)
{
$value = mysqli_escape_string(ConnectionFactory::getConnection(), $value);
$this->params[$this->idx++] = "'" . $value . "'";
}
示例6: Connection
public function Connection(){
$this->connection = ConnectionFactory::getConnection();
}
示例7: catch
try {
@$__loginAppuserpersistentloginDAO->insert($kmli);
} catch (Exception $ex) {
}
// Confirm that we were able to add the row successfully.
$kmlis = $__loginAppuserpersistentloginDAO->findByKeep_me_logged_in_uniqid($kmli->keep_me_logged_in_uniqid);
if (count($kmlis) == 1 && $kmlis[0]->user_id == $loggedInUser->id) {
// Success. Set the cookie and stop trying new unique Ids.
setcookie('kmliuid', $kmli->keep_me_logged_in_uniqid, time() + $KEEP_ME_LOGGED_IN_TIME, '/');
return true;
}
}
return false;
}
$__loginErrorMsg = '';
$__loginDB = ConnectionFactory::getConnection();
$__loginAppuserDAO = new AppuserDAO($__loginDB);
$__loginAppuserpersistentloginDAO = new AppuserpersistentloginDAO($__loginDB);
$loggedInUser = null;
// Try logging in with username and password from a login form POST.
if ($loggedInUser === null && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['loginUserName']) && isset($_POST['loginPassword'])) {
$__loginUsers = $__loginAppuserDAO->findByUser_name(trim($_POST['loginUserName']));
if (empty($__loginUsers)) {
$__loginUsers = $__loginAppuserDAO->findByEmail_addr(trim($_POST['loginUserName']));
}
if (count($__loginUsers) == 1 && $__loginUsers[0] && $__loginUsers[0]->is_active) {
if ($__loginUsers[0]->login_failures >= $MAX_LOGIN_FAILURES && strtotime($__loginUsers[0]->last_login_failure) >= time() - $LOGIN_FAILURE_LOCKOUT_TIME) {
__accountLocked();
}
$loggedInUser = $__loginUsers[0];
$saltidx = strrpos($loggedInUser->password_hash, '{');
示例8: __construct
function __construct(Cliente $cli)
{
$this->dao = ConnectionFactory::getConnection();
$this->cli = $cli;
$this->tabela = strtolower(get_class($this->cli));
}
示例9: Participante
<?php
require_once 'modelos/participante.php';
require_once 'modelos/dao/participante_dao.php';
require_once 'infra/connection_factory.php';
$nome = $_POST['nome'];
$sobrenome = $_POST['sobrenome'];
$email = $_POST['email'];
$participante = new Participante($nome, $sobrenome, $email);
$factory = new ConnectionFactory();
$conexao = $factory->getConnection();
$participanteDao = new ParticipanteDao($conexao);
$participanteDao->adiciona($participante);
?>
示例10: __construct
public function __construct()
{
$cf = new ConnectionFactory();
$this->conn = $cf->getConnection();
}
示例11: executeInsert
public static function executeInsert($sqlQuery)
{
QueryExecutor::executeUpdate($sqlQuery);
return mysqli_insert_id(ConnectionFactory::getConnection());
}
示例12: preViewOutputHook
function preViewOutputHook()
{
global $ALL_PERM_NAMES, $ALL_PERM_DESCRIPTIONS_BY_PERM_NAMES;
$db = ConnectionFactory::getConnection();
$ALL_PERM_NAMES = array();
$ALL_PERM_DESCRIPTIONS_BY_PERM_NAMES = array();
$ps = new PreparedStatement('select perm_name, description from appperm order by perm_name');
$rs = $db->executeQuery($ps);
while ($r = $db->fetchObject($rs)) {
$ALL_PERM_NAMES[] = $r->perm_name;
$ALL_PERM_DESCRIPTIONS_BY_PERM_NAMES[$r->perm_name] = $r->description;
}
$db->freeResult($rs);
$db->close();
}