After the post login redirect page shows the following error. In shows unknown column as 'id'. After login the controller moved to payment function. In this function I used DB for payment process. Can anyone help to rectify the error?
Here usp_payment_detail is procedure of my database.
Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'field list' (SQL: call usp_payment_details(null,null))
Procedure:
BEGIN
-- Ashok Kumar, 25/11/2015
-- V1.3
-- Parameters are optional.
-- Parameter values for "is_completed" are :
-- 0 - incomplete , 1 - complete , null - for complete/incomplete
-- Usage
-- call usp_payment_details(null,'babyname');
-- call usp_payment_details(null,null);
DECLARE input_is_completed tinyint(4) default null;
DECLARE input_service_name varchar(200) default null;
DECLARE dynamic_where varchar(3000);
set input_is_completed=(select is_completed);
set input_service_name=(select service_name);
set dynamic_where='';
if input_is_completed is null then
set dynamic_where=concat(' where paid_at is not null');
else if input_is_completed=0 then
set dynamic_where=concat(' where is_completed is null and paid_at is not null');
else if input_is_completed=1 then
set dynamic_where=concat(' where is_completed is not null and paid_at is not null');
end if;
end if;
end if;
DROP TEMPORARY TABLE IF EXISTS tmpprocess_tables;
CREATE TEMPORARY TABLE tmpprocess_tables
(row_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,tablename varchar(100));
set @db_name=(SELECT DATABASE());
if input_service_name is null then
begin
insert into tmpprocess_tables(tablename)
SELECT table_name FROM information_schema.tables
WHERE table_schema=@db_name and table_name not in('logs','users');
end;
else
begin
set @insert_sql=concat('insert into tmpprocess_tables(tablename)
SELECT table_name FROM information_schema.tables
WHERE table_schema=','',@db_name,'',' and table_name like concat('%',',input_service_name,','%')');
Prepare stmt from @insert_sql;
Execute stmt;
end;
end if;
DROP TEMPORARY TABLE IF EXISTS tmppopulate_payments;
CREATE TEMPORARY TABLE tmppopulate_payments
(sno INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,primary_id int(11),tab_name varchar(200)
,is_plan varchar(100),is_name varchar(100),amount decimal(10,2),is_completed datetime,paid_at datetime,first_name varchar(50),
middle_name varchar(50),last_name varchar(50),initial varchar(50),full_name varchar(50));
set @count=(select count(row_id) from tmpprocess_tables);
set @ctr=1;
WHILE(@ctr<=@count) DO
set @tableName=(select tableName from tmpprocess_tables where row_id=@ctr);
SET @insert_sql=concat('insert into tmppopulate_payments(primary_id,tab_name,is_plan,is_name,amount,is_completed,paid_at,first_name,middle_name,last_name,initial,full_name)
select id,','', @tableName,'',' ,is_plan,is_name,amount,is_completed,paid_at,first_name,middle_name,last_name,initial,full_name from ', @tableName,' ',dynamic_where);
PREPARE stmt1 FROM @insert_sql;
EXECUTE stmt1;
SET @ctr=@ctr+1;
END WHILE;
set @select_sql=concat('select sno,primary_id,tab_name,is_plan,is_name,amount,is_completed,paid_at,first_name,middle_name,last_name,initial,full_name from tmppopulate_payments order by paid_at desc');
PREPARE stmt1 FROM @select_sql;
EXECUTE stmt1;
End
LoginController:
public function payment($t)
{
$showFilter = 0;
$table = [];
$status = "null";
$service_name= "null";
// $serviceArr= $tab_name;
if(Input::has('status'))
{
$status = "'" .Input::get('status') . "'";
}
if(Input::has('service_name'))
{
$service_name = "'" . Input::get('service_name') . "'";
}
$table =array(''=>'- Select -');
$data = DB::select("select TABLE_NAME from information_schema.tables where TABLE_SCHEMA = 'urbanedg_mn'");
foreach ($data as $key => $value)
{
$table[$value->TABLE_NAME] = $value->TABLE_NAME;
}
$data = DB::select("call usp_payment_details($status,$service_name)");
return View::make('backoffice/loginpage/payment')->with('table',$table)
->with('data',$data)
->with('statusArr',CustomClass::$StatusArr)
->with('serviceArr',CustomClass::$ServiceArr)
->with('s',Input::has("s")?Input::get("s") : 0)
->with('msg',Input::has("msg")?Input::get("msg") : '')
->with('t',$t);
}
Have a look at your procedure,
if input_service_name is null then
begin
insert into tmpprocess_tables(tablename)
SELECT table_name FROM information_schema.tables
WHERE table_schema=@db_name and table_name not in('logs','users');
end;
else
begin
set @insert_sql=concat('insert into tmpprocess_tables(tablename)
SELECT table_name FROM information_schema.tables
WHERE table_schema=','',@db_name,'',' and table_name like concat('%',',input_service_name,','%')');
Prepare stmt from @insert_sql;
Execute stmt;
end;
end if;
If the parameters passed to this procedure are null, all table names in the schema inserted into the temporary table.
May any one of the table does not have the column named "id". Ensure that you insert only the required tables or all having the column "id"