本文整理汇总了PHP中TCriteria类的典型用法代码示例。如果您正苦于以下问题:PHP TCriteria类的具体用法?PHP TCriteria怎么用?PHP TCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TCriteria类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: listar
public function listar($param)
{
try {
TTransaction::open('sample');
$criteria = new TCriteria();
$criteria->add(new TFilter('categoria_id', '=', $param['id']));
$produtos = Produtos::getObjects($criteria);
TTransaction::close();
//cria um array vario
$replace_detail = array();
if ($produtos) {
// iterate products
foreach ($produtos as $p) {
// adicio os itens no array
// a função toArray(), transforma o objeto em um array
// passando assim para a $variavel
$replace_detail[] = $p->toArray();
}
}
// ativa a sessão e substitui as variaveis
//o parametro true quer dizer que é um loop
$this->produtos->enableSection('produtos', $replace_detail, TRUE);
} catch (Exception $e) {
new Message('error', $e->getMessage());
}
}
开发者ID:jhonleandres,项目名称:pecommerce,代码行数:26,代码来源:Home.class.php
示例2: 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
示例3: __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
示例4: logar
public static function logar($email, $senha)
{
try {
TTransaction::open('sample');
$criteria = new TCriteria();
$filter = new TFilter('email', '=', $email);
$filter2 = new TFilter('senha', '=', $senha);
$criteria->add($filter);
$criteria->add($filter2);
$user = Clientes::getObjects($criteria);
if ($user) {
TSession::setValue('cliente_logado', true);
// cria a sessão para mostrar que o usuario esta no sistema
TSession::setValue('cliente', $user);
// guarda os dados do cliente
foreach ($user as $c) {
TSession::setValue('id', $c->id);
// guarda os dados do cliente
}
TCoreApplication::executeMethod('Home');
} else {
new TMessage('error', 'Usuario ou Senha invalidos');
}
TTransaction::close();
} catch (Exception $e) {
echo $e->getMessage();
}
}
开发者ID:jhonleandres,项目名称:pecommerce,代码行数:28,代码来源:Clientes.class.php
示例5: 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
示例6: getSocial
public function getSocial()
{
//RECUPERA CONEXAO BANCO DE DADOS
TTransaction::open('my_bd_site');
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->setProperty('order', 'nome ASC');
// instancia a instrução de SELECT
$sql = new TSqlSelect();
$sql->addColumn('*');
$sql->setEntity('social');
// atribui o critério passado como parâmetro
$sql->setCriteria($criteria);
// obtém transação ativa
if ($conn = TTransaction::get()) {
// registra mensagem de log
TTransaction::log($sql->getInstruction());
// executa a consulta no banco de dados
$result = $conn->Query($sql->getInstruction());
$this->results = array();
if ($result) {
// percorre os resultados da consulta, retornando um objeto
while ($row = $result->fetchObject()) {
// armazena no array $this->results;
$this->results[] = $row;
}
}
}
TTransaction::close();
return $this->results;
}
开发者ID:rodu-pereira,项目名称:RogerioPereira,代码行数:31,代码来源:controladorSocial.class.php
示例7: __construct
/**
* Class constructor
* Creates the page
*/
function __construct()
{
parent::__construct();
// create the form using TQuickForm class
$this->form = new TQuickForm('form_seek_sample');
$this->form->setFormTitle('Seek button');
$this->form->class = 'tform';
// create the form fields
$city_id1 = new TSeekButton('city_id1');
$city_name1 = new TEntry('city_name1');
$criteria = new TCriteria();
$criteria->add(new TFilter('id', '>', 1));
$criteria->add(new TFilter('id', '<', 5));
$criteria->setProperty('order', 'name');
// define the action for city_id1
$obj = new TestCitySeek();
$action = new TAction(array($obj, 'onReload'));
$city_id1->setAction($action);
$city_id1->setSize(100);
$city_name1->setEditable(FALSE);
$this->form->addQuickFields('Manual SeekButton', array($city_id1, $city_name1));
$this->form->addQuickAction('Save', new TAction(array($this, 'onSave')), 'fa:floppy-o');
// wrap the page content using vertical box
$vbox = new TVBox();
$vbox->add($this->form);
parent::add($vbox);
}
开发者ID:jhonleandres,项目名称:Atividades,代码行数:31,代码来源:FormSeekButtonView.class.php
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: getEmails
public function getEmails()
{
$this->collectionEmails = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->setProperty('order', 'email');
$this->repository->addColumn('email');
$this->repository->addEntity('emails');
$this->collectionEmails = $this->repository->load($criteria);
return $this->collectionEmails;
}
开发者ID:GroupSofter,项目名称:SiteZerado,代码行数:12,代码来源:controladorEmails.php
示例17: getTelefones
public function getTelefones()
{
$this->collectionTelefones = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->setProperty('order', 'codigo');
$this->repository->addColumn('telefone');
$this->repository->addEntity('telefones');
$this->collectionTelefones = $this->repository->load($criteria);
return $this->collectionTelefones;
}
开发者ID:GroupSofter,项目名称:SiteZerado,代码行数:12,代码来源:controladorTelefones.php
示例18: getImoveis
/**
* Método getImoveis
* Retorna os Imóveis
*
* @access public
* @return TRepository Coleção de Imóveis
*/
public function getImoveis()
{
$this->collectionImoveis = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->setProperty('order', 'endereco');
$this->repository->addColumn('*');
$this->repository->addEntity('imoveis');
$this->collectionImoveis = $this->repository->load($criteria);
return $this->collectionImoveis;
}
开发者ID:GroupSofter,项目名称:ImoveisVieiraERodrigues,代码行数:19,代码来源:controladorImoveis.php
示例19: 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
示例20: 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
注:本文中的TCriteria类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论