本文整理汇总了PHP中Projects::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::find方法的具体用法?PHP Projects::find怎么用?PHP Projects::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projects
的用法示例。
在下文中一共展示了Projects::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
<?php
include 'config.php';
#include 'A/Db/Sqlite.php';
#include 'A/Db/Tabledatagateway.php';
class Projects extends A_Db_Tabledatagateway
{
}
$db = new A_Db_Sqlite3($ConfigArray['DBDSN_SQLITE']);
$db->connect();
if ($db->isError()) {
die('ERROR: ' . $db->getMessage());
}
$project = new Projects($db);
$rows = $project->find(2);
dump($project->sql);
dump($rows);
$rows = $project->find('clients_id=', 1);
dump($project->sql);
dump($rows);
示例2: findByUserAndCompany
/**
* Return projects visible for $user that have $company for client
*
* @param User $user
* @param Company $company
* @param boolean $all_for_admins_and_pms
* @return array
*/
function findByUserAndCompany($user, $company, $all_for_admins_and_pms = false)
{
if (!instance_of($user, 'User')) {
return null;
}
// if
if (instance_of($company, 'Company')) {
$company_id = $company->getIsOwner() ? 0 : $company->getId();
} else {
return null;
}
// if
// Admin or project manager
if ($all_for_admins_and_pms && ($user->isProjectManager() || $user->isAdministrator())) {
return Projects::find(array('conditions' => array('company_id = ?', $company_id), 'order' => 'name'));
}
// if
// Clients and other members
$rows = db_execute_all('SELECT project_id FROM ' . TABLE_PREFIX . 'project_users WHERE user_id = ?', $user->getId());
if (is_foreachable($rows)) {
$project_ids = array();
foreach ($rows as $row) {
$project_ids[] = (int) $row['project_id'];
}
// if
} else {
return null;
}
// if
return Projects::find(array('conditions' => array('id IN (?) AND company_id = ?', $project_ids, $company_id), 'order' => 'name'));
}
示例3: getOwnProjects
/**
* Return array of active projects that this user created
*
* @access public
* @param void
* @return array
*/
function getOwnProjects()
{
if (is_null($this->own_projects)) {
$this->own_projects = Projects::find('`created_by_id` = ' . $this->getId());
}
// if
return $this->own_projects;
}
示例4: die
<?php
ini_set('date.timezone', 'America/Los_Angeles');
include 'config.php';
// need to set the database type for PDO factory
$ConfigArray['DBDSN']['phptype'] = 'mysql';
//include 'A/Db/Pdo.php';
include 'A/Db/Tabledatagateway.php';
class Projects extends A_Db_Tabledatagateway
{
}
$db = new A_Db_Pdo($ConfigArray['DBDSN']);
$db->connect();
if ($db->isError()) {
die('ERROR: ' . $db->getMessage());
}
$project = new Projects($db, 'users');
$rows = $project->find(1);
dump($project->sql);
dump($rows);
// Get the current row
dump($rows->current());
// Get all rows
$all = $rows->fetchAll();
dump($all);
// Update some data
$data = array('lastname' => 'testert');
$updated = $project->update($data, 'id = 1');
//dump($updated);
$rows = $project->find(1);
dump($rows->current());
示例5: getFullname
parent::__construct($db);
}
public function getFullname()
{
return $this->data['title'] . ', ' . $this->data['name'] . ' ' . $this->data['surname'];
}
}
$db = new A_Db_MySQL($config['db']);
$db->connect();
if ($db->isError()) {
die('ERROR: ' . $db->getMessage());
}
Projects::setDb($db);
$project = new Projects();
#$project->find("id='3'");
$project->find("client_id='2'");
#$project->set('title', 'Mr');
#$project->set('name', 'Frodo');
#$project->set('surname', 'Baggins');
#$project->set('email', 'frodo@the-shire.com');
//User::getInstance();
echo 'table=' . $project->getTable() . '<br/>';
dump($project->toArray());
/*
$project->insert();
$project->unsetAttr();
$rs = $project->getAll();
foreach ( $rs as $result ) {
echo $result->get('fullname') ."\n";
// OR
echo $result->fullname ."\n";
示例6: die
<?php
include 'config.php';
#include 'A/Db/Sqlite.php';
#include 'A/Db/Activerecord.php';
class Projects extends A_Db_Activerecord
{
}
$db = new A_Db_Sqlite3($ConfigArray['DBDSN_SQLITE']);
$db->connect();
if ($db->isError()) {
die('ERROR: ' . $db->getMessage());
}
$project = new Projects($db);
$project->find(2);
dump($project->sql);
dump($project->toArray());