OFFSET error with symfony project and MS SQL backend - sql-server

I am building a symfony 1.4 project with an MS SQL backend. I built a backend using the admin generator but when I attempt to load an admin module I am getting this error:
OFFSET cannot be used in MS SQL without ORDER BY due to emulation reasons
How do I resolve this?
The symfony application is running on Debian squeeze under Apache 2.2.

In my case the error disappeared by setting the pager size explicit:
list:
max_per_page: 20
Edit: That wasn't the solution, I just had some sorting paramters in the session which solved the problem temporarily.
The new solution is to define a defalut sorting. I did it by overriding the index action:
class organisationActions extends autoOrganisationActions
{
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort', 'created_at') && $this->isValidSortColumn($request->getParameter('sort', 'created_at')))
{
$this->setSort(array($request->getParameter('sort', 'created_at'), $request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page'))
{
$this->setPage($request->getParameter('page'));
}
$this->pager = $this->getPager();
$this->sort = $this->getSort();
}
}
$request->getParameter('sort', 'created_at')
instead of
$request->getParameter('sort')

Based on my glance at the Doctrine API, it is SUPPOSED to support this feature, but may be broken for some versions of MS SQL. Unfortunately I don't have MS SQL any longer to experiment.
If you can get along without doing paging at all, a workaround could be to disable it by setting
list:
max_per_page: false
in your generator.yml file for the modules using admin.

I just ran into this (or a similar) problem. I was getting that error message, and I narrowed it down to a problem with the paging in Symfony. If I took out the paging stuff from the component action, I could get past it.
The answer turned out to be very simple: just order the main query (i.e. the query that the pager gets applied to). In my case, it was adding this:
->orderBy('i.created_at DESC')
Hope this helps someone.

Just an FYI. The backend admin generator pagination get's stuck on certain pages using OFFSET n; at the end of a doctrine query. The solution is to clear the SESSION COOKIES.
I kept getting blank pages in the backend. I analyzed my mysql queries and saw OFFSET 60 was being added to every query. This happened after I had deleted all records from the database table.

Related

How to post data to wordpress database using react

i'm trying to create a wordpress plugin and got a bit lost.
I'm not looking for a solution in code but could anyone direct me to a tutorial/docs where to find the correct approach.
I'm trying to post an array of objects to a mysql database.
Most basic stuff that you can do - onClick function, that connects to a database.
My wordpress plugin is created using React and I have previously used AJAX, but this time it throws quite a lot of errors that I have not seen, so I don't even know where to begin.
mysql npm package is also not working as I have used it before so i'm just confused.
Essentially could anyone tell me which API to use and link a good tutorial

SPA DTM analytics pagename issue

I am using Angular SPA with DTM.Using custom event based rules, I am able to get all my data including pageName, v41,v42 as correct. Now inside adobe editor, i am storing pagename to s.pageName and some hard-coded value to s.server. I have verified that all my data is correctly populating using OMNIBUG tool as server,pageName, v41 and v42.
Problem is coming in Omniture reporting, as server and page data are not coming through. Page-name data only showing SPA homepage in all page visits and server also coming as default from s.code and not the one i am passing from s.server. eVar/prop are all coming fine.Even if I do prop40=s.pageName/prop41=s.server, then in omniutre reporting i am seeing correct data populating in prop40/prop41 but not under Page and server. And again I cant use prop40/prop41 for pagename/server as its not a correct way to follow and PAGE-VISITS are ZERO in that case.
Any help how to get data in page/server in omniture for SPA or anything wrong in my implementation? Thanks in advance!!
If you really do see the correct values in Omnibug (or more specifically, network request to Adobe collection server), then the issue is not in the code.
Check against another AA hit debugger. Possible Omnibug is somehow bugging out. There are a ton of alternatives out there. Adobe Experience Cloud Debugger. Observepoint. Charles Proxy. Fiddler. Or just use the browser dev tool network tab (what I usually do as a backup).
Make sure you are looking in the correct report suite. Perhaps your data is being sent to a dev report suite, and you are looking at prod report suite, or visa versa?
Check to see if you have any Processing Rules that are overriding your values.
Contact your Adobe Rep to check if there are any VISTA Rules present for the report suite, that are overriding your values.
If you have verified none of the above is the case, then sorry, but it sounds like the issue must really be in your code, but there is a problem with your QA method (e.g. maybe you are looking at the wrong AA request, or something).
Update:
Based on your comment:
Earlier, i was making s.tl() call, but replacing it with s.t() call
resolved my problem for data was not populating
pageName/server/page-views in Omniture and now it is. But the current
problem is we need PageName on all SPA clicks (can be achieved by
s.t() call ) , but the page-Views are not needed on all clicks. So,
its like link-tracking needed only but with PageName data. I am
struggling not to populate page-views on a s.t() call or vice-versa
how to get PageName populated on s.tl() call. Again, omnibug shows all
requests just fine but the issue comes in reports in omniture
When Adobe processes a hit, it wipes pageName for s.tl calls, as that's how it determines whether to count the request as a page view or not. If you want to see page name even for s.tl calls, the common practice is to dupe the pageName value to a prop or eVar and send in with the s.tl call, and look at that report. In fact, most clients I work with don't even use the native pages report, and instead use the (usually eVar) report.

Load Testing Drupal by JMeter

I want to load test DRUPAL by JMeter, but when I run my test plan (it is about updating cart in drupal commerce) it gives me this error:"The form has become outdated. Copy any unsaved work in the form below and then reload this page."
I think the value of form-token is invalid. I use regular expressin for form-token with this regular expression: name="form_token" value="(.+?)".it still does not update cart
How can I solve this problem?
There could be a lot of different reasons for this, most probably:
Missing HTTP Cookie Manager
Missing or improperly working correlation
The solution is comparing the request, which is being generated by JMeter with the request, coming from the real browser - they need to be identical (apart from dynamic bits like cookies or this form_param).
In JMeter you can use View Results Tree listener to check request and response details, variables and cookie values, etc.
In browser you should have developer tools option which allows inspecting the same

What is the best way to update an angular application?

Our team is constantly working on an angular application, and every week or 2 we update it with new features or correct some bugs that came out.
We are using a C# backend with webservices.
QUESTION: When we update the application on the server, we sometimes (this doesn't happen all the time) get the problem that user is still seeing the old HTML and functionalities. What is the way to solve this?
I didn't find this on google, maybe I'm not looking for the right terms,
any help is appreciated.
Users have to clear their cache to get the new version of the application.
What you are seeing are cached copies of the JS files (possibly HTML partials too).
When the browser parses the HTML page, it makes the request for getting the JS resource and looks at various information before deciding to retrieve either the cached copy (if any) or whether to query the server again.
You can find some extra details on the Google fundamentals on HTTP caching
A solution I have been adopting myself is to set the cache headers to cache the file for a very long period, and then use tools in the build to version the file either on the filename or with a request parameter.
I have used grunt-cache-breaker and found it to serve well for this purpose. I know there is a gulp equivalent too
The most common way to make sure cached versions of your javascript aren't used is adding the version as a parameter in the reference to the script like so:
<script src="/app.js?v=v1.0"></script>

extjs 4 rest proxy and zend 2 restful controller

I want to post data to Zend 2 restful controller from EXTJS 4 rest proxy.
But when I inspect with the firebug I found that there is the post data ,but I am not able to fetch that data .How to get that post data to use it in my methods.
Where I am getting wrong I cant figure it out.
Anyone having steps to post data from rest Extjs 4 proxy method to Zend?
The standard way in PHP to load JSON from the HTTP Request Body is to use
$some_json = file_get_contents('php://input');
$some_object = json_decode($some_json);
I don't know whether Zend2 has their own way of doing it.
ExtJS send params like sort, page, filter, etc. into the URL, e.g.: http://myhost.com/?page=2&sort=myfield.
In this case you simply need to intercept the query params from your RESTController Action:
$page = $this->params()->fromQuery('page');
$sort = $this->params()->fromQuery('sort');
Data transmission to a ZF2 REST controller depends on the HTTP Method you are using:
GET, PUT, DELETE receives an $id argument;
POST used to create a new record and receives a $data argument.
For further information you can have a look in here:
http://framework.zend.com/manual/current/en/modules/zend.mvc.controllers.html#the-abstractrestfulcontroller
If you are interested, I am developing my REST proxy for Sencha, I have tested with ExtJS and Sencha Touch frameworks and it supports pagination, remote filters, remote sorting and so on.
It's developed with Zend Framework 2 and may support different DB types on the same installation. Have a look at:
http://apiskeleton.asaconsult.com/
I have exactly the same problem. Now, the reasons why the previous replies don´t work is because Zend Studio 10 has a new feature for configuring REST services from a visual editor that receives parameters and creates routes. This service designer is actually accepting the parameters form the body for the POST action of the Restful service but it somehow ignores the JSon sent from ExtJS. To make things worse, if you test the service using the integrated GUI in Zend Studio 10 it works perfectly and the JSon produced is 100% the same as the one from ExtJS ( I actually performed some data transforms to get to that point ), and it doesn't work.
The real issue is that there is 'something' within the POST method that is different in the ExtJS Request, than the JSon being expected from the framework itself that abstracts the code for deserializing this JSon from the developer.
The real question is, What is the Zend Server Gateway library expecting that ExtJS is sending in a different way in the POST body? I would enormously appreciate if any of the thousands of experts here could please check that out and come with a correct answer. The one that will answer this will have to have or to download a trial of Zend Studio 10 and check for himself how the Visual Service Tool that comes with ZS10 works. I have found so far that ExtJS4 produces it´s JSon like this:
{"data":
{"IdCurso":"0","Nombre":"NodeJS","IdEstadoCurso":"1",
"IdTipoPeriodo":"1","CantPeriodo":"1","CantAsignatura":"1","IdPlantel":"1"}
}
And the Zend GUI for testing the service, produces (and the service accepts) JSon like this:
{
'data' : '{"Nombre":"NodeJS","IdEstadoCurso":"1","IdTipoPeriodo":"1","CantPeriodo":"1","CantAsignatura":"1","IdPlantel":"1","IdCurso":"0"}'
}
As you can see data is enclosed on single quotes, and its content is as well for Zend Framework to consume it without issue. ExtJS uses double quotes, as well as is not quoting the content of the data package itself.
This is a Patch that actually works, Not the definitive solution, if somebody finds a better one, that would be great.
Try this as the first instruction in your add() (POST) method:
$data = json_decode($this->getRequest()->getContent());
You may need to add afer that:
$data = (array) $data;
After that, keep writing your code with the $data variable normally as you would do if the parameter would actually work.

Resources