how to execute procedure

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

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…)

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

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

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;


    }

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)");




[b]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

[/b]

If i remove the following code working with out error




($employeerdetailrecord=EmployeeDetail::model()->findAll("employer_id IN($employee1)")<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />



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

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,',');







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?

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

The procedure is called just fine… as I wrote before… it’s something with the database…

Here is more info on this problem

http://pecl.php.net/bugs/bug.php?id=7976

http://bugs.php.net/bug.php?id=39858