Iam trying to use addclause where in (1,2,4,5,6...) in crud controller - where-clause

Iam trying to use addclause, but instead of use a filter in my where that get only one value, I need to use a list of values, like this
$this->crud->addClause('where', 'customer_id', 'in', [1,3,5,6,7]);
Its possible? how to make it happen?
thanks in advance.

Related

Inputs for searching (form:select)

Is it possible to use Search like this in order to refer a specific {name} provided by an input? I want to create an input form like: <form:select items="${cars}" path="car" itemLabel="type" itemValue="id"/>. This is my controller mapping: #GetMapping("/searchby/{name}"). Thanks!
it should be possible but not recommended, from what i know using url parameters (domain.com/page?value=theValue) is better

How can we make an Item in socialengine?

I know how to get an item of the particular table. Like for user we can have
$userItem = Engine_Api::_()->getItem("user", $userId);
or for a custom table
$customItem = Engine_Api::_()->getItem("custom", $customeId);
I want to know the code or method how can I make my $customItem to work the same way as $userItem works for users table. So that I can get data or manipulate the data of custom table
Thanks for your help. :-)
You can achieve that by creating a model. Check how it's done in /application/modules/User/Model. There is User.php file that declares User_Model_User and methods available for User such as getTitle, get Href etc.
You may use similar approach for your custom item. You will also need to create a file similar to /application/modules/User/Model/DbTable/User.php to declare table for your custom items.

Create custom advance search filter in CGridView in YII

I have a model which contains emails with some other fields.
I want a custom filter in Yii CGridView's advance search which when applied, lists only Invalid Email IDs (using regular expression '^[A-Z0-9._%-]+#[A-Z0-9.-]+\.[A-Z]{2,4}$')
Note: I dont want to add any column in CGridView
I hope to help you out,
you will need several things
the line for filtering in the column of your choice...(i recommend you create a new attribute for this, ask me in comments if you want to know more why.) this goes in the cgridview of course:
'filter'=>CHtml::activeCheckBox($model, $attributeEmail)
the condition in your search of function that brings up the model.
Supposing you have a criteria inside your search in your model wich help you with your filtering what you need is ...
if($this->EMAIL == TRUE)
{
$criteria->addCondition("\"t\".\"EMAIL\" email NOT LIKE '%_#__%.__%'");
}
Why not to use regex and make a KISS approach ? better read this first...
Sql script to find invalid email addresses
I'd be glad to hear your comments it is interesting question for yii dev's btw

Is it possible to compare 2 dimensions in a Google Analytics query filter?

I'm just starting out with the Google Analytics API and am wondering if it's possible to compare two dimensions via an operand in the filters I pass in the query. And by wondering I mean I've tried it, but have had no success.
Specifically I'm trying to compare 2 custom variable values. One holds the user who created a post (customVarValue3), the other the user who is viewing the post (customVarValue5). I want to get the pageviews only for the visitors who are not also the creator. The filter looks like this (without urlencoding applied):
ga:customVarValue3!=ga:customVarValue5
The full query (url encoded) looks like this:
https://www.google.com/analytics/feeds/data?ids=ga%3Axxxxxx&dimensions=ga%3AcustomVarValue1%2Cga%3AcustomVarValue2%2Cga%3AcustomVarValue3&metrics=ga%3Apageviews&filters=ga%3AcustomVarValue3!%3Dga%3AcustomVarValue5&sort=-ga%3Apageviews&start-date=2012-02-09&end-date=2012-02-23&max-results=50
However, it returns the same results (and I know there are results where ga:customVarValue3 == ga:customVarValue5).
Probably it isn't possible, but I just wanted to see if anyone knew how to achieve this or has a workaround or something.
No, it is not possible using the GAv3 API in its present state. You can, however, get all the results by using the specified two custom variables as the dimensions for a report, and programmatically filter out the unnecessary results.
Some simple construct like
for(var item in collatedResultsListwithDimensions) {
for(var row in item.rows) {
if(row[0]!=row[1])
newResultRows.push(row);
}
}
Now your newResultRows will have those rows where row[1]!=row[0] assuming the two custom variables you mentioned are the first two dimensions.

How to enable dojox.data.JsonRestStore access struts2's action to retrieve data? I mean how to configure 'target' or others

I tend to use dojox.data.JsonRestStore as my grid's store, but I am always failed to access struts2 action, I am unfamiliar in REST, is it only can be used in servlet rather than struts2, etc.
Currently, My project is using struts2 + spring as backend skill and dojo as front-side skill, have you any ways for me to make dojox.data.JsonRestStore access a structs2 action class?
Thanks in advance.
to get the data, all you need is an HTTP GET that returns an array of JSON objects. The return value from the action must be a string with something like:
[
{
"penUser":"Micha Roon",
"submitTime":"12.03 13:20",
"state":"Eingang",
"FormNumber":"001001"
},
{
"penUser":"Micha Roon",
"submitTime":"12.03 13:20",
"state":"Eingang",
"FormNumber":"001001"
}
]
If you want to be able to update objects you have to have a method that reacts to PUT with the same URL as the one you used for GET and if you need to delete, DELETE will be used. The important part is that it must be the same URL.
In order to have JsonRestStore pass the ID in a GET parameter instead of appending it to the URL, you could specify the URL like so:
target:"services/jsonrest/formstore?formId="
When you call yourStore.get("123") the request will try to get http://yourserver:port/AppContext/services/jsonrest/formstore?formId=123
REST is nothing more than a convention.
You can use a RESTFull API like jersey.java.net in order to make your life easier and your URL more RESTFull.