Solved

Query Syntax With LIKE

Posted on 2014-09-20
4
170 Views
Last Modified: 2014-09-20
I have a variation on a question I asked earlier .  How do I use LIKE in the following query and then in creating the variables?
Line 7 and Line 20;

 	$check_alt  = 	"SELECT meta_value, meta_key
					FROM wp_woocommerce_order_itemmeta
					WHERE (meta_key = 'Bicycle Info - Primary Operator First Name'
					OR meta_key = 'Bicycle Info - Primary Operator Last Name'
					OR meta_key = 'Bicycle Info - Bicycle Serial Number'
					OR meta_key = '_line_total'
					OR meta_key LIKE 'Custom Price - Bicycle Liability %')
					AND order_item_id = :order_id ";
 	
		$checking_alt = $pdo->prepare($check_alt);		
		$checking_alt->execute(array(':order_id' => $order_id)) or die(print_r($checking_alt -> errorInfo()));
		$res_alt = $checking_alt->fetchAll();	
				
				if ($res_alt) {
					
					foreach ($res_alt as $rows)  {
						if($rows->meta_key == "_line_total") { 
							$total = $rows->meta_value;
						}
						elseif($rows->meta_key == 'Custom Price - Bicycle Liability')	{
							$total_liabil = $rows->meta_value;
						}			
						} 						           
					}		
				}	
			}

Open in new window

0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
ID: 40334664
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334683
@dave, but it does not address how I write line 20  ???
0
 
LVL 58

Accepted Solution

by:
Gary earned 350 total points
ID: 40334690
if(strpos($rows->meta_key,"string-to-find") !== FALSE){
...
}

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40334705
Thanks!
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question