Re: [PHP] regex

2008-01-21 Thread Keith Roberts
Can yo upost the code you have got to do the conversion 
so far please?


Regards

Keith

-
Websites:
http://www.karsites.net
http://www.php-debuggers.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-

On Mon, 21 Jan 2008, Peter wrote:


To: php-general@lists.php.net
From: Peter [EMAIL PROTECTED]
Subject: [PHP] regex

I am trying to convert ms access sql to postgresql using php.

I have a sql statement in the form ;-
$sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column
Name 2] etc.

what I want to end up with is $sql = SELECT DISTINCT table_name.column_name,
table_name_1.column_name_2, 

I have managed to get the caps to lower but I cant work out how to put the _
in place of spaces if the spaces are between [  ].   I either end up with
S_E_L_E_C . or SELECT_DISTINCT_ etc... .

Naturally I have only used part of sql statement and table, column names
have been changed. (Think the one I'm trying on is 2000+ characters. So its
not a case of set number of words/numbers between [] it could be 2 or it
could be 4 etc)

Anyone workout what I am talking about and can help would be appreciated.

Peter

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex

2008-01-21 Thread Keith Roberts
Hi Peter. Is this what you want to do. Copy this into a 
*.php page, and then look at it with your browser.


I just refactored one of my heredoc queries to handle your 
problem.


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 
Transitional//EN

 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en

head
titleSQL Regex Tester/title
/head

body

?php

echo Version 1 br /;

$this_table = 'MSS TABLE NAME';
$this_id = 5;

$sql = OUT
select * from $this_table
where ID = $this_id
OUT;

echo Contents of \$sql: br /$sql;



echo br /br / Version 2 br /;

$sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name1].[Column Name 
2];

echo Contents of \$sql: br /$sql;



echo br /br / Version 3 br /;


$this_table = 'MSS TABLE NAME';
$this_id = 5;

$sql = OUT
SELECT DISTINCT
[Table Name].[Column.Name],
[Table Name1].[Column Name 2]
OUT;

echo Contents of \$sql: br /$sql;



echo br /br / Version 4 br /;

$tbl_name  = [Table Name];
$col_name  = [Column Name];

$tbl_name1 = [Table Name1];
$col_name2 = [Column Name 2];


$sql = OUT
SELECT DISTINCT
$tbl_name.$col_name,
$tbl_name1.$col_name2
OUT;

echo Contents of \$sql: br /$sql;


echo br /br / Version 5 br /;

$sql_query = SELECT DISTINCT;

$tbl_name  = [Table Name];
$col_name  = [Column Name];

$tbl_name1 = [Table Name1];
$col_name2 = [Column Name 2];


$tbl_name = strtolower($tbl_name);
$col_name = strtolower($col_name);

$tbl_name1 = strtolower($tbl_name1);
$col_name2 = strtolower($col_name2);


$sql = OUT
$sql_query
$tbl_name.$col_name,
$tbl_name1.$col_name2
OUT;

echo Contents of \$sql: br /$sql;



echo br /br / Version 6 br /;

$sql_query = SELECT DISTINCT;

$tbl_name  = [Table Name];
$col_name  = [Column Name];

$tbl_name1 = [Table Name1];
$col_name2 = [Column Name 2];


// convert to lower case
$tbl_name = strtolower($tbl_name);
$col_name = strtolower($col_name);

$tbl_name1 = strtolower($tbl_name1);
$col_name2 = strtolower($col_name2);


// remove '[]' characters
$tbl_name = trim($tbl_name, []);
$col_name = trim($col_name, []);

$tbl_name1 = trim($tbl_name1, []);
$col_name2 = trim($col_name2, []);


// replace space with '_' character
$tbl_name = preg_replace('/\s/', '_', $tbl_name);
$col_name = preg_replace('/\s/', '_', $col_name);

$tbl_name1 = preg_replace('/\s/', '_', $tbl_name1);
$col_name2 = preg_replace('/\s/', '_', $col_name2);


$sql = OUT
$sql_query
$tbl_name.$col_name,
$tbl_name1.$col_name2
OUT;

echo Contents of \$sql: br /$sql;

?

/body
/html

The above code is not optimal, but it works OK.

I use the heredoc construct to build my sql query strings. 
Saves using all those single and double quote characters.


http://uk2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

HTH

Keith Roberts

-
Websites:
http://www.karsites.net
http://www.php-debuggers.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-

On Mon, 21 Jan 2008, Peter wrote:


To: php-general@lists.php.net
From: Peter [EMAIL PROTECTED]
Subject: Re: [PHP] regex

Well actually not a real lot so far. I'm just trial and error(lots of that)
at the moment. I've only been 'playing with php for about a month or so.
$file = phptest1.txt;
$rep = array (tbl_ , _%, bool default 0, bool default 1, '?');
$wih = array (, _pc, bool DEFAULT FALSE, bool DEFAULT TRUE,  );

if (is_file($file)) :

 $fh = fopen($file, r+) or die(File does not exist);
 while (! feof($fh)) :
  $line = fgets($fh,4096);
  $str = strtolower($line);
  $str_fixed = str_replace($rep, $wih, $str);
 print $str_fixed . br /;
 endwhile;

Then as far as the regexp part for replacing the space inbetween [blah blah
blah] with _ goes it was a case of try delete try delete etc. I may need to
break the string into an array but that in its self adds its own problems.

Think one of my problems is Im try to run before I can crawl with php,
postgre regex etc. Also its fun trying to workout things when all the books
you come across are php/mysql.

Came across an old message in my trawl of the news group that 'may' help
going to give that a try as soon as I get the time. (it was more to do with
replacing | with space between   but it maybe convertable)
Keith Roberts [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

Can yo upost the code you have got to do the conversion so far please?

Regards

Keith

-
Websites:
http://www.karsites.net
http://www.php-debuggers.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-

On Mon, 21 Jan 2008, Peter wrote:


To: php-general@lists.php.net
From: Peter [EMAIL PROTECTED]
Subject: [PHP] regex

I am trying

[PHP] New website dedicated to debugging PHP.

2008-01-20 Thread Keith Roberts
Hi everyone. Please excuse me for cross posting to four 
lists, but I'm aware that not everyone subscribes to all of 
the lists, so I don't want anyone to miss this announcement.


I have written a new website that is dedicated to debugging 
PHP applications.



From the about page:

http://www.php-debuggers.net/home/anyuser/about.php

About php-debuggers

A one-stop resource for Free Open Source PHP debuggers, 
covering all operating systems. This site has been developed 
in, and is maintained in, my spare time. I hope it helps you 
with debugging your PHP applications.


Here at php-debuggers you can:

* Find details of Open Source PHP debuggers available for
  your particular OS, including screenshots, and external
  download links.

* Find download links and installation and configuration
  instructions for PHP debugger modules, such as DBG and
  Xdebug.

* Post forum help requests for problems you have
  installing and configuring DBG or Xdebug PHP modules.

* Find installation and configuration instructions for
  your OS's PHP debugger GUI programs.

* Post forum help requests for problems you have
  installing and configuring the PHP debugger GUI programs
  on your OS.

* Make forum requests for PHP debugger GUI programs to
  be ported to your OS.

* Converse with other Open Source developers to discuss
  porting a particular PHP GUI debugger from one OS to any
  other.

* Add tutorials on the forum for how install and
  configure a particular PHP debugger module, or debugger
  GUI for your OS.

* Post details of Open Source PHP Debugger Projects that
  need more help, or a new maintainer for the project.

To suggest other OS categories, more PHP debugger GUI's, or 
improvements to the website, please see the contact page.


Kind Regards and Best Wishes,

Keith Roberts.


-
Websites:
http://www.karsites.net
http://www.php-debuggers.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Cannot parse html pages in php

2002-07-18 Thread Keith Roberts

I am running into a situation where I need some serious help.  My
environment is:

Workstation - W2k, Frontpage
Server - Cobalt RaQ4i, Linux, Apache

Problem:  I need to access MySQL to display inventory information on the web
page.  When I have modified the httpd.conf file to parse html files through
php, the embedded php code works.  However, FrontPage no longer works and a
Web statisics application will not work (Webalizer).  I know I am not
setting something correctly, but dang if I know what it is.

I really need some help on this.  Please realize that I am relatively new to
internet programming, linux, php, etc.  I have done okay so far, but this is
beyond me at this point.  Any help will be greatly appreciated.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Cannot parse html pages in php

2002-07-18 Thread Keith Roberts

I am running into a situation where I need some serious help.  My
environment is:

Workstation - W2k, Frontpage
Server - Cobalt RaQ4i, Linux, Apache

Problem:  I need to access MySQL to display inventory information on the web
page.  When I have modified the httpd.conf file to parse html files through
php, the embedded php code works.  However, FrontPage no longer works and a
Web statisics application will not work (Webalizer).  I know I am not
setting something correctly, but dang if I know what it is.

I really need some help on this.  Please realize that I am relatively new to
internet programming, linux, php, etc.  I have done okay so far, but this is
beyond me at this point.  Any help will be greatly appreciated.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] php and html

2002-07-18 Thread Keith Roberts

I am running into a situation where I need some serious help.  My
environment is:

Workstation - W2k, Frontpage
Server - Cobalt RaQ4i, Linux, Apache

Problem:  I need to access MySQL to display inventory information on the web
page.  When I have modified the httpd.conf file to parse html files through
php, the embedded php code works.  However, FrontPage no longer works and a
Web statisics application will not work (Webalizer).  I know I am not
setting something correctly, but dang if I know what it is.

I really need some help on this.  Please realize that I am relatively new to
internet programming, linux, php, etc.  I have done okay so far, but this is
beyond me at this point.  Any help will be greatly appreciated.






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] php and html

2002-07-18 Thread Keith Roberts

I am running into a situation where I need some serious help.  My
environment is:

Workstation - W2k, Frontpage
Server - Cobalt RaQ4i, Linux, Apache

Problem:  I need to access MySQL to display inventory information on the web
page.  When I have modified the httpd.conf file to parse html files through
php, the embedded php code works.  However, FrontPage no longer works and a
Web statisics application will not work (Webalizer).  I know I am not
setting something correctly, but dang if I know what it is.

I really need some help on this.  Please realize that I am relatively new to
internet programming, linux, php, etc.  I have done okay so far, but this is
beyond me at this point.  Any help will be greatly appreciated.








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php