本文整理汇总了PHP中DAOFactory::getMessagesDAO方法的典型用法代码示例。如果您正苦于以下问题:PHP DAOFactory::getMessagesDAO方法的具体用法?PHP DAOFactory::getMessagesDAO怎么用?PHP DAOFactory::getMessagesDAO使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAOFactory
的用法示例。
在下文中一共展示了DAOFactory::getMessagesDAO方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/priv_dao/include_dao.php';
// $ip = '' ;
// if( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
// $ip = $_SERVER['HTTP_CLIENT_IP'] ;
// } else if ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
// $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
// } else {
// $ip = $_SERVER['REMOTE_ADDR'] ;
// }
// date_default_timezone_set( 'ASIA/SHANGHAI' ) ;
// $time = date( 'Y-m-d H:i:s ' , time( ) ) ;
// print $ip.' -- ip<br/>' ;
// print $time.' -- time<br/>' ;
// $transaction = new Transaction();
// $message = new Message( ) ;
// $message->time = $time ;
// $message->ip = $ip ;
// $message->content = 'test' ;
// DAOFactory::getMessagesDAO()->insert($message);
// $transaction->commit();
$messages = DAOFactory::getMessagesDAO()->queryAllOrderBy('time');
// foreach( $messages as $message ) {
// print $message->time." ".$message->ip." ".$message->content."<br/>" ;
// }
示例2: date_default_timezone_set
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/priv_dao/include_dao.php';
$ip = '';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
}
date_default_timezone_set('ASIA/SHANGHAI');
$time = date('Y-m-d H:i:s ', time());
$transaction = new Transaction();
$message = new Message();
$message->time = $time;
$message->ip = $ip;
$message->content = $_POST['message'];
DAOFactory::getMessagesDAO()->insert($message);
$transaction->commit();
示例3: array_reverse
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/priv_dao/include_dao.php';
$messages = array_reverse(DAOFactory::getMessagesDAO()->queryAllOrderBy('time'));