本文整理汇总了PHP中TCriteria::add方法的典型用法代码示例。如果您正苦于以下问题:PHP TCriteria::add方法的具体用法?PHP TCriteria::add怎么用?PHP TCriteria::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCriteria
的用法示例。
在下文中一共展示了TCriteria::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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();
}
示例2: 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();
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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;
}
}
示例6: listBetween
public static function listBetween($from, $to)
{
TTransaction::open('samples');
$response = array();
$criteria = new TCriteria();
$criteria->add(new TFilter('id', '>', $from));
$criteria->add(new TFilter('id', '<', $to));
$all = Customer::getObjects($criteria);
foreach ($all as $customer) {
$response[] = $customer->toArray();
}
TTransaction::close();
return $response;
}
示例7: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$criteria = new TCriteria();
$criteria->add(new TFilter('address', 'like', 'Rua Porto%'));
$criteria->add(new TFilter('gender', '=', 'M'));
$repository = new TRepository('Customer');
$repository->delete($criteria);
new TMessage('info', 'Records Deleted');
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例8: 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);
}
示例9: 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);
}
示例10: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$criteria = new TCriteria();
$criteria->add(new TFilter('name', 'like', 'Rafael%'), TExpression::OR_OPERATOR);
$criteria->add(new TFilter('name', 'like', 'Ana%'), TExpression::OR_OPERATOR);
$repository = new TRepository('Customer');
$count = $repository->count($criteria);
new TMessage('info', "Total of found customers: {$count} <br>\n");
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例11: 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());
}
}
示例12: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$criteria = new TCriteria();
$criteria->add(new TFilter('gender', '=', 'M'));
$criteria->add(new TFilter('name', 'like', 'A%'));
$customers = Customer::getObjects($criteria);
foreach ($customers as $customer) {
echo $customer->id . ' - ' . $customer->name . '<br>';
}
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例13: onGenderChange
/**
* Action to be executed when the user changes the gender or status
* @param $param Action parameters
*/
public static function onGenderChange($param)
{
TTransaction::open('samples');
$repo = new TRepository('Customer');
$criteria = new TCriteria();
$criteria->add(new TFilter('gender', 'IN', isset($param['check_gender']) ? $param['check_gender'] : array()));
if ($param['combo_status']) {
$criteria->add(new TFilter('status', '=', $param['combo_status']));
}
$customers = $repo->load($criteria);
TTransaction::close();
$options = array();
foreach ($customers as $customer) {
$options[$customer->id] = $customer->name;
}
TCombo::reload('form_dynamic_filter', 'customers', $options);
}
示例14: 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);
}
示例15: 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);
}