Solved

How do I use strcspn() to extract values in an SQL argument?

Posted on 2009-05-16
2
190 Views
Last Modified: 2012-05-07
Hi,

I'm trying to extract MySQL insert values into a PHP array. Each field value is delimited by a comma, though surrounding each comma can be a single quote, a closed bracket, an uppercase letter denoting the start of a MySQL function or an integer. Finding the start and end of each value is made more complicated by concatenated values. I don't want to use regex as I need greater efficiency for this particular code and was looking into strcspn - can anyone show me some code demonstrating strcspn splitting an SQL expression?

Thanks
0
Comment
Question by:tomp_gl
2 Comments
 
LVL 7

Accepted Solution

by:
tg_wilk earned 500 total points
Comment Utility
Maybe instead of reinventing the wheel, you could use already made class to parse insert queries.  Here's one example based on tokens, not regex, so it should be fast enough:
http://www.phpclasses.org/browse/package/5007.html
It includes insert queries parser.
0
 

Author Comment

by:tomp_gl
Comment Utility
I resolved the problem using strpos and looping.

Thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now