Yii Framework Forum: how to execute procedure - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how to execute procedure Rate Topic: -----

#1 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 01 December 2010 - 05:03 AM

Can any one help to run procedure depending upon the result of the procedure i want to filter the content
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 01 December 2010 - 08:28 AM

Can you explain a bit more your aim?
0

#3 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 01 December 2010 - 11:28 PM

View Postzaccaria, on 01 December 2010 - 08:28 AM, said:

Can you explain a bit more your aim?


I have return a procedure to select employee number with below condition

If pass manager ID to procedure it will return the employer under his controll
out put will be like
Manager
--------
South Assistant Number, North Assitant Number
south assistant
-----
emp1 emp2
north
-----
emp3 emp4

after this
i want to get their details(ex : south Assistant number ,name, add and so...)
0

#4 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 02 December 2010 - 02:20 AM

Is not very clear, anyway if you have to pass manager id to your procedure, for you is better to work like that:

Create a method in the manager model:

public function getEmployerUnderControl()
{
     // where you can get the manager id as $this->id;

}


So in your code you can use

$manager= Manager::model()->find();
$EmployerUnderControl=$manager->getEmployerUnderControl();


That is oop style.

Hope it helps
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 03:54 AM

It's not realy clear what you mean with procedure... do you mean database stored procedure or a PHP function?
And what you mean with "filter the content"?

Additionaly... maybe if you post your database structure it will be more clear...
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 05:34 AM

View Postmdomba, on 02 December 2010 - 03:54 AM, said:

It's not realy clear what you mean with procedure... do you mean database stored procedure or a PHP function?
And what you mean with "filter the content"?

Additionaly... maybe if you post your database structure it will be more clear...


To call stored procedure in sql, i used dbconnection to execute procedure after that if i execute findall method with condition it shows error connection to mysql server is terminated
0

#7 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 05:49 AM

When you call findAll() that's a complete new request, I think...

Can you post your code for executing the stored procedure?
Find more about me.... btw. Do you know your WAN IP?
0

#8 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 06:35 AM

View Postmdomba, on 02 December 2010 - 05:49 AM, said:

When you call findAll() that's a complete new request, I think...

Can you post your code for executing the stored procedure?


$employers=Employee::model()->getEmployee($user_id);


and function is

public function getEmployee($userid)
{
//echo $userid;
$employee=array();
$connection=Yii::app()->db;

$result =$connection->createCommand("call getEmployeeFrom(1)")->queryColumn();
foreach($result as $record)
{
array_push($employee,$record['employee_id']);
}

return $employee;
}
0

#9 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 07:15 AM

So now in the $employers you have an array with all emplyee_id's that you need...

What you want/need to do now?

NOTE: When posting code fragments use the <> button (Insert code snippets)... it makes code more readable...
Find more about me.... btw. Do you know your WAN IP?
0

#10 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 07:37 AM

View Postmdomba, on 02 December 2010 - 07:15 AM, said:

So now in the $employers you have an array with all emplyee_id's that you need...

What you want/need to do now?

NOTE: When posting code fragments use the <> button (Insert code snippets)... it makes code more readable...


$employers1=implode($employee,',');

$employeerdetailrecord=EmployeeDetail::model()->findAll("employer_id IN($employee)");


while doing this im getting following error

CDbException
Description

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query

If i remove the following code working with out error
($employeerdetailrecord=EmployeeDetail::model()->findAll("employer_id IN($employee1)");)

0

#11 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 07:45 AM

Note that $employers1is not used in the query you wanted to use this right?
Find more about me.... btw. Do you know your WAN IP?
0

#12 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 07:49 AM

View Postmdomba, on 02 December 2010 - 07:45 AM, said:

Note that $employers1is not used in the query you wanted to use this right?


sorry i have made a mistake while posting
$employers=Employee::model()->getEmployee($user_id);

$employers1=implode($employers,',');

$employeerdetailrecord=EmployeeDetail::model()->findAll("employer_id IN($employers1)");



Once again sorry
0

#13 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 08:13 AM

Sorry, I did not understand if it was a posting error and you are still getting the error or it is solved now?
Find more about me.... btw. Do you know your WAN IP?
0

#14 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 08:23 AM

View Postmdomba, on 02 December 2010 - 08:13 AM, said:

Sorry, I did not understand if it was a posting error and you are still getting the error or it is solved now?


no i wrongly post my original code .....


finally i typed my original code and send back to you still im having error

even im getting error if use this too....
$employeerdetailrecord=EmployeeDetail::model()->findAll()


CDbException
Description

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query


but working fine
$employeerdetailrecord=EmployeeDetail::model()->findAll();

$employers=Employee::model()->getEmployee($user_id);

$employers1=implode($employers,',');




0

#15 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 08:35 AM

I tried this localy and it works for me...

Seems like a problem with mysql - try to google "SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query" there are many info on that...

Maybe a new mysql version?
Find more about me.... btw. Do you know your WAN IP?
0

#16 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 08:40 AM

View Postmdomba, on 02 December 2010 - 08:35 AM, said:

I tried this localy and it works for me...

Seems like a problem with mysql - try to google "SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query" there are many info on that...

Maybe a new mysql version?


Have you used stored procedure?
0

#17 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 08:58 AM

No.. .I just used IN (1,2,3)...
Find more about me.... btw. Do you know your WAN IP?
0

#18 User is offline   Thirumalai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 20-November 10

Posted 02 December 2010 - 09:10 AM

View Postmdomba, on 02 December 2010 - 08:58 AM, said:

No.. .I just used IN (1,2,3)...


That's not at all a problem so that i mentioned its working fine before procedure call and not working after the call of procedure please understand that first .

question given by me is its working fine
$employeerdetailrecord=EmployeeDetail::model()->findAll();

$employers=Employee::model()->getEmployee($user_id);

$employers1=implode($employers,',');


its not working


$employers=Employee::model()->getEmployee($user_id);

$employers1=implode($employers,',');

$employeerdetailrecord=EmployeeDetail::model()->findAll();


Its not working after procedure call
tell me is there any mistake i made to call procedure
0

#19 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 09:13 AM

The procedure is called just fine... as I wrote before... it's something with the database...
Find more about me.... btw. Do you know your WAN IP?
0

#20 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 December 2010 - 09:17 AM

Here is more info on this problem

http://pecl.php.net/...bug.php?id=7976
http://bugs.php.net/bug.php?id=39858
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users