本文整理汇总了PHP中DAO类的典型用法代码示例。如果您正苦于以下问题:PHP DAO类的具体用法?PHP DAO怎么用?PHP DAO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DAO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
public function view()
{
$dao = DAO::getDAO('UserDAO');
if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
// ex: requesting: /user-list/delete/2
$id = trim(sanitizeString($this->params[1]));
$dao->removeById($id);
} else {
if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
$randNum = mt_rand(0, 99999);
$newUser = new User(array('firstName' => 'First', 'lastName' => 'LastName', 'username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'createTime' => dbDateTime()));
// #TODO: implement UserDao.create($newUser) instead.
if ($dao->countAll() > 30) {
// Demo mode: clean up if too many users
$dao->execute("DELETE FROM user");
$dao->execute("vacuum");
}
$dao->insertInto("firstName, lastName, username, email, createTime", $newUser->getFields());
}
}
$users = $dao->getAll();
$v = $this->smarty;
$v->assign('title', 'User List');
$v->assign('inc_content', v('user_list.html'));
$v->assign('users', $users);
$v->assign('totalUsers', $dao->countAll());
$this->display($v, v('index.html'));
}
开发者ID:rsanaie,项目名称:Thin-PHP-Framework,代码行数:28,代码来源:UserList.php
示例2: delLikes
function delLikes($rID)
{
$dao = new DAO();
$dao->delLikes($rID);
echo 'sorry for your dislike!  ';
returnToMovieDetail();
}
开发者ID:a4501150,项目名称:CS425,代码行数:7,代码来源:likes.php
示例3: bookAsMember
function bookAsMember()
{
$userName = $_SESSION['LoginName'];
$dao = new DAO();
$orderNumber = $dao->makeOrder($_GET['sID'], $dao->fetchUserIDByUserName($userName));
echo 'Thanks for your booking ! . Your order number is ' . $orderNumber;
}
开发者ID:a4501150,项目名称:CS425,代码行数:7,代码来源:order.php
示例4: createSections
public function createSections(DAO $dao)
{
if ($dao->queryOK()) {
$sections = array();
$row = $dao->next();
$count = $row['cnt'];
$letter = $row[$this->_subcat_field][0];
$first_section = $last_section = $row[$this->_subcat_field];
while ($row = $dao->next()) {
if ($row[$this->_subcat_field][0] == $letter) {
// aggregating mode
$count += $row['cnt'];
$last_section = $row[$this->_subcat_field];
} else {
// section assignment mode
$section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}";
$sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count);
// update loop values for next section
$count = $row['cnt'];
$letter = $row[$this->_subcat_field][0];
$first_section = $last_section = $row[$this->_subcat_field];
}
}
// end while()
// add last section aggregated
$section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}";
$sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count);
} else {
$sections = NULL;
}
return $sections;
}
开发者ID:morganney,项目名称:livewire,代码行数:32,代码来源:FrameTypeSubcategory.class.php
示例5: update
function update()
{
require_once 'Nouvelle.class.php';
require_once 'DAO.class.php';
// Cree un objet pour accueillir le contenu du RSS : un document XML
$doc = new DOMDocument();
//Telecharge le fichier XML dans $rss
$doc->load($this->url);
// Recupère la liste (DOMNodeList) de tous les elements de l'arbre 'title'
$nodeList = $doc->getElementsByTagName('title');
// Met à jour le titre dans l'objet
$this->titre = $nodeList->item(0)->textContent;
// Recupère la liste (DOMNodeList) de tous les elements de l'arbre 'title'
$nodeList = $doc->getElementsByTagName('pubDate');
// Met à jour la date dans l'objet
$this->date = $nodeList->item(0)->textContent;
$docNodeList = $doc->getElementsByTagName('item');
$dao = new DAO();
$dao->createRSS($this->url);
$id = $dao->returnIdFromURL($this->url);
$table = array();
$nomLocalImage = 1;
foreach ($docNodeList as $nouvelle) {
$tempNouvelle = new Nouvelle();
$tempNouvelle->update($nouvelle);
$tempNouvelle->downloadImage($nouvelle, $nomLocalImage);
$dao->createNouvelle($tempNouvelle, $id);
$nomLocalImage++;
$table[] = $tempNouvelle;
}
$this->nouvelles = $table;
}
开发者ID:Valdavin,项目名称:Model,代码行数:32,代码来源:RSS.class.php
示例6: dumpFounderData
/**
* Dumps the Founder data into a table
*
* @param int $CompanyID
*/
function dumpFounderData($CompanyID)
{
// include the data access class
include_once "DAO.php";
try {
// create a new data access object
$db = new DAO();
$sql = "EXEC dbo.GetFounderByCompanyID @CompanyID = " . $CompanyID;
// set the select statement
$db->setSQL($sql);
// execute the SQL
if ($db->execute()) {
// did we get some rows
if (sqlsrv_has_rows($db->getResultSet())) {
// output the table and the first row (column headers)
echo '<br>';
echo '<table class="sorted table-autosort:0 table-stripeclass:alternate">';
echo "<thead><tr>";
echo "<th class='table-sortable:default' width='100'>Name</th>";
echo "</tr></thead><tbody>";
// output the table rows
while ($row = sqlsrv_fetch_array($db->getResultSet(), SQLSRV_FETCH_ASSOC)) {
echo '<tr><td class="left" width="70"><a href="../Participant/History.php?wfID=' . $row['ID'] . '" target="_blank">' . $row['FounderName'] . '</a></td></tr>';
}
// finish the table
echo "</tbody></table>";
} else {
echo "<div class='err'>No data found.</div>";
}
}
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
echo "</br>";
}
开发者ID:zekuny,项目名称:RTPUI,代码行数:40,代码来源:DumpUtils.php
示例7: generatePartWiseReport
function generatePartWiseReport()
{
$type = $_REQUEST['type'];
$typeID = $_REQUEST['typeID'];
$dao = new DAO();
$debtorDetails = $dao->getReportDebtorDetails($type, $typeID);
include "../view/partyWiseGenReport.php";
}
开发者ID:htiwari1402,项目名称:ems,代码行数:8,代码来源:reportControl.php
示例8: createConnexion
/**
* Cette méthode permet de créer l'objet de connexion à une base de données
*
* @param string $pool Nom du pool de connection
* @param string $dbname Nom de la base de données
* @return DatabaseInterface
*/
static function createConnexion($pool, $dbname){
global $_CONST;
if (isset($dbname) && isset($_CONST["POOL"][$pool]["ABSTRACTION"])){
$driverOptions = array();
// Connexion
if($_CONST["POOL"][$pool]["ABSTRACTION"] == "PDO"){
// Classe d'abstraction DAO utilisant PDO
require_once("drivers/DAO.class.php");
// Gestion des options du driver PDO
if(isset($_CONST["POOL"][$pool]["FORCE_ENCODING"]) && $_CONST["POOL"][$pool]["FORCE_ENCODING"]!='') {
if(defined('PDO::MYSQL_ATTR_INIT_COMMAND')) {
$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES ".$_CONST["POOL"][$pool]["FORCE_ENCODING"];
$fix_force_encoding_bug = false;
} else {
$fix_force_encoding_bug = true;
}
}
if(isset($_CONST["POOL"][$pool]["PERSISTENT"]) && $_CONST["POOL"][$pool]["PERSISTENT"]===true) {
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}
// Ouverture d'une connexion avec PDO
$connexion = new DAO($_CONST["POOL"][$pool]["TYPE"], $dbname, $_CONST["POOL"][$pool]["USER"], $_CONST["POOL"][$pool]["PASS"], $_CONST["POOL"][$pool]["HOST"], $_CONST["POOL"][$pool]["PORT"], $driverOptions);
if(isset($fix_force_encoding_bug) && $fix_force_encoding_bug) {
$connexion->query("SET NAMES ".$_CONST["POOL"][$pool]["FORCE_ENCODING"]);
}
}elseif($_CONST["POOL"][$pool]["ABSTRACTION"] == "MYSQL"){
/** Classe d'abstraction MYSQL */
require_once("drivers/Mysqlux.class.php");
// Ouverture d'une connexion avec MYSQL
$connexion = new Mysqlux($_CONST["POOL"][$pool]["TYPE"],$dbname, $_CONST["POOL"][$pool]["USER"], $_CONST["POOL"][$pool]["PASS"], $_CONST["POOL"][$pool]["HOST"], $_CONST["POOL"][$pool]["PORT"], $driverOptions);
if(isset($_CONST["POOL"][$pool]["FORCE_ENCODING"]) && $_CONST["POOL"][$pool]["FORCE_ENCODING"]!='') {
$connexion->query("SET NAMES ".$_CONST["POOL"][$pool]["FORCE_ENCODING"]);
}
}else{
// Génération d'une DataBaseException
throw new DataBaseException("Erreur de connection '".$dbname."'","La couche d'abastraction '".$_CONST["POOL"][$pool]["ABSTRACTION"]."' n'est pas impléméntée !","");
}
$connexion->logType = isset($_CONST["POOL"][$pool]["LOG"]) ? $_CONST["POOL"][$pool]["LOG"] : null;
}else{
// Génération d'une DataBaseException
throw new DataBaseException("Erreur de connection '".$dbname."'","La base de données '".$dbname."' n'est pas configurée !","");
}
return $connexion;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:63,代码来源:DatabaseFactory.class.php
示例9: tryLogin
function tryLogin($un, $up)
{
$dao = new DAO();
$pass = $dao->fetchPassWord($un);
if ($pass != $up) {
return false;
} else {
return true;
}
}
开发者ID:a4501150,项目名称:CS425,代码行数:10,代码来源:loginProcess.php
示例10: getTareasAbiertasYUsuarios
function getTareasAbiertasYUsuarios($request_id)
{
$daoHandler = new DAO();
$sql = "SELECT \ts.step_name, u.user_name\r\n\t\t\t\tFROM \tef_task t\r\n\t\t\t\tleft join ef_step s ON s.step_id = t.task_step AND s.step_flow = t.task_flow\r\n\t\t\t\tleft join ef_user u ON u.user_id = t.task_assignedto\r\n\t\t\t\tWHERE \t?\r\n\t\t\t\tAND \tt.task_request = '.{$request_id}.' \r\n\t\t\t\tAND \t(t.task_status is null or t.task_status = 'new' or t.task_status = '')\r\n\t\t\t\tAND \tt.task_flow = '" . $_SESSION["user_flow"] . "' ";
$daoHandler->resetDAO();
$daoHandler->setQuery($sql);
$daoHandler->setParameter('i', 1);
$reportData = $daoHandler->executeQuery();
return $reportData;
}
开发者ID:elcuy,项目名称:Novopan,代码行数:10,代码来源:reportPlazosReclamo.php
示例11: executeIndex
/**
* Performs the logic for logging into the LWS backend CMS.
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->setLayout('login');
if ($request->isMethod('POST')) {
$dao = new DAO();
$pw = md5($dao->getEscapedSQLString(trim($request->getPostParameter('pw'))));
$email = $dao->getEscapedSQLString(trim(strtolower($request->getPostParameter('email'))));
$dao->query("\n \t\t\tSELECT be_user.*, role \n \t\t\tFROM be_user INNER JOIN be_role USING(role_id) \n \t\t\tWHERE email='{$email}' AND password='{$pw}' LIMIT 1\n \t\t");
if ($dao->queryOK()) {
$user = $dao->next();
$dao->query("SELECT last_login_ts FROM be_user WHERE email='{$user['email']}'");
// I know that there is a record in the DB with this email, so no need to check
$ts_row = $dao->next();
$last_login = is_null($ts_row['last_login_ts']) ? 'N/A' : date('M jS Y @ g:i A', $ts_row['last_login_ts']);
$dao->query("UPDATE be_user SET last_login_ts=UNIX_TIMESTAMP() WHERE email='{$user['email']}'");
$this->getUser()->setAttribute('be_user', array('first_name' => $user['first_name'], 'last_name' => $user['last_name'], 'full_name' => "{$user['first_name']} {$user['last_name']}", 'email' => $user['email'], 'role' => $user['role'], 'phone' => $user['phone'], 'phone_ext' => $user['phone_ext'], 'last_login' => $last_login, 'password' => $user['password']));
$this->getUser()->setAuthenticated(true);
$this->getUser()->addCredential($user['role']);
} else {
if ($this->getUser()->hasAttribute('be_user')) {
$this->getUser()->getAttributeHolder()->remove('be_user');
}
$this->getUser()->setAuthenticated(false);
$this->getUser()->setFlash('login_error', 'Invalid email and/or password!');
}
// allows users to go directly to requested page after login
$uri = $this->getContext()->getRouting()->getCurrentInternalUri(true);
$this->redirect($uri);
}
return sfView::SUCCESS;
}
开发者ID:morganney,项目名称:livewire,代码行数:36,代码来源:actions.class.php
示例12: getDuracionCerradosPorCliente
function getDuracionCerradosPorCliente($cliente, $filtros)
{
$daoHandler = new DAO();
$flow = $_SESSION["user_flow"];
$sql = "SELECT AVG(a.delay) delay\r\n\t\t\t\tFROM(\tSELECT SUM(IF (d.date_end is not null, \r\n\t\t\t\t\t\t\t\t\t\t(-1*TIME_TO_SEC(TIMEDIFF(d.date_start, d.date_end))), \r\n\t\t\t\t\t\t\t\t\t\t(-1*TIME_TO_SEC(TIMEDIFF(d.date_start, NOW())))\r\n\t\t\t\t\t\t\t\t\t\t)) delay\r\n\t\t\t\t\t\tFROM ef_date d\r\n\t\t\t\t\t\tLEFT JOIN ef_step s ON d.date_flow = s.step_flow AND d.date_step = s.step_id\r\n\t\t\t\t\t\tLEFT JOIN \tef_request r2 ON d.date_request = r2.request_id\r\n\t\t\t\t\t\tLEFT JOIN \trc_reclamo r1 ON r1.ef_id = r2.request_id\r\n\t\t\t\t\t\tLEFT JOIN \trc_clase c ON r1.reclamo_clase = c.id\t\r\n\t\t\t\t\t\tWHERE \t\t(r2.request_status = 'closed' OR r2.request_status = 'cancelled')\r\n\t\t\t\t\t\tAND \t\tr1.cliente_nombre = '" . $cliente . "'\r\n\t\t\t\t\t\tAND \t\tr2.request_flow = " . $flow . "\r\n\t\t\t\t\t\t" . $filtros . "\r\n\t\t\t\t\t\tGROUP BY \td.date_request\r\n\t\t\t\t\t) a\r\n\t\t\t\tWHERE ? ";
$daoHandler->resetDAO();
$daoHandler->setQuery($sql);
$daoHandler->setParameter('i', 1);
$reportData = $daoHandler->executeQuery();
return $reportData[0]["delay"];
}
开发者ID:elcuy,项目名称:Novopan,代码行数:11,代码来源:reportReclamosMontosCliente.php
示例13: getAllGroupes
/**
* Created by PhpStorm.
* User: arthurveys
* Date: 09/01/16
* Time: 18:12
*/
function getAllGroupes()
{
$request = 'select * from groupe';
$db = new DAO();
$listgroupe = array();
$result = $db->executeRequest($request);
foreach ($result as $value) {
$listgroupe[] = new groupe($value["groupeId"], $value["nom"], $value["description"], $value["imageHeader"]);
}
return $listgroupe;
}
开发者ID:memfou,项目名称:ProjetBooking,代码行数:17,代码来源:groupeController.php
示例14: validateStaff
function validateStaff()
{
$dao = new DAO();
$id = $dao->fetchStaffIDbySSN($_POST['ssn']);
if ($id != null) {
$_SESSION['STAFFID'] = $id;
echo 'WelCome, redirecting to management page...';
header("refresh:2; url=staff.php");
} else {
echo 'you are not a staff of our company.';
}
}
开发者ID:a4501150,项目名称:CS425,代码行数:12,代码来源:admin.php
示例15: restoreTables
/**
* Restore the given tables.
* @param $tables array
* @param $test PHPUnit_Framework_Assert
*/
public static function restoreTables($tables, $test)
{
$dao = new DAO();
foreach ($tables as $table) {
$sqls = array("TRUNCATE TABLE {$table}", "INSERT INTO {$table} SELECT * FROM backup_{$table}", "DROP TABLE backup_{$table}");
foreach ($sqls as $sql) {
if (!$dao->update($sql, false, true, false)) {
$test->fail("Error while restoring {$table}: offending SQL is '{$sql}'");
}
}
}
}
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:17,代码来源:PKPTestHelper.inc.php
示例16: OAIDAO
/**
* Constructor.
*/
function OAIDAO()
{
parent::DAO();
$this->archiveDao =& DAORegistry::getDAO('ArchiveDAO');
$this->recordDao =& DAORegistry::getDAO('RecordDAO');
PluginRegistry::loadCategory('schemas');
}
开发者ID:jalperin,项目名称:harvester,代码行数:10,代码来源:OAIDAO.inc.php
示例17: importVersion
function importVersion($filename)
{
import('lib.pkp.classes.rt.RTXMLParser');
$parser = new RTXMLParser();
$version =& $parser->parse($filename);
$this->dao->insertVersion($this->journalId, $version);
}
开发者ID:jmacgreg,项目名称:ojs,代码行数:7,代码来源:JournalRTAdmin.inc.php
示例18:
/**
*
*/
function __construct()
{
parent::__construct();
$this->setTableName('t_widget');
$this->setPrimaryKey('pk_i_id');
$this->setFields(array('pk_i_id', 's_description', 's_location', 'e_kind', 's_content'));
}
开发者ID:mylastof,项目名称:os-class,代码行数:10,代码来源:Widget.php
示例19: __construct
public function __construct($expired = false)
{
$this->city_areas = array();
$this->cities = array();
$this->regions = array();
$this->countries = array();
$this->categories = array();
$this->conditions = array();
$this->fields = array();
$this->tables[] = sprintf('%st_item_description as d, %st_category_description as cd', DB_TABLE_PREFIX, DB_TABLE_PREFIX);
$this->order();
$this->limit();
$this->results_per_page = 10;
if (!$expired) {
$this->addTable(sprintf('%st_category', DB_TABLE_PREFIX));
$this->addConditions(sprintf("%st_item.b_active = 1 ", DB_TABLE_PREFIX));
$this->addConditions(sprintf("%st_item.b_enabled = 1 ", DB_TABLE_PREFIX));
$this->addConditions(sprintf("%st_item.b_spam = 0", DB_TABLE_PREFIX));
$this->addConditions(sprintf(" (%st_item.b_premium = 1 || %st_category.i_expiration_days = 0 ||TIMESTAMPDIFF(DAY,%st_item.dt_pub_date,'%s') < %st_category.i_expiration_days) ", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, date('Y-m-d H:i:s'), DB_TABLE_PREFIX));
$this->addConditions(sprintf("%st_category.b_enabled = 1", DB_TABLE_PREFIX));
$this->addConditions(sprintf("%st_category.pk_i_id = %st_item.fk_i_category_id", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
}
$this->total_results = null;
parent::__construct();
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:25,代码来源:Search.php
示例20:
/**
* Set data related to t_currency table
*/
function __construct()
{
parent::__construct();
$this->setTableName('t_currency');
$this->setPrimaryKey('pk_c_code');
$this->setFields(array('pk_c_code', 's_name', 's_description', 'b_enabled'));
}
开发者ID:oanav,项目名称:closetshare,代码行数:10,代码来源:Currency.php
注:本文中的DAO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论