本文整理汇总了PHP中TRepository类的典型用法代码示例。如果您正苦于以下问题:PHP TRepository类的具体用法?PHP TRepository怎么用?PHP TRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onReload
/**
* method onReload()
* Load the datagrid with the database objects
*/
function onReload($param = NULL)
{
try {
// open a transaction with database 'samples'
TTransaction::open('samples');
// creates a repository for Category
$repository = new TRepository('Category');
// creates a criteria, ordered by id
$criteria = new TCriteria();
$order = isset($param['order']) ? $param['order'] : 'id';
$criteria->setProperty('order', $order);
// load the objects according to criteria
$categories = $repository->load($criteria);
$this->datagrid->clear();
if ($categories) {
// iterate the collection of active records
foreach ($categories as $category) {
// add the object inside the datagrid
$this->datagrid->addItem($category);
}
}
// close the transaction
TTransaction::close();
$this->loaded = true;
} catch (Exception $e) {
// shows the exception error message
new TMessage('error', '<b>Error</b> ' . $e->getMessage());
// undo all pending operations
TTransaction::rollback();
}
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:35,代码来源:CompleteFormDataGridView.class.php
示例2: removeListOfMaterialPermanente
public function removeListOfMaterialPermanente()
{
$criteria = new TCriteria();
$criteria->add(new TFilter('tipo_material_permanente_id', '=', $this->id));
$repository = new TRepository('MaterialPermanente');
return $repository->delete($criteria);
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:7,代码来源:TipoMaterialPermanente.class.php
示例3: onReload
function onReload($param = NULL)
{
$offset = $param['offset'];
//$order = $param['order'];
$limit = 10;
// inicia transação com o banco 'pg_livro'
TTransaction::open('pg_livro');
// instancia um repositório para Alunos
$repository = new TRepository('Pessoa');
// retorna todos objetos que satisfazem o critério
$criteria = new TCriteria();
$count = $repository->count($criteria);
$criteria->setProperty('limit', $limit);
$criteria->setProperty('offset', $offset);
$pessoas = $repository->load($criteria);
$this->navbar->setPageSize($limit);
$this->navbar->setCurrentPage($param['page']);
$this->navbar->setTotalRecords($count);
$this->datagrid->clear();
if ($pessoas) {
foreach ($pessoas as $pessoa) {
// adiciona o objeto na DataGrid
$this->datagrid->addItem($pessoa);
}
}
// finaliza a transação
TTransaction::close();
$this->loaded = true;
}
开发者ID:CodeBooks,项目名称:php-programando-com-orientacao-a-objetos,代码行数:29,代码来源:list6.php
示例4: listForCategory
public static function listForCategory($category_id)
{
$criteria = new TCriteria();
$criteria->add(new TFilter('category_id', '=', $category_id));
$repos = new TRepository('Post');
return $repos->load($criteria);
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:7,代码来源:Post.class.php
示例5: __construct
/**
* Class Constructor
* @param $name widget's name
* @param $database database name
* @param $model model class name
* @param $key table field to be used as key in the combo
* @param $value table field to be listed in the combo
* @param $ordercolumn column to order the fields (optional)
* @param array $filter TFilter (optional) By Alexandre
* @param array $expresione TExpression (opcional) by Alexandre
*/
public function __construct($name, $database, $model, $key, $value, $ordercolumn = NULL, $filter = NULL, $expression = NULL)
{
new TSession();
// executes the parent class constructor
parent::__construct($name);
// carrega objetos do banco de dados
TTransaction::open($database);
// instancia um repositório de Estado
$repository = new TRepository($model);
$criteria = new TCriteria();
$criteria->setProperty('order', isset($ordercolumn) ? $ordercolumn : $key);
if ($filter) {
foreach ($filter as $fil) {
if ($expression) {
foreach ($expression as $ex) {
$criteria->add($fil, $ex);
}
} else {
$criteria->add($fil);
}
}
}
// carrega todos objetos
$collection = $repository->load($criteria);
// adiciona objetos na combo
if ($collection) {
$items = array();
foreach ($collection as $object) {
$items[$object->{$key}] = $object->{$value};
}
parent::addItems($items);
}
TTransaction::close();
}
开发者ID:jhonleandres,项目名称:pecommerce,代码行数:45,代码来源:TDBFCombo.class.php
示例6: delete
public function delete($id = NULL)
{
$id = isset($id) ? $id : $this->{'id'};
$criteria = new TCriteria();
$criteria->add(new TFilter('project_id', '=', $id));
$repository = new TRepository('Backlog');
$repository->delete($criteria);
parent::delete($id);
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:9,代码来源:Project.class.php
示例7: delete
public function delete($id = NULL)
{
$id = isset($id) ? $id : $this->logra_id;
$repository = new TRepository('LogradouroBairro');
$criteria = new TCriteria();
$criteria->add(new TFilter('tb_logradouros_logra_id', '=', $id));
$repository->delete($criteria);
// delete the object itself
parent::delete($id);
}
开发者ID:eduardojsouza,项目名称:liger,代码行数:10,代码来源:Logradouro.class.php
示例8: newFromLogin
/**
* Retorna uma instância de usuário a partir do login
* @param $login Login do usuário
*/
public static function newFromLogin($login)
{
$repos = new TRepository('User');
$criteria = new TCriteria();
$criteria->add(new TFilter('login', '=', $login));
$objects = $repos->load($criteria);
if (isset($objects[0])) {
return $objects[0];
}
}
开发者ID:jhonleandres,项目名称:crmbf,代码行数:14,代码来源:User.class.php
示例9: delete
/**
* Delete an Active Record object from the database
* @param [$id] The Object ID
* @exception Exception if there's no active transaction opened
*/
public function delete($id = NULL)
{
$id = isset($id) ? $id : $this->{'id'};
$note_rep = new TRepository('Note');
$criteria = new TCriteria();
$criteria->add(new TFilter('id_issue', '=', $id));
$note_rep->delete($criteria);
// delete the object itself
parent::delete($id);
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:15,代码来源:Issue.class.php
示例10: newFromBarcode
/**
* Returns the Item from its barcode
*/
public static function newFromBarcode($barcode)
{
$rep = new TRepository('Item');
$criteria = new TCriteria();
$criteria->add(new TFilter('barcode', '=', $barcode));
$objects = $rep->load($criteria);
if ($objects) {
$item = $objects[0];
return $item;
}
}
开发者ID:jhonleandres,项目名称:crmbf,代码行数:14,代码来源:Item.class.php
示例11: delete
/**
* Delete the object and its aggregates
* @param $id object ID
*/
public function delete($id = NULL)
{
// delete the related System_groupSystem_program objects
$id = isset($id) ? $id : $this->id;
$repository = new TRepository('SystemGroupProgram');
$criteria = new TCriteria();
$criteria->add(new TFilter('system_group_id', '=', $id));
$repository->delete($criteria);
// delete the object itself
parent::delete($id);
}
开发者ID:edurbs,项目名称:sobcontrole,代码行数:15,代码来源:SystemGroup.class.php
示例12: get_inscricoes
function get_inscricoes()
{
// cria um critério de seleção
$criteria = new TCriteria();
// filtra por codigo do aluno
$criteria->add(new TFilter('ref_aluno', '=', $this->id));
// instancia repositório de Inscrições
$repository = new TRepository('Inscricao');
// retorna todas inscrições que satisfazem o critério
return $repository->load($criteria);
}
开发者ID:CodeBooks,项目名称:php-programando-com-orientacao-a-objetos,代码行数:11,代码来源:lazy.php
示例13: getFromBarcode
/**
* Get the last loan (not arrived) from a barcode
*/
public static function getFromBarcode($barcode)
{
$rep = new TRepository('Loan');
$criteria = new TCriteria();
$criteria->add(new TFilter('barcode', '=', $barcode));
$criteria->add(new TFilter('arrive_date', 'is', NULL));
$objects = $rep->load($criteria);
if ($objects) {
$loan = $objects[0];
return $loan;
}
}
开发者ID:jhonleandres,项目名称:crmbf,代码行数:15,代码来源:Loan.class.php
示例14: getTicketsSolicitante
public function getTicketsSolicitante($solicitante_id)
{
$criteria = new TCriteria();
$criteria->add(new TFilter('solicitante_id', '=', $solicitante_id));
$repository = new TRepository('Ticket');
$tickets = $repository->load($criteria);
$retorno[] = '0';
foreach ($tickets as $row) {
$retorno[] = $row->id;
}
return $retorno;
}
开发者ID:jhonleandres,项目名称:Atividades,代码行数:12,代码来源:Ticket.class.php
示例15: delete
public function delete($id = NULL)
{
//sobrescrito!
$id = isset($id) ? $id : $this->id;
$repository = new TRepository('TurmaDisciplina');
$criteria = new TCriteria();
$criteria->add(new TFilter('turma_id', '=', $id));
$repository->delete($criteria);
$repository = new TRepository('AlunoTurma');
$repository->delete($criteria);
parent::delete($id);
}
开发者ID:joaopaulo11jp,项目名称:educaproject,代码行数:12,代码来源:Turma.class.php
示例16: getWeekEvents
/**
* Return the week events
* @return Event[]
*/
public static function getWeekEvents()
{
$first_week_day = self::getFirstWeekDay();
$last_week_day = self::getLastWeekDay();
// load objects
$repo = new TRepository('Event');
$criteria = new TCriteria();
$criteria->add(new TFilter('event_date', '>=', $first_week_day));
$criteria->add(new TFilter('event_date', '<=', $last_week_day));
$criteria->setProperty('order', 'event_date, start_hour');
return $repo->load($criteria);
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:16,代码来源:Event.class.php
示例17: get_itens
public function get_itens()
{
// instancia um repositório de Item
$repositorio = new TRepository('Item');
// define o critério de seleção
$criterio = new TCriteria();
$criterio->add(new TFilter('id_venda', '=', $this->id));
// carrega a coleção de itens
$this->itens = $repositorio->load($criterio);
// retorna os itens
return $this->itens;
}
开发者ID:ricardohenriq,项目名称:learn-php,代码行数:12,代码来源:Venda.class.php
示例18: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$repository = new TRepository('Customer');
$repository->where('address', 'like', 'Rua Porto%')->where('gender', '=', 'M')->delete();
new TMessage('info', 'Records Deleted');
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:13,代码来源:CollectionSimpleDelete.php
示例19: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$repository = new TRepository('Customer');
$count = $repository->where('name', 'like', 'Rafael%', TExpression::OR_OPERATOR)->where('name', 'like', 'Ana%', TExpression::OR_OPERATOR)->count();
new TMessage('info', "Total of found customers: {$count} <br>\n");
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:13,代码来源:CollectionSimpleCount.php
示例20: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$repository = new TRepository('Customer');
$customers = $repository->where('gender', '=', 'M')->where('name', 'like', 'A%')->load();
foreach ($customers as $customer) {
echo $customer->id . ' - ' . $customer->name . '<br>';
}
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:15,代码来源:CollectionSimpleLoad.php
注:本文中的TRepository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论