Page 1 of 1

simple -

Posted: Mon Feb 06, 2006 10:26 pm
by VmusicV
Hi,
I have a file that has a bunch of sql statements, mixed in with code and comments. For example,
select p.first_nm, p.last_nm, p.img_file, ..... from party p,

I want to capture the sql statements - 'SELECT through the word FROM' - using regex, but I couldn't figure out the tutorials. I was under the impression regex would create an array of all of the occurences?

I am making sure there are NO selects without the from keyword, say burried in the comments or something....
Any help would be appreciated.

regexless in colulmbus

Posted: Mon Feb 06, 2006 10:34 pm
by feyd
it'd be hard to give an exact pattern unless you posted examples of what is in the file, involving not only a query, but many lines around it to understand what can and can't be in the pattern. However, I will throw out a generic pattern, as it may work in your instance.

Code: Select all

preg_match_all('#(SELECT .*?FROM)#si',$text,$matches);
var_export($matches);

regex master needed

Posted: Mon Feb 06, 2006 10:55 pm
by VmusicV
Hey Feyd.... you da mmmMAAan...

Sorry - I should have provided a better example - your code worked as is... but I tried to expand it and I couldn't get it to work

The file is below between the code

How would modify your preg_match_all statement to find all of the text between
SELECT and $filter
so for example select t.col1, t.col2, t.col3 from mytable t $filter $order - would return or place 'select t.col1, t.col2, t.col3 from mytable t $filter' into the array

see I know the dollar sign means end of line, but here it's a variable passed into this file for the WHERE clauses in the sql statements.


Any Help Would Be Great

Thanks

Code: Select all

<?

/////////////////////////////////////////////////////////////////////////////////////////
//function to get data
function getData($request_page, $table_view, $filter, $order, $purpose)
{

global $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view)
{
	case $table_view : 
	{ //list of all tables from the passed in databasse
		if($purpose == "SHOW ALL TABLES") //keep the format and spacing for $purpose EXACT
		{ 
			$sql_statement = "SHOW TABLES FROM $table_view"; 
			 $script_error = " retrieving a list of all tables in the database";
		}
		elseif($purpose == "SHOW COLUMNS")  //keep the format and spacing for $purpose EXACT
		{
			$sql_statement = "SHOW COLUMNS FROM $table_view"; 
			 $script_error = " retrieving a list of columns for the table or view $table_view";
		}
		
		break;
	}
	case "sys_element_attribute_spec" : 
	{
		if($purpose == "SHOW ALL FORM ELEMENTS and ATTRIBUTES") //keep the format and spacing 
		{
			$sql_statement = "SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order"; 
			 $script_error = " retrieving a list of elements and their attribute specifications";
			 //reportError($request_page, $script_error , $purpose , $sql_statement);
		}
		else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
		{  
			$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
			 $script_error = " Retrieving hyper link order or arrangement on page";
		}
		//reportError($request_page, $script_error , $purpose , $sql_statement);
		break;
	}
	case "sys_form_specification" : 
	{
		if($purpose == "SHOW ALL FORM SPECIFICATIONS")//keep the format and spacing for $purpose 
		{  
			$sql_statement = "SELECT fp.*, FROM `sys_form_specification` $filter $order"; 
			 $script_error = " retrieving list of form specifications";
			 //reportError($request_page, $script_error , $purpose , $sql_statement);
		}
		else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
		{  
			$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
			 $script_error = " Retrieving hyper link order or arrangement on page";
		}
		//reportError($request_page, $script_error , $purpose , $sql_statement);
		break;
	}
	case "party":  //keep the format and spacing for $purpose EXACT
	{
		if($purpose == "PARTY AND IMAGES REGARDLESS of ROLE")
		{
			$sql_statement = "SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order"; 
			 $script_error = " retrieving party and images regardless of role";
			 //reportError($request_page, $script_error , $purpose , $sql_statement);
		}
		break;
	}
	case "content" : 
	{
		if($purpose == "GENERAL DISPLAY") //keep the format and spacing for $purpose EXACT
		{
			$sql_statement = "SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order"; 
			 $script_error = " Retrieving General Display Content/Article and Author(s)";
			 //reportError($request_page, $script_error , $purpose , $sql_statement);
		}
		else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
		{  
			$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
			 $script_error = " Retrieving hyper link order or arrangement on page";
		}
		//reportError($request_page, $script_error , $purpose , $sql_statement);
		break;
	}
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link)
{
	//error handling
	reportError($request_page, $script_error, $no_db_connection, $sql_statement);
	$result = -1;
}
else
{
	// SQL Query - should select each column by name
	$result = mysql_query($sql_statement, $db_link);
	if(!$result)
	{
		   //error handling
			reportError($request_page, $script_error, $no_result, $sql_statement);
			$result = -2;
	}

	return $result;
}
} //end function getData


/////////////////////////////////////////////////////////////////////////////////////////
//function to set or update data
function setData($request_page, $table_view, $update_string, $filter, $uid){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view){
	case "links" : {
		$current_date = date("Y-m-d, H:i:s"); 
		$sql_statement = "UPDATE LINKS SET ";
		$sql_statement .=  $update_string;
		$sql_statement .= ", last_update_dt = '" . $current_date . "' " . $filter;
		$script_error = "Updating hyper links.";
		//here to see what the SQL statement is
		//reportError($request_page, $script_error ,"No SQL result - testing only " , $sql_statement);
		break;
	}
	
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
	//error handling
	reportError($request_page, $script_error, $no_db_connection, $sql_statement);
	$result = -1;
}
else{
	//reportError($request_page, $script_error, $no_result, $sql_statement);
	// SQL Query - should select each column by name
	$result=mysql_query($sql_statement, $db_link);

	if(!$result){
		//error handling
		reportError($request_page, $script_error, $no_result, $sql_statement);
		$result = -2;
	}
return $result;
}
} //end function


/////////////////////////////////////////////////////////////////////////////////////////
//function to add or insert data
function addData($request_page, $table_view, $insert_string, $purpose, $uid){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//this may be used with all inserts
$current_date = date("Y-m-d  H:i:s");

//build sql statement based on the table -
switch($table_view){
	case "web_issue" : {

		$sql_statement = "INSERT INTO web_issue VALUES('', ";
		$sql_statement .=  $insert_string;
		$sql_statement .= " )";

		//here to see what the SQL statement is
		$script_error = "Inserting a new web issue";
		//reportError($request_page, $script_error ,"No SQL result - testing only " , $sql_statement);
		break;
	}

} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
	//error handling
	reportError($request_page, $script_error, $no_db_connection, $sql_statement);
	$result = -1;
}
else{
	// SQL Query - should insert a row into a table or view
	$result=mysql_query($sql_statement, $db_link);

	if(!$result){
		//error handling
		reportError($request_page, $script_error, $no_result, $sql_statement);
		$result = -2;
	}
return $result;
}
} //end function

/////////////////////////////////////////////////////////////////////////////////////////
//function to delete data
function removeData($request_page, $purpose, $table_view, $filter, $uid ){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view){
	case "event" : {
		if($purpose == "DELETE EVENT"){
			$sql_statement = "DELETE FROM event $filter"; 
			 $script_error = "Deleting event from admin area per user request. User ID: " . $uid;
		}
		break;
	}
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
	//error handling
	reportError($request_page, $script_error, $no_db_connection, $sql_statement);
	$result = -1;
}
else{
	// SQL Query - should select each column by name
	$result=mysql_query($sql_statement, $db_link);

	if(!$result){
		//error handling
		reportError($request_page, $script_error, $no_result, $sql_statement);
		$result = -2;
	}
return $result;
}
} //end function

?>

Posted: Mon Feb 06, 2006 11:39 pm
by feyd
it appears all the selects are given in a single string, so you could possibly use this:

Code: Select all

preg_match_all('#"(SELECT. ?)"#si',$text,$matches);
var_export($matches);

Only one word?

Posted: Tue Feb 07, 2006 9:36 am
by VmusicV
Hey Feyd,
Uh... your
preg_match_all('#(SELECT. ?)#si', $starting_string, $matches);

it doesn't give me the entire sql string, it only grabs the word select. I really want the entire string, from the 'SELECT word all the way through the $filter word, which is a variable but reading it in a text file it's just a word....

so for example I 'SELECT .........................$filter' - is what I wanted to grab. Starting with 'SELECT' then all the words up through and including the word '$filter'.

Thanks!!!
VmusiV

Posted: Tue Feb 07, 2006 9:44 am
by feyd
doh, stupid quick reply.. that space is supposed to be a plus.

Sorry.... I'm kind of /[S-L-O-W]/

Posted: Tue Feb 07, 2006 11:02 am
by VmusicV
Hi Feyd,
I tried putting a plus sign in where the space was - as shown below........

preg_match_all('#(SELECT.+?)#si', $starting_string, $matches);
var_export($matches);


I am still getting just the select

Isn't there a way to match a phrase that starts with 'SELECT' and ends with '$filter' ????

Thanks for your patience!!!
VmusicV

Posted: Tue Feb 07, 2006 11:19 am
by feyd

Code: Select all

preg_match_all('#"(SELECT.+?)"#si',$text,$matches);
var_export($matches);
try that.

If not that, try

Code: Select all

preg_match_all('#(SELECT.+?\$filter)#si',$text,$matches);
var_export($matches);

Crying Endlessly

Posted: Tue Feb 07, 2006 5:09 pm
by VmusicV
:x

OK.... I've tried and I've tried let me put it this way

while(date() < eternity){
try preg_match expression;
cry because it doesn't work;
}


I SWEAR... I've tried every combination, I've esaped, brought back, added subtracted, meta-charactered and even called 911

I just want a preg_match expression that will pull all the occurences of 'SELECT.......filter' out of the text file, which I already moved into a variable above

Thanks
No Really Thanks

VmusicV

Posted: Tue Feb 07, 2006 5:29 pm
by feyd
This sure seems to work:

Code: Select all

<?php

$text='
<?

/////////////////////////////////////////////////////////////////////////////////////////
//function to get data
function getData($request_page, $table_view, $filter, $order, $purpose)
{

global $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view)
{
   case $table_view :
   { //list of all tables from the passed in databasse
      if($purpose == "SHOW ALL TABLES") //keep the format and spacing for $purpose EXACT
      {
         $sql_statement = "SHOW TABLES FROM $table_view";
          $script_error = " retrieving a list of all tables in the database";
      }
      elseif($purpose == "SHOW COLUMNS")  //keep the format and spacing for $purpose EXACT
      {
         $sql_statement = "SHOW COLUMNS FROM $table_view";
          $script_error = " retrieving a list of columns for the table or view $table_view";
      }
      
      break;
   }
   case "sys_element_attribute_spec" :
   {
      if($purpose == "SHOW ALL FORM ELEMENTS and ATTRIBUTES") //keep the format and spacing
      {
         $sql_statement = "SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order";
          $script_error = " retrieving a list of elements and their attribute specifications";
          //reportError($request_page, $script_error , $purpose , $sql_statement);
      }
      else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
      { 
         $sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
          $script_error = " Retrieving hyper link order or arrangement on page";
      }
      //reportError($request_page, $script_error , $purpose , $sql_statement);
      break;
   }
   case "sys_form_specification" :
   {
      if($purpose == "SHOW ALL FORM SPECIFICATIONS")//keep the format and spacing for $purpose
      { 
         $sql_statement = "SELECT fp.*, FROM `sys_form_specification` $filter $order";
          $script_error = " retrieving list of form specifications";
          //reportError($request_page, $script_error , $purpose , $sql_statement);
      }
      else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
      { 
         $sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
          $script_error = " Retrieving hyper link order or arrangement on page";
      }
      //reportError($request_page, $script_error , $purpose , $sql_statement);
      break;
   }
   case "party":  //keep the format and spacing for $purpose EXACT
   {
      if($purpose == "PARTY AND IMAGES REGARDLESS of ROLE")
      {
         $sql_statement = "SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order";
          $script_error = " retrieving party and images regardless of role";
          //reportError($request_page, $script_error , $purpose , $sql_statement);
      }
      break;
   }
   case "content" :
   {
      if($purpose == "GENERAL DISPLAY") //keep the format and spacing for $purpose EXACT
      {
         $sql_statement = "SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order";
          $script_error = " Retrieving General Display Content/Article and Author(s)";
          //reportError($request_page, $script_error , $purpose , $sql_statement);
      }
      else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
      { 
         $sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
          $script_error = " Retrieving hyper link order or arrangement on page";
      }
      //reportError($request_page, $script_error , $purpose , $sql_statement);
      break;
   }
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link)
{
   //error handling
   reportError($request_page, $script_error, $no_db_connection, $sql_statement);
   $result = -1;
}
else
{
   // SQL Query - should select each column by name
   $result = mysql_query($sql_statement, $db_link);
   if(!$result)
   {
         //error handling
         reportError($request_page, $script_error, $no_result, $sql_statement);
         $result = -2;
   }

   return $result;
}
} //end function getData


/////////////////////////////////////////////////////////////////////////////////////////
//function to set or update data
function setData($request_page, $table_view, $update_string, $filter, $uid){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view){
   case "links" : {
      $current_date = date("Y-m-d, H:i:s");
      $sql_statement = "UPDATE LINKS SET ";
      $sql_statement .=  $update_string;
      $sql_statement .= ", last_update_dt = \'" . $current_date . "\' " . $filter;
      $script_error = "Updating hyper links.";
      //here to see what the SQL statement is
      //reportError($request_page, $script_error ,"No SQL result - testing only " , $sql_statement);
      break;
   }
   
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
   //error handling
   reportError($request_page, $script_error, $no_db_connection, $sql_statement);
   $result = -1;
}
else{
   //reportError($request_page, $script_error, $no_result, $sql_statement);
   // SQL Query - should select each column by name
   $result=mysql_query($sql_statement, $db_link);

   if(!$result){
      //error handling
      reportError($request_page, $script_error, $no_result, $sql_statement);
      $result = -2;
   }
return $result;
}
} //end function


/////////////////////////////////////////////////////////////////////////////////////////
//function to add or insert data
function addData($request_page, $table_view, $insert_string, $purpose, $uid){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//this may be used with all inserts
$current_date = date("Y-m-d  H:i:s");

//build sql statement based on the table -
switch($table_view){
   case "web_issue" : {

      $sql_statement = "INSERT INTO web_issue VALUES(\'\', ";
      $sql_statement .=  $insert_string;
      $sql_statement .= " )";

      //here to see what the SQL statement is
      $script_error = "Inserting a new web issue";
      //reportError($request_page, $script_error ,"No SQL result - testing only " , $sql_statement);
      break;
   }

} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
   //error handling
   reportError($request_page, $script_error, $no_db_connection, $sql_statement);
   $result = -1;
}
else{
   // SQL Query - should insert a row into a table or view
   $result=mysql_query($sql_statement, $db_link);

   if(!$result){
      //error handling
      reportError($request_page, $script_error, $no_result, $sql_statement);
      $result = -2;
   }
return $result;
}
} //end function

/////////////////////////////////////////////////////////////////////////////////////////
//function to delete data
function removeData($request_page, $purpose, $table_view, $filter, $uid ){
global $db_host, $db_user, $db_pwd, $db_name, $db_default_name, $mysql_errno, $mysql_error, $no_db_connection, $no_result;

//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view){
   case "event" : {
      if($purpose == "DELETE EVENT"){
         $sql_statement = "DELETE FROM event $filter";
          $script_error = "Deleting event from admin area per user request. User ID: " . $uid;
      }
      break;
   }
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link){
   //error handling
   reportError($request_page, $script_error, $no_db_connection, $sql_statement);
   $result = -1;
}
else{
   // SQL Query - should select each column by name
   $result=mysql_query($sql_statement, $db_link);

   if(!$result){
      //error handling
      reportError($request_page, $script_error, $no_result, $sql_statement);
      $result = -2;
   }
return $result;
}
} //end function

?>';

preg_match_all('#"(SELECT.+?)"#si',$text,$matches);
var_export($matches);

?>
Outputs:

Code: Select all

array (
  0 => 
  array (
    0 => '"SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order"',
    1 => '"SELECT MAX(link_order) FROM LINKS $filter"',
    2 => '"SELECT fp.*, FROM `sys_form_specification` $filter $order"',
    3 => '"SELECT MAX(link_order) FROM LINKS $filter"',
    4 => '"SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order"',
    5 => '"SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order"',
    6 => '"SELECT MAX(link_order) FROM LINKS $filter"',
  ),
  1 => 
  array (
    0 => 'SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order',
    1 => 'SELECT MAX(link_order) FROM LINKS $filter',
    2 => 'SELECT fp.*, FROM `sys_form_specification` $filter $order',
    3 => 'SELECT MAX(link_order) FROM LINKS $filter',
    4 => 'SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order',
    5 => 'SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order',
    6 => 'SELECT MAX(link_order) FROM LINKS $filter',
  ),
)

SwweeEEEEEeeeeTTT

Posted: Tue Feb 07, 2006 6:30 pm
by VmusicV
Feyd,
Thank you so much. Yes it does work. I was testing it with the wrong string variable.

All I have to say is:
Image
Thanks!!!
no really
Thanks!!!!
Vmusic

Posted: Tue Feb 07, 2006 6:36 pm
by raghavan20
I just now was working on this...it works in my way as well..

I have the entire file in my host space

Code: Select all

$fileString = file_get_contents("sampleDoc.txt");
echo $fileString;
preg_match_all("#(select(.*?)from.*?)$#im", $fileString, $matches);
var_export($matches);
Output:
I have got the information btw select and from keywords as well..

Code: Select all

array (
  0 => 
  array (
    0 => 'SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order";
',
    1 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
    2 => 'SELECT fp.*, FROM `sys_form_specification` $filter $order";
',
    3 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
    4 => 'SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order";
',
    5 => 'SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order";
',
    6 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
  ),
  1 => 
  array (
    0 => 'SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order";
',
    1 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
    2 => 'SELECT fp.*, FROM `sys_form_specification` $filter $order";
',
    3 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
    4 => 'SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order";
',
    5 => 'SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c,  `party_content` pc,  `party` p $filter $order";
',
    6 => 'SELECT MAX(link_order) FROM LINKS $filter";
',
  ),
  2 => 
  array (
    0 => ' seas.* ',
    1 => ' MAX(link_order) ',
    2 => ' fp.*, ',
    3 => ' MAX(link_order) ',
    4 => ' p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm,   p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm,  p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc ',
    5 => ' c.*, p.person_fnm, p.person_lnm ',
    6 => ' MAX(link_order) ',
  ),
)

Posted: Tue Feb 07, 2006 6:39 pm
by feyd
yours is pulling a trailing quote though.. ;)

Posted: Tue Feb 07, 2006 7:05 pm
by raghavan20
feyd wrote:yours is pulling a trailing quote though.. ;)
Can you tell me why it is behaving like that...all matches start with a single quote but end with a double quote... :roll:

Posted: Tue Feb 07, 2006 7:17 pm
by feyd
the array is being output by var_export() which creates a literal representation of the contents of the variable given to it. In this case, strings are being stored in an array. If you look carefully, each of the strings are single-quote strings. The ending quote is often on the following line. Your regex is grabbing the trailing double quote because each of the selects is being captured until an end of line is found, which happens to be after the double quote. Mine captures the contents of double quoted strings. Slightly differing behavior.