RE: Calling multiple stored procedures.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes ,We are using mysqli library.We are using 19 functions in the same php page .Please check out following  sample function which we are written in our application and please give us your suggestions.

function Related_Topic_category($str_searchString)
{
    $str_searchString =trim($str_searchString);
    $topic = array();
    $Query1 = "";
$var="science";
    $temp_str_searchString ="";
    if(substr($str_searchString,strlen($str_searchString)-1) == 's')
      {
        $temp_str_searchString = substr($str_searchString,0,strlen($str_searchString)-1);
        $var="+".mysql_escape_string($temp_str_searchString)."*";
        $Query1="call Related_Topic_category('$var')";
      } 
    else
      {
        $temp_str_searchString = $str_searchString;
        $var=mysql_escape_string($temp_str_searchString);
        $Query1="call Related_Topic_category('$var')";
      }
      $mysqli = mysqli_connect("localhost", "root", "vijaya", "testdb");
      
      $result = $mysqli->query("$Query1");
      if(mysqli_num_rows($result)==0) 
      {
       $var="+".mysql_escape_string($str_searchString)."*";
       $Query1="call Related_Topic_category('$var')";
       $mysqli->close();
        $mysqli = mysqli_connect("localhost", "root", "vijaya", "testdb");
      
       $result = $mysqli->query("$Query1");
      }
      if(mysqli_num_rows($result)>0)
      {
          $rows=mysqli_num_rows($result);            
        for($i=0;$i<$rows;$i++) 
        {
            $res_row= mysqli_fetch_row($result);    
            $topic[]=array('name'=>$res_row[1],'id'=>$res_row[0]);
        }
     }
    else
     {
        $topic[] = "None";
     }
      $mysqli->close();
      return $topic;        
  }



<ratkinson@xxxxxxxxxxxxx> wrote:                               I still don't understand why you need to do it this way.
 
 Are you using the mysqli client library for the statements? This support the
 mysqli_prepare() method, which will allow you to send multiple queries over a
 single connection?
 
 Rob.
 
 -----Original Message-----
 From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
 Behalf Of Vijaya Lakshmi
 Sent: 21 December 2007 10:52
 To: php-objects@xxxxxxxxxxxxxxx
 Subject: RE:  Calling multiple stored procedures.
 
 Hi,
 thank you for your message.Actually if we not closed the connection we unable
 to called the next stored procedure.So that every time we have done open and
 close the connection to mysql
 
 "Atkinson, Robert" <ratkinson@xxxxxxxxxxxxx> wrote:
 Why do you think you need to open and close the connection in-between calls
  to the stored procedure? 
  
  -----Original Message-----
  From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
  Behalf Of emandi govind rao
  Sent: 21 December 2007 08:55
  To: php-objects@xxxxxxxxxxxxxxx
  Subject:  Calling multiple stored procedures.
  
  Hi All,
  
  We have written code for multiple functions in php.In the functions we
  are using stored procedures calls.First we called a stored
 procedure,retrived
  values.To retrive values from second stored porcedure we need to close the
  previously opened connection and then execute the second stored procedure.
      
      But  actually we are using  remote MYSQL DB.Due to the closing/opening
 of
  DB connection ,it is taking so much to execute our application.
     
      We need an alternaive method to avoid close/open connection each time
 for
  each strored procedure call.
  
  If any one knows a solution, please help us.
  
  Thanking u all.
  
  
 *****************************************************************************
 ******
  Any opinions expressed in email are those of the individual and not
 necessarily those of the company. This email and any files transmitted with
 it are confidential and solely for the use of the intended recipient 
  or entity to whom they are addressed. It may contain material protected by
 attorney-client privilege. If you are not the intended recipient, or a person
 responsible for delivering to the intended recipient, be advised that you
 have received this email in error and that any use is strictly prohibited.
  
  Random House Group + 44 (0) 20 7840 8400
  http://www.randomhouse.co.uk
  http://www.booksattransworld.co.uk 
  http://www.kidsatrandomhouse.co.uk
  Generic email address - enquiries@xxxxxxxxxxxxxxxxx
  
  Name & Registered Office:
  THE RANDOM HOUSE GROUP LIMITED
  20 VAUXHALL BRIDGE ROAD
  LONDON
  SW1V 2SA
  Random House Group Ltd is registered in the United Kingdom with company No.
 00954009, VAT number 102838980
  
 *****************************************************************************
 ******
  
  
      
                                
 
 ---------------------------------
  Download prohibited? No problem. CHAT from any browser, without download.
        
 ---------------------------------
  Forgot the famous last words? Access your message archive online. Click
 here.
 
 [Non-text portions of this message have been removed]
 
 Are you looking for a PHP job? Join the PHP Professionals directory Now!
 http://www.phpclasses.org/professionals/ 
 Yahoo! Groups Links
 
 
     
                               

       
---------------------------------
 Chat on a cool, new interface. No download required. Click here.

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux