本文整理汇总了PHP中TRepository类的典型用法代码示例。如果您正苦于以下问题:PHP TRepository类的具体用法?PHP TRepository怎么用?PHP TRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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];
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}