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
0
 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;
     }
 }
// 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
0
 /**
  * コンストラクタ
  * @access public
  */
 function __construct()
 {
     $this->db = ConnectionFactory::getConnection();
 }
 /**
  * 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 . "'";
 }
	public function Connection(){
		$this->connection = ConnectionFactory::getConnection();
	}
示例#7
0
         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
0
 function __construct(Cliente $cli)
 {
     $this->dao = ConnectionFactory::getConnection();
     $this->cli = $cli;
     $this->tabela = strtolower(get_class($this->cli));
 }
示例#9
0
<?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
0
 public function __construct()
 {
     $cf = new ConnectionFactory();
     $this->conn = $cf->getConnection();
 }
 public static function executeInsert($sqlQuery)
 {
     QueryExecutor::executeUpdate($sqlQuery);
     return mysqli_insert_id(ConnectionFactory::getConnection());
 }
示例#12
0
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();
}