Fatal error: Call to a member function limitPage() - magento-1.9

I was trying to add the pagination in one of my custom modules and i followed some reference URLs. Everything is good but at last i am getting an error Fatal error: Call to a member function limitPage() on a non-object in /var/www/html/lib/Varien/Data/Collection/Db.php on line 516
$pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
$pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
$this->getCollection = new Varien_Data_Collection_Db();
$rowObj = new Varien_Object();
$rowObj->setData($this->getOrderProductCollection());
$this->getCollection->addItem($rowObj);
//$this->getCollection->setPageSize(5)->setCurPage(1);
$pager->setCollection($this->getCollection);
$this->setChild('pager', $pager);
$this->getCollection->setPageSize(10);
$this->getCollection->setCurPage(2.8);
///$this->getCollection->load();
return $this;

Related

Trying to execute a BiqQuery Stored Procedure from a Google Cloud Function

I have the following code in Google Cloud Function. The cloud function is written in.NET 6 C#
var testsku = 1414;
var parameters = new BigQueryParameter[]
{
new BigQueryParameter("skuId", BigQueryDbType.Int64, testsku),
};
BigQueryClient client = BigQueryClient.Create(projectID);
string query = #"CALL 'xxxxxxx.xxxxxx.fraudskus'()";
BigQueryJob job = client.CreateQueryJob(
sql: query,
parameters: parameters,
options: new QueryOptions { UseQueryCache = false });
// Wait for the job to complete.
job.PollUntilCompleted();
// Display the results
int numOrders = 0;
foreach (BigQueryRow row in client.GetQueryResults(job.Reference))
{
numOrders++;
}
message = "Num of rows = " + numOrders;
The stored procedure runs fine in BIGQUERY and outputs the right results, but I am getting errors on the call to the stored procedure as follows.
"The service bigquery has thrown an exception.
No HttpStatusCode was specified.
Google.Apis.Requests.RequestError
Job unique-moon-366800/US/job_24e29215_e011_4d66_a2c4_bbf5640d5cc6 contained 2 error(s). First error message: Syntax error: Unexpected string literal 'unique-moon-366800.ecommerce_fraud_ds.fraudskus' at [1:6] [0]
Errors [
Message[Syntax error: Unexpected string literal 'xxxx.xxxxx.fraudskus' at [1:6]] Location[query - ] Reason[invalidQuery] Domain[]
Message[Syntax error: Unexpected string literal 'xxxx.xxxxx.fraudskus' at [1:6]] Location[query - ] Reason[invalidQuery] Domain[]
]
Google.GoogleApiException: The service bigquery has thrown an exception. No HttpStatusCode was specified. Job xxxxxxx/US/job_24e29215_e011_4d66_a2c4_bbf5640d5cc6 contained 2 error(s). First error message: Syntax error: Unexpected string literal 'unique-moon-366800.ecommerce_fraud_ds.fraudskus' at [1:6]
at Google.Cloud.BigQuery.V2.BigQueryJob.ThrowOnFatalError()
at Google.Cloud.BigQuery.V2.BigQueryJob.GetQueryDestinationTable()
at Google.Cloud.BigQuery.V2.BigQueryJob.GetQueryResults(GetQueryResultsOptions options)
at Google.Cloud.BigQuery.V2.BigQueryClientImpl.GetQueryResults(JobReference jobReference, GetQueryResultsOptions options)
at SimpleHttpFunction.Function.HandleAsync(HttpContext context) in /workspace/Function.cs:line 196
at Google.Cloud.Functions.Hosting.HostingInternals.Execute(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)"
I can get the results I expect if I use sql SELECT, but not if I try to call the stored procedure.

How to use MVC membership provider with MySQL?

I'm currently working on an ASP.NET MVC web application. I used this tutorial to use MySqlMembershipProvider in the app. The required tables are also created in the MySql database:
Now, when I try to register as a new user in my application, I get this error:
Unknown column 'Extent1.UserName' in 'field list'
Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column 'Extent1.UserName' in 'field list'
Source Error:
Line 80: {
Line 81: var user = new ApplicationUser() { UserName = model.UserName };
//error comes here at line 82
Line 82: var result = await UserManager.CreateAsync(user, model.Password);
Line 83: if (result.Succeeded)
Line 84: {
The error message shows that a query is being run which expects a field that it cannot find. So, the first thing to check is whether your my_aspnet_users table contains a UserName field. If not, then some error has occurred when the table was created.
If the field does exist, check your membership connection string and make sure it is connecting to the right database.

LLVM: error: 'class llvm::Function' has no member named 'hasFnAttribute'

I'm trying to use the method function::hasFnAttribute,
but the result is:
error: 'class llvm::Function' has no member named 'hasFnAttribute'
What am I doing wrong?
Code:
Module::iterator flti;
for(flti = Mod->begin(); flti != Mod->end(); flti++){
Function * actual = flti;
bool attr = actual->hasFnAttribute("inlinehint");
//...
}
Make sure you are using the proper LLVM version - this method has only been added in version 3.3 (released on June 2013).

Why does this not return an error?

I'm trying to evaluate arbitrary strings to know whether they are valid Python function definitions.
I ran this test at first :
i1 = "def z(a): return a"
exec(i1)
i2 = "def z(a): eturn a"
exec(i2)
Which raises a SyntaxError for i2. Then i tried with the real values I'm gonna have to evaluate :
i3 = """def fct_lambda(s,x):
return lambmax*(x>xmin)"""
exec(i3)
i4 = """def fct_lambda(s,x):
eturn lambmax*(x>xmin)"""
exec(i4)
Which yields SyntaxError for i4, seems ok. But then i came to the point :
i5 = """def densite_initiale(x):
return (((((x-0.0005)/0.00025)*(1-(x-0.0005)/0.00025))**5)*(x>0.0005)*(x<0.00075))"""
exec(i5)
i6 = """def densite_initiale(x):
eturn (((((x-0.0005)/0.00025)*(1-(x-0.0005)/0.00025))**5)*(x>0.0005)*(x<0.00075))"""
exec(i6)
Which yields no error for i6. However, if I delete a single parenthesis I will get a SyntaxError sent back, but not for the eturn NameError.
Additionally, is this the right way to do it ?
eturn(insert_expression_here) isn't a syntax error. The interpreter assumes you're calling a method called eturn with the arguments inside the parentheses. Sure, that function doesn't exist, but the interpreter won't complain until you actually execute densite_initiale.

Using functions on callbacks of a GUI

I'm using GUIDE to create an interface where a function [x,y]=function(a,b,c,d) will be executed when the button is clicked. Im having problems to get this to work. GUIDE creates an autogenerated function with the syntax varargout = LineasA(varargin).
I'm calling the GUI using this syntax [x,y]=LineasA(a,b,c,d).
Errors I get are:
Error in ==> LineasA>LineasA_OutputFcn at 73
varargout{1} = handles.output;
??? Error using ==> feval
Output argument "varargout{2}" (and maybe others) not assigned during call to
"C:\Users\ZeTa\Documents\MATLAB\ImagenB\LineasA.m>LineasA_OutputFcn".
Error in ==> gui_mainfcn at 263
[varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [],
gui_Handles);
Error in ==> LineasA at 40
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
Error in ==> ImagenB at 17
[MatrizB,Cuenta]=LineasA(Cuenta,waveformObj,channelObj,MatrizB);
You have to be clear where you are getting the inputs to this function, and where you want the outputs to go. It is proper coding to store the inputs and outputs in the handles struct that is passed into the callback. Also, the proper callback structure is:
LineasA(hObject, eventdata, handles)
However, if you insist on calling and storing from the base workspace, you can do as follows:
LineasA(hObject, eventdata, handles)
% grab values from base workspace
Cuenta = evalin('base', 'Cuenta');
waveformObj = evalin('base', 'waveformObj');
channelObj = evalin('base', 'channelObj');
MatrizB = evalin('base', 'MatrizB');
% the rest of your code
% assign outputs
assignin('base', 'MatrizB', matrizB);
assignin('base', 'Cuenta', Cuenta);
end
However I recommend getting those values in the handles structure and not to use evalin and assignin, they are usually bad coding techniques.