本文整理汇总了PHP中DBC类的典型用法代码示例。如果您正苦于以下问题:PHP DBC类的具体用法?PHP DBC怎么用?PHP DBC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a new record found at the given zero-based position in the associated DBC
*/
public function __construct(DBC $dbc, $pos)
{
$this->_dbc = $dbc;
$this->_pos = $pos;
$this->_offset = DBC::HEADER_SIZE + $pos * $dbc->getRecordSize();
$handle = $dbc->getHandle();
fseek($handle, $this->_offset);
if ($dbc->getRecordSize() > 0) {
$this->_data = fread($handle, $dbc->getRecordSize());
}
}
示例2: before
public function before($context)
{/*{{{*/
parent::before($context);
$group = DAL::get()->find_parent('FinanceInspectGroup');
DBC::requireTrue($group->among($context->response->curInspector), '你没有权限访问');
}/*}}}*/
示例3: addFlowChargeOrder
public function addFlowChargeOrder($request, $response)
{
/*{{{*/
$refId = $request->getRequest('refid', true);
$ref = DAL::get()->find('DoctorPatientRef', $refId);
$isdpRef = $ref instanceof DoctorPatientRef;
$isUserSelf = $ref->user->id == $this->user->id;
$isOpenCharge = $ref->space->isChargeOpened();
DBC::requireTrue($isdpRef && $isUserSelf && $isOpenCharge, '对不起,您不能预充值');
if ($this->checkCanCharge($ref)) {
$this->message("抱歉!现在不能购买。您已经提前购买了{$ref->space->name}医生的3次指导机会,为避免资源浪费,请在使用后再次够买。", $response, array('text' => '点击这里继续', 'url' => $ref->getUrl()));
} else {
$product = ProductClient::getInstance()->getDoctorChargeFlowProduct($ref->space);
$charge = $product->salePrice;
$cashAccount = $this->user->getCashAccount();
if ($cashAccount->amount >= $charge) {
$serviceOrder = ServiceOrderClient::getInstance()->create($ref, $product, $this->user);
if (false == $serviceOrder->isNull()) {
ServiceOrderClient::getInstance()->pay($serviceOrder, $this->user);
$serviceOrder = DAL::get()->find('serviceOrder', $serviceOrder->id, true);
}
if ($serviceOrder->isPaid()) {
$response->setRedirect($serviceOrder->successUrl());
return parent::DIRECT_OUTPUT;
}
}
$url = 'http://' . URL_PREFIX . 'passport.haodf.com/telpayment/showtelaccount';
$this->message('您的余额不足,不能购买,请充值后重新购买', $response, array('text' => '去充值', 'url' => $url));
}
}
示例4: validate
public function validate(&$data, $single = false)
{
$p = DBC::queryOneAssoc("\n\t\t\tSELECT p_id\n\t\t\tFROM wog_player\n\t\t\tWHERE p_id={$data['p_id']}\n\t\t");
if (!$p) {
alert('玩家不存在');
}
}
示例5: detail
public function detail($request, $response)
{/*{{{*/
$articleId = intval($request->getRequest('article_id', 0));
$article = DAL::get()->find('article', $articleId);
if($article->isNull())
{
$this->_exit404();
}
DBC::requireFalse($article->isDelete(), "文章已经被删除了!");
DBC::requireFalse($article->isShield(), "文章正在审核中!");
if ($article->isAuditing())
{
$result = $this->filterArticle($article);
if (false == empty($result['title']) || false == empty($result['content']))
{
DBC::requireFalse(true, "文章正在审核中!");
}
}
$isShare = $request->getRequest('isShare', '');
//分享文章阅读量统计
if(false == empty($isShare))
{
HitClient::getInstance()->increaseArticleHitsForShare($article->id);
}
$response->article = $article;
$response->topTitle = XString::truncate($article->title, 18);
$response->title = $article->title."_好大夫在线";
$articleAttachmentRef = new NullEntity();
if ($article->hasDocAttachment())
{
$articleAttachmentRef = ArticleClient::getInstance()->getValidAttachmentRef($article->id);
}
$response->articleAttachmentRef = $articleAttachmentRef;
}/*}}}*/
示例6: testMigrateData
function testMigrateData()
{
$prefix = $this->getPrefix();
$this->initDatabase(126, array('zones', 'ad_zone_assoc', 'placement_zone_assoc', 'banners'));
$aAValues = array(array('zoneid' => 1, 'zonetype' => 0, 'what' => ''), array('zoneid' => 2, 'zonetype' => 0, 'what' => 'bannerid:3'), array('zoneid' => 3, 'zonetype' => 3, 'what' => 'clientid:3'), array('zoneid' => 4, 'zonetype' => 3, 'what' => 'clientid:5', 'delivery' => phpAds_ZoneText), array('zoneid' => 5, 'zonetype' => 3, 'what' => 'clientid:5', 'delivery' => phpAds_ZoneBanner, 'width' => 468, 'height' => 60), array('zoneid' => 6, 'zonetype' => 0, 'what' => 'bannerid:2,bannerid:3'), array('zoneid' => 7, 'zonetype' => 3, 'what' => 'clientid:3,clientid:4'), array('zoneid' => 8, 'zonetype' => 0, 'what' => 'bannerid:2,bannerid:3,bannerid:4,bannerid:5'), array('zoneid' => 9, 'zonetype' => 3, 'what' => 'clientid:,clientid:3'));
foreach ($aAValues as $aValues) {
// Set empty defaults for NOT NULL fields
$aValues['chain'] = $aValues['prepend'] = $aValues['append'] = '';
$sql = OA_DB_Sql::sqlForInsert('zones', $aValues);
$this->oDbh->exec($sql);
}
$aABannerValues = array(array('bannerid' => 1, 'campaignid' => 3), array('bannerid' => 2, 'campaignid' => 3), array('bannerid' => 3, 'campaignid' => 4), array('bannerid' => 4, 'campaignid' => 4), array('bannerid' => 5, 'campaignid' => 5, 'storagetype' => 'txt'), array('bannerid' => 6, 'campaignid' => 5, 'storagetype' => 'sql', 'width' => 468, 'height' => 60), array('bannerid' => 7, 'campaignid' => 5, 'storagetype' => 'sql', 'width' => 125, 'height' => 125));
foreach ($aABannerValues as $aBannerValues) {
// Set empty defaults for NOT NULL fields
$aBannerValues['htmltemplate'] = $aBannerValues['htmlcache'] = $aBannerValues['bannertext'] = $aBannerValues['compiledlimitation'] = $aBannerValues['append'] = '';
$sql = OA_DB_Sql::sqlForInsert('banners', $aBannerValues);
$this->oDbh->exec($sql);
}
$this->upgradeToVersion(127);
$aAssocTables = array("{$prefix}ad_zone_assoc WHERE link_type = 1" => 17, "{$prefix}ad_zone_assoc WHERE link_type = 0" => 7, "{$prefix}placement_zone_assoc" => 6);
foreach ($aAssocTables as $assocTable => $cAssocs) {
$rsCAssocs = DBC::NewRecordSet("SELECT count(*) AS cassocs FROM {$assocTable}");
$this->assertTrue($rsCAssocs->find());
$this->assertTrue($rsCAssocs->fetch());
$this->assertEqual($cAssocs, $rsCAssocs->get('cassocs'), "%s: The table involved: {$assocTable}");
}
}
示例7: newPost
public function newPost($request, $response)
{
/*{{{*/
$verifyOk = Captcha::verify($request->verifyStr, XIpLocation::getIp(), 'article', $request->article_id, $request->token);
DBC::requireTrue($verifyOk, "您输入的验证码有误!");
//禁用词检查
$title = $request->title;
$result = DoctorClient::getInstance()->getProfanityCheck($title);
DBC::requireFalse($result['CODE'] < 0, "文章 评论添加失败");
DBC::requireFalse($result['CODE'] == 2, "文章 评论添加成功");
$title = $result['CONTENT'];
$content = htmlspecialchars($request->getRequest('content'), ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
$result = DoctorClient::getInstance()->getProfanityCheck($content);
DBC::requireFalse($result['CODE'] < 0, "文章 评论添加失败");
DBC::requireFalse($result['CODE'] == 2, "文章 评论添加成功");
$content = $result['CONTENT'];
$article = DAL::get()->find('article', $request->article_id);
$feilds = array();
$feilds['ip'] = XIpLocation::getIp();
$feilds['ipLocation'] = XIpLocation::getLocationArea();
$userId = $this->user->isNull() == false ? $this->user->id : '';
$comment = ArticleClient::getInstance()->addComment($article, $userId, $title, $content, $feilds);
squid::clean($article->getUrl(), true);
$this->message('您发表的评论已经提交,待网站审核通过后即可展示。', $response);
}
示例8: sanitizeShowData
public static function sanitizeShowData($d)
{
if ($d['syn_need_mission'] == 0) {
$d['m_subject'] = '無';
}
if (in_array($d['d_type'], array(5, 6))) {
$d['d_name'] .= '*' . $d['syn_num'];
}
$tmplist = explode(',', $d['syn_element']);
$itemlist = $listmap = [];
$listmap = [];
$result = array();
foreach ($tmplist as $v) {
$v = explode('*', $v);
$itemlist[] = $v[0];
$listmap[$v[0]] = $v[1];
}
$query = DBC::query('
SELECT d_id, d_name
FROM wog_df
WHERE d_id IN (' . implode(',', $itemlist) . ')
');
while ($item = $query->fetchAssoc()) {
$result[] = $item['d_name'] . '*' . $listmap[$item['d_id']];
}
$d['syn_name'] = implode(', ', $result);
unset($d['d_type']);
return $d;
}
示例9: detail
public function detail($request, $response)
{/*{{{*/
$threadId = (int)$request->case_id;
$criticalNum = 100*100*1000;
$correctNum = 100*100*100;
$threadId = $threadId > $criticalNum ? $threadId : $threadId-$correctNum;
$proposal = DAL::get()->find('proposal', $threadId);
if(false == $proposal->isNull())
{
$response->setRedirect($proposal->getTouchUrl());
return 0;
}
else
{
$intention = DAL::get()->find('intention', $threadId);
if(false == $intention->isNull())
{
$response->setRedirect($intention->getTouchUrl());
return 0;
}
else
{
DBC::requireTrue(false, 'Êý¾ÝÎÊÌâ');
}
}
}/*}}}*/
示例10: testMigrateData
function testMigrateData()
{
$prefix = $this->getPrefix();
$this->initDatabase(121, array('clients', 'campaigns'));
$aCampaigns = array(array('clientid' => 3, 'parent' => 1, 'views' => '100', target => '1000'), array('clientid' => 4, 'parent' => 1, 'views' => '200', target => '1'), array('clientid' => 5, 'parent' => 1, 'views' => '200', target => '0'));
$cCampaigns = count($aCampaigns);
$aAValues = array(array('clientid' => 1, 'parent' => 0, 'views' => '0', target => '0'), array('clientid' => 2, 'parent' => 0, 'views' => '0', target => '0'));
$aAValues = array_merge($aAValues, $aCampaigns);
foreach ($aAValues as $aValues) {
$sql = OA_DB_Sql::sqlForInsert('clients', $aValues);
$this->oDbh->exec($sql);
}
$this->upgradeToVersion(122);
$tableCampaigns = $this->oDbh->quoteIdentifier($prefix . 'campaigns', true);
$rsCampaigns = DBC::NewRecordSet("SELECT * from {$tableCampaigns}");
$this->assertTrue($rsCampaigns->find());
$this->assertEqual($cCampaigns, $rsCampaigns->getRowCount());
for ($idxCampaign = 0; $idxCampaign < $cCampaigns; $idxCampaign++) {
$this->assertTrue($rsCampaigns->fetch());
$this->assertEqual($aCampaigns[$idxCampaign]['clientid'], $rsCampaigns->get('campaignid'));
$this->assertEqual($aCampaigns[$idxCampaign]['parent'], $rsCampaigns->get('clientid'));
$this->assertEqual($aCampaigns[$idxCampaign]['views'], $rsCampaigns->get('views'));
$priority = $aCampaigns[$idxCampaign]['target'] > 0 ? 5 : 0;
$this->assertEqual($priority, $rsCampaigns->get('priority'));
}
$tableClients = $this->oDbh->quoteIdentifier($prefix . 'clients', true);
$rsClients = DBC::NewRecordSet("SELECT count(*) AS nclients FROM {$tableClients}");
$this->assertTrue($rsClients->find());
$this->assertTrue($rsClients->fetch());
$this->assertEqual(count($aAValues) - $cCampaigns, $rsClients->get('nclients'));
if ($this->oDbh->dbsyntax == 'pgsql') {
$value = $this->oDbh->queryOne("SELECT NEXTVAL('{$prefix}campaigns_campaignid_seq')");
$this->assertTrue($value > 5, "The current sequence value is {$value}.");
}
}
示例11: url
private function url()
{
$dbc = new DBC();
if (isset($_GET['url'])) {
// get the URL from the base defined in the.htaccess file.
// filter url
# Example: www.yourdomain.com/example-page/hello/1/title/
$url = filter_var(mysqli_real_escape_string($dbc->connect(), trim($_GET['url'])), FILTER_SANITIZE_URL);
// delete last / if it is there.
$url = rtrim($url, '/');
# Exampele change 1: $url = example-page/hello/1/title
/*
* Remove the - (dash) in the url : EX. example-page/hello. Classnames can't have the - (dash) so class is written as examplePage.
* to call the function we need to remove the - (dash)
*/
# Example change 2: $url = examplepage/hello/1/title
$url = str_replace('-', '', $url);
// create array with all the url parts.
# Example change 3: $url = ["examplepage","hello",1,"title"]
$url = explode('/', $url);
// add all array values to the class var routes.
foreach ($url as $key => $value) {
$this->routes[$key] = $value;
}
}
}
示例12: export
/**
* Exports given DBC in XML format to given target (defaults to output stream)
*/
public function export(DBC $dbc, $target = self::OUTPUT)
{
$map = $dbc->getMap();
if ($map === null) {
throw new DBCException(self::NO_MAP);
return;
}
$dom = new DOMDocument('1.0');
$dom->formatOutput = true;
$edbc = $dom->appendChild($dom->createElement('dbc'));
$efields = $edbc->appendChild($dom->createElement('fields'));
$erecords = $edbc->appendChild($dom->createElement('records'));
$fields = $map->getFields();
foreach ($fields as $name => $rule) {
$count = max($rule & 0xff, 1);
if ($rule & DBCMap::UINT_MASK) {
$type = 'uint';
} else {
if ($rule & DBCMap::INT_MASK) {
$type = 'int';
} else {
if ($rule & DBCMap::FLOAT_MASK) {
$type = 'float';
} else {
if ($rule & DBCMap::STRING_MASK || $rule & DBCMap::STRING_LOC_MASK) {
$type = 'string';
}
}
}
}
for ($i = 1; $i <= $count; $i++) {
$suffix = $count > 1 ? $i : '';
$efields->appendChild($dom->createElement($name . $suffix, $type));
}
}
foreach ($dbc as $i => $record) {
$pairs = $record->extract();
$erecord = $erecords->appendChild($dom->createElement('record'));
foreach ($pairs as $field => $value) {
$attr = $dom->createAttribute($field);
$attr->value = $value;
$erecord->appendChild($attr);
}
}
$data = $dom->saveXML();
file_put_contents($target, $data);
}
示例13: before
public function before($context)
{
parent::before($context);
$mark = DAL::get()->find('flowproposalmark', $context->request->markId);
DBC::requireFalse($mark->isNull(), '无效的标记');
$inspectNames = array($mark->inspector->user->name, 'lihao120', 'sunnysmell', 'lyly006', 'pilack');
$context->request->validAccess = in_array($context->response->curInspector->user->name, $inspectNames);
}
示例14: before
public function before($context)
{
$userId = UserClient::getInstance()->getCheckedSeed('id');
$user = DAL::get()->mustFind('user', $userId);
$inspector = DAL::get()->find_actived('inspector', $user);
$hasClaimPaymentPower = $inspector->isInRenLingHuiKuanGroup();
DBC::requireTrue($hasClaimPaymentPower, '您没有认领汇款权限');
}
示例15:
/**
* Returns the record set for either 'acls' or 'acls_channels' table,
* all records and rows.
*
* @param string $table Either 'acls' or 'acls_channels'
* @return RecordSet
*/
function &getRsAcls($table, $orderBy = false)
{
$table = $this->oDbh->quoteIdentifier($this->getTablePrefix() . $table);
$query = "\n SELECT\n *\n FROM\n {$table}";
if ($orderBy) {
$query .= " ORDER BY " . $this->oDbh->quoteIdentifier($orderBy);
}
return DBC::NewRecordSet($query);
}