public function testFindUser() { $userName = "******"; $user = getUserInstance($userName); $umapper = new UserMapper(self::$pdo); $umapper->insert($user); $newUser = $umapper->find($user->user_id); $this->assertEquals($userName, $newUser->user_name); }
#include('DomainObjects.php'); $mapper = new PostMapper($db); $post = new Post(); $post->title = 'New Title'; $post->content = 'New content...'; $post->author_id = 1; //$mapper->insert($post); $post->id = 2; $mapper->update($post); $post = $mapper->find(1); $post->title = 'Updated Title'; $post->content = 'Updated content...'; $mapper->update($post); $posts = $mapper->find(); $userMapper = new UserMapper($db); $user = $userMapper->find(1); p($user); ?> <?php foreach ($posts as $post) { ?> <h1><?php echo $post->title; ?> </h1> <p><?php echo $post->content; ?> </p> <?php
<?php require '../../../vendor/autoload.php'; require '../Resources/User/Mapper/User.php'; use Xeeo\Services\Database\Mongo\Mapper as MongoMapper, Xeeo\Services\Paginator\PaginatorApi, Xeeo\Services\Database\Mongo\Filter; MongoMapper::addConnection(array('name' => 'connectionName', 'url' => 'mongodb://localhost:27017/databaseName')); try { $users = UserMapper::find(); /** * @var PaginatorApi $paginatorApi */ $paginatorApi = PaginatorApi::getInstance(); $paginatorApi->setCollection($users)->setItemsPerPage(3)->setCurrentPage(1)->setUrlPattern("http://www.example.com/page/{#PAGE}")->setHtmlTemplate('../Resources/Paginator/paginationTemplate.phtml'); echo $paginatorApi->render(); } catch (\Exception $e) { print_r($e->getMessage()); }
while (true) { sleep(5); $result = tagToolsParser(exec('python ' . htmlspecialchars($nfcpyPath))); if (!isset($result['IDm'])) { continue; } $dbfacade = DBFacade::I($pdo); $log = $dbfacade->checkin($result['IDm']); $idm = $imapper->find($log->idm_id); $idmArray = $idm->toArray(); $postData = array(); var_dump($idm); if ($idm != NULL) { $postData += array('cardName' => $idm->card_name); $postData += array('checkinNum' => $idm->checkin_num); $user = $umapper->find($idm->user_id); $postData += array('userName' => $user->user_name); } $postData += array('IDm' => $result['IDm']); $postData += array('checkinTime' => $log->checkin_time); $result = file_get_contents($domainName . "touch", false, stream_context_create(array('http' => array('method' => 'POST', 'header' => implode("\r\n", array('Content-Type: application/x-www-form-urlencoded')), 'content' => http_build_query(array('json' => json_encode((array) $postData))))))); // この行を実行すると貯金箱からの入金機能が利用できる // 挙動が恐ろしいほど安定していないかつ現状では500円しか読み取れないので、デフォルトではコメントアウトしておく // exec("php observeMoneyBox.php &"); } // DB clean up function testInit() { $pdo = getPDO('test'); $pdo->beginTransaction(); $pdo->query('DELETE FROM CheckinLogs');
<?php $rootPass = dirname(__FILE__) . '/../../'; require_once $rootPass . 'lib/db/dbfunctions.php'; require_once $rootPass . 'lib/db/Model/User.php'; require_once $rootPass . 'lib/db/Mapper/UserMapper.php'; // $pdo = getPDO('test'); $pdo = getPDO($argv[2]); $umapper = new UserMapper($pdo); $user = $umapper->find((int) $argv[1]); $result = array(); $result += array('userId' => $user->user_id); $result += array('userName' => $user->user_name); $result += array('mailAddress' => $user->mail_address); $result += array('password' => $user->password); $result += array('profile' => $user->profile); $result += array('coin' => $user->coin); header("Content-Type: application/json; charset=utf-8"); echo json_encode($result);