本文整理汇总了PHP中Period类的典型用法代码示例。如果您正苦于以下问题:PHP Period类的具体用法?PHP Period怎么用?PHP Period使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Period类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scanpassword
function scanpassword($password)
{
$lower = false;
$upper = false;
$specialchar = false;
$number = false;
$possibilities = 0;
$special = '!@#$%&*<>-_!@#$%&*<>-_';
for ($i = 0; $i < strlen($password); $i++) {
if (preg_match("/[a-z]/", $password[$i]) && !$lower) {
$possibilities += 26;
$lower = true;
}
if (preg_match('/[A-Z]/', $password[$i]) && !$upper) {
$possibilities += 26;
$upper = true;
}
if (preg_match('/[0-9]/', $password[$i]) && !$number) {
$possibilities += 10;
$number = true;
}
if (strpbrk($password[$i], $special) && !$specialchar) {
$possibilities += 15;
$specialchar = true;
}
}
$product['product'] = pow($possibilities, strlen($password)) / 4000000000;
$product['possibilities'] = $possibilities;
$product['quantity'] = strlen($password);
$objPeriod = new Period();
$product['possibilities'] = $objPeriod->mountPossibilities($product);
return $product;
}
示例2: format
public function format(Period $period)
{
// this method actually has a pretty bad smell on it.
// it does what it's supposed to, but at one point or another it should be
// refactored to use a combination of
// the strategy and chain of responsibility-pattern
// so the variants can be customized
if ($period->getYears() != 0) {
return $this->doFormat($this->lang, 'years', $period->getYears());
}
if ($period->getMonths() != 0) {
return $this->doFormat($this->lang, 'months', $period->getMonths());
}
if ($period->getDays() != 0) {
$amount = $period->getDays();
// if the amount of days is larger than 6 we'll want to
// express it in weeks instead
if ($amount > 6 || $amount < -6) {
$amount = intval($amount / 7);
return $this->doFormat($this->lang, 'weeks', $amount);
} else {
return $this->doFormat($this->lang, 'days', $amount);
}
}
if ($period->getHours() != 0) {
return $this->doFormat($this->lang, 'hours', $period->getHours());
}
if ($period->getMinutes() != 0) {
return $this->doFormat($this->lang, 'minutes', $period->getMinutes());
}
return $this->doFormat($this->lang, 'justNow', 0);
}
示例3: actionIndex
public function actionIndex()
{
$model = new Period('search');
$model->unsetAttributes();
if (isset($_GET['Period'])) {
$model->attributes = $_GET['Period'];
}
$this->render('list', array('model' => $model));
}
示例4: getVoted1k
public static function getVoted1k(Period $period)
{
$q = Doctrine_Query::create()->select('v.*')->from('Vote v')->where('v.id_period = ?', $period->getId())->andWhere('v.weight > 50')->execute()->getFirst();
if ($q) {
return $q->getPrice();
} else {
return false;
}
}
示例5: getSoldArticlesQuery
public static function getSoldArticlesQuery(User $user, Period $period, $c_sort = null)
{
if (!is_null($c_sort)) {
$sortby = $c_sort['sortby'];
$order = $c_sort['order'];
} else {
$sortby = 'pub_date';
$order = 'desc';
}
$q = Doctrine_Query::create()->select('c.id, sum(t.amount) as sell_sum, count(cp.id) as sell_count')->from('Content c')->leftJoin('c.Category ct')->leftJoin('c.ContentPurchase cp')->leftJoin('cp.Transaction t with t.id_period = ?', $period->getId())->where('c.id_user = ?', $user->getId())->andWhere('c.state = "public"')->groupBy('c.id')->orderBy("{$sortby} {$order}");
return $q;
}
示例6: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$Database = new \mysqli(TEST_DB_HOST, TEST_DB_USER, TEST_DB_PASSWORD, TEST_DB);
$oPeriod = new Period($Database);
$oPeriod->setPeriodType('monthly');
$this->object = new Data($Database, $oPeriod);
$sSql = "DELETE FROM `dim_l1`";
$this->object->getDbConnection()->query($sSql);
$sSql = "DELETE FROM `dim_l2`";
$this->object->getDbConnection()->query($sSql);
$sSql = "DELETE FROM `dim_l3`";
$this->object->getDbConnection()->query($sSql);
$sSql = "INSERT INTO `dim_table` (`id`, `table_name`) VALUES (" . self::TEST_TABLE_ID . ", 'test_table')";
$this->object->getDbConnection()->query($sSql);
}
示例7: __construct
/**
* This is construct base of the class.
*
* A public constructor; initializes the variable $instanceDataBase.
*
*/
public function __construct($instanceDataBase)
{
parent::__construct($instanceDataBase);
Period::setDataOperationBusiness($instanceDataBase);
Period::getBusiness();
Period::getDescriptionBusiness();
}
示例8: getR2RPercent
/**
* Return R2R percent
*
* @return int
*/
public static function getR2RPercent()
{
/*
$option = SettingTable::getOptionByName('percent_r2r');
return (int)$option->getValue();
*/
return (double) Period::getCurrentPeriod()->getR2rShare();
}
示例9: getAllInvoicePeriods
public function getAllInvoicePeriods()
{
// status
$all_periods = Period::orderBy('id', 'ASC')->get(['id', 'description']);
$periods = [];
foreach ($all_periods as $period) {
$periods[] = (object) ['value' => $period->id, 'label' => utf8_encode($period->description)];
}
return $periods;
}
示例10: run
public function run()
{
DB::table('periods')->delete();
Period::create(array('start' => '8:00', 'end' => '9:30', 'total' => 10, 'current' => 2, 'schedule_id' => 1));
Period::create(array('start' => '9:30', 'end' => '10:30', 'total' => 10, 'current' => 6, 'schedule_id' => 1));
Period::create(array('start' => '10:30', 'end' => '12:00', 'total' => 10, 'current' => 0, 'schedule_id' => 1));
Period::create(array('start' => '13:00', 'end' => '14:30', 'total' => 10, 'current' => 10, 'schedule_id' => 3));
Period::create(array('start' => '14:30', 'end' => '16:30', 'total' => 10, 'current' => 0, 'schedule_id' => 3));
Period::create(array('start' => '16:30', 'end' => '18:00', 'total' => 8, 'current' => 3, 'schedule_id' => 3));
}
示例11: delete
/**
* Delete this period or related object.
* If no parameters are set, this method deletes current period and re-sort all other periods.
* @param DataMapper|string $object related object to delete from relation.
* @param string $related_field relation internal name.
*/
public function delete($object = '', $related_field = '')
{
if (empty($object) && !is_array($object) && !empty($this->id)) {
$lower_periods = new Period();
$lower_periods->order_by('sorting', 'asc');
$lower_periods->where('sorting > ', $this->sorting);
$lower_periods->get_iterated();
$ids = array();
foreach ($lower_periods as $lower_period) {
$ids[] = $lower_period->id;
}
if (count($ids) > 0) {
$this->db->set('sorting', 'sorting-1', FALSE);
$this->db->where_in('id', $ids);
$this->db->update('periods');
}
}
parent::delete($object, $related_field);
}
示例12: executeVisit
/**
* Show Visit stats
*
* @param sfWebRequest $request
*/
public function executeVisit(sfWebRequest $request)
{
$this->form = new CategorySelectForm();
$iCategoryId = 1;
$iPeriodId = Period::getCurrentPeriod()->getId();
if ($request->getParameter('category', false)) {
$this->form->bind($request->getParameter($this->form->getName()));
$iCategoryId = $this->form->getValue('id_category');
$this->form->setDefault('id_category', $iCategoryId);
}
$this->aFullData = StatisticsTable::getInstance()->getFullStatistics($iPeriodId);
$this->aDataByCategory = StatisticsTable::getInstance()->getFullStatistics($iPeriodId, $iCategoryId);
}
示例13: getByUserIdAndPeriodId
/**
* Enter description here...
*
* @param int $user_id
* @param int $period_id
* @return BalanceUser
*/
public static function getByUserIdAndPeriodId($user_id, $period_id = 0)
{
if ($period_id == 0) {
$period_id = Period::getCurrentPeriod()->getId();
}
$q = Doctrine_Query::create()->from('BalanceUser bu')->where('bu.id_user=?', $user_id)->andWhere('bu.id_period=?', $period_id)->limit(1);
$balance = $q->fetchOne();
if (false === $balance) {
BalanceUser::setInitialRecord($user_id, $period_id);
$balance = self::getByUserIdAndPeriodId($user_id, $period_id);
//throw new sfException('Cannot get Balance for User: '.$user_id.' period: '.$period_id.'. Error in DB data');
}
return $balance;
}
示例14: postInsert
public function postInsert($event)
{
$oStatistics = new Statistics();
$oStatistics->setCategoryId($this->getId());
try {
$iPeriod = Period::getCurrentPeriod();
} catch (sfException $e) {
return;
}
if (false !== $iPeriod) {
$oStatistics->setPeriodId($iPeriod);
$oStatistics->save();
}
}
示例15: executeIndex
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort') && $this->isValidSortColumn($request->getParameter('sort'))) {
$this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page')) {
$this->setPage($request->getParameter('page'));
}
$this->pager = $this->getPager();
$this->sort = $this->getSort();
$user = new User();
$this->dataArray = array('amountSum' => $user->getUserAmountSum('uuser', Period::getCurrentPeriod()->getId()), 'sellPurchaseSum' => $user->getUserSellPurchaseSum('uuser', Period::getCurrentPeriod()->getId()));
}