?
Solved

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

Posted on 2009-05-16
2
Medium Priority
?
203 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
[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 Comments
 
LVL 7

Accepted Solution

by:
tg_wilk earned 1500 total points
ID: 24403185
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
ID: 24532192
I resolved the problem using strpos and looping.

Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
Starting up a Project
Suggested Courses

719 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