本文整理汇总了PHP中UserMapper::find方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::find方法的具体用法?PHP UserMapper::find怎么用?PHP UserMapper::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindUser
public function testFindUser()
{
$userName = "forFindUser";
$user = getUserInstance($userName);
$umapper = new UserMapper(self::$pdo);
$umapper->insert($user);
$newUser = $umapper->find($user->user_id);
$this->assertEquals($userName, $newUser->user_name);
}
示例2: PostMapper
#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
示例3: catch
<?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());
}
示例4: testInit
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');
示例5: json_encode
<?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);