本文整理汇总了PHP中TCriteria::setProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP TCriteria::setProperty方法的具体用法?PHP TCriteria::setProperty怎么用?PHP TCriteria::setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCriteria
的用法示例。
在下文中一共展示了TCriteria::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TQuickForm
/**
* 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);
}
示例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();
}
}
示例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();
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
示例7: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
// abre uma transação
$criteria = new TCriteria();
$criteria->setProperty('limit', 10);
$criteria->setProperty('offset', 20);
$criteria->setProperty('order', 'id');
$repository = new TRepository('Customer');
$customers = $repository->load($criteria);
foreach ($customers as $customer) {
echo $customer->id . ' - ' . $customer->name . '<br>';
}
TTransaction::close();
// fecha a transação.
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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 Product
$repository = new TRepository('Product');
$limit = 10;
// creates a criteria
$criteria = new TCriteria();
$criteria->setProperties($param);
// order, offset
$criteria->setProperty('limit', $limit);
// update the save action parameters to pass
// offset, limit, page and other info to the save action
$this->saveAction->setParameters($param);
// important!
// load the objects according to criteria
$objects = $repository->load($criteria);
$this->datagrid->clear();
if ($objects) {
// iterate the collection of active records
foreach ($objects as $object) {
$object->sale_price_edit = new TEntry('sale_price_' . $object->id);
$object->sale_price_edit->setNumericMask(1, '.', ',');
$object->sale_price_edit->setSize(120);
$object->sale_price_edit->setValue($object->sale_price);
$this->form->addField($object->sale_price_edit);
// important!
// add the object inside the datagrid
$this->datagrid->addItem($object);
}
}
// reset the criteria for record count
$criteria->resetProperties();
$count = $repository->count($criteria);
$this->pageNavigation->setCount($count);
// count of records
$this->pageNavigation->setProperties($param);
// order, page
$this->pageNavigation->setLimit($limit);
// limit
// 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();
}
}
示例11: getUsuarios
/**
* Método getUsuarios
* Obtem todos os usuarios
*
* @access public
* @return array Coleção de Usuário
*/
public function getUsuarios()
{
$this->collectionUsuario = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
//$criteria->addFilter('situacao', '=', $situacao);
$criteria->setProperty('order', 'nome');
$this->repository = new TRepository();
$this->repository->addColumn('*');
$this->repository->addEntity('usuarios');
$this->collectionUsuario = $this->repository->load($criteria);
return $this->collectionUsuario;
}
示例12: getSituacoes
/**
* Método getLocalizacoes
* Retorna as localizações
*
* @access public
* @return TRepository Coleção de Localizações
*/
public function getSituacoes()
{
$this->collectionSituacao = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->setProperty('order', 'situacao');
$this->repository->addColumn('codigo');
$this->repository->addColumn('situacao');
$this->repository->addEntity('situacaoimoveis');
$this->collectionSituacao = $this->repository->load($criteria);
return $this->collectionSituacao;
}
示例13: getCategorias
/**
* Método getLocalizacoes
* Retorna as localizações
*
* @access public
* @return TRepository Coleção de Localizações
*/
public function getCategorias()
{
$this->collectionCategoria = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->setProperty('order', 'categoria');
$this->repository->addColumn('codigo');
$this->repository->addColumn('categoria');
$this->repository->addEntity('categoriaimoveis');
$this->collectionCategoria = $this->repository->load($criteria);
return $this->collectionCategoria;
}
示例14: getGaleriaImovel
/**
* Método getGaleriaImovel
* Obtém a galeria de fotos do imóvel de acordo com o código do imóvel
*
* @access public
* @param int $codigo Código do Imóvel
* @return TRepository Coleção de imagens do Imóvel
*/
public function getGaleriaImovel($codigo)
{
$this->collectionGaleria = NULL;
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->addFilter('ativo', '=', 1);
$criteria->addFilter('codigoImovel', '=', $codigo);
$criteria->setProperty('order', 'ordem');
$this->repository->addColumn('imagem');
$this->repository->addColumn('titulo');
$this->repository->addColumn('descricao');
$this->repository->addEntity('galeria');
$this->collectionGaleria = $this->repository->load($criteria);
return $this->collectionGaleria;
}
示例15: getCollectionOrcamentosProdutos
function getCollectionOrcamentosProdutos($codigo)
{
$this->setCollectionOrcamentosProdutos(NULL);
//RECUPERA CONEXAO BANCO DE DADOS
TTransaction::open('my_bd_site');
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->add(new TFilter('codigoOrcamento', '=', $codigo));
$criteria->setProperty('order', 'nome');
$this->repository = new TRepository();
$this->repository->addColumn('*');
$this->repository->addEntity('orcamentoproduto');
$this->setCollectionOrcamentosProdutos($this->repository->load($criteria));
TTransaction::close();
return $this->collectionOrcamentosProdutos;
}