Re: [PHP-DB] fiscal week??

2002-07-31 Thread Jason Wong

On Wednesday 31 July 2002 20:56, Dib, Walid (MED, Stagiaire GEMS) wrote:
 How can i print the fiscal week number on a web page??

1) Work out an algorithm to calculate the fiscal week
2) Implement algorithm in php

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Roumanian-Yiddish cooking has killed more Jews than Hitler.
-- Zero Mostel
*/


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




RE: [PHP-DB] fiscal week??

2002-07-31 Thread Gary . Every

Look at the date functions at:
http://www.mysql.com/doc/D/a/Date_and_time_functions.html
and search for the date_format table
Within it you will see the following:


 
%U  Week (00..53), where Sunday is the first day of the week  
%u  Week (00..53), where Monday is the first day of the week  
%V  Week (01..53), where Sunday is the first day of the week. Used with '%X'

%v  Week (01..53), where Monday is the first day of the week. Used with '%x'


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


-Original Message-
From: Pierre-Alain Joye [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 8:25 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] fiscal week??


On Wed, 31 Jul 2002 21:19:00 +0800
Jason Wong [EMAIL PROTECTED] wrote:

 On Wednesday 31 July 2002 20:56, Dib, Walid (MED, Stagiaire GEMS) wrote:
  How can i print the fiscal week number on a web page??
 
 1) Work out an algorithm to calculate the fiscal week
 2) Implement algorithm in php

or simply use the pear::Date package :)

Do not be so rude with newcomers :)

pa

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



[PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Brian Graham

Are there any benefits to assigning a query to a variable?



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




[PHP-DB] adding a space in mysql

2002-07-31 Thread ron wallace

How can I add a space to the end of a varchar string
in mysql?  I can't seem to do it directly, and I tried
str_pad and other things, but no luck so far.  The db
doesnt hold the value of the space...its getting
trimmed somewhere(?)

The reason I want to do this is so I can search for
exact matches on one word strings without stemming:
...WHERE name LIKE '$var %'.

If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.

Thank You All

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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




RE: [PHP-DB] adding a space in mysql

2002-07-31 Thread Hutchins, Richard

I haven't set up any text-based searches before, but when you say:
snip
If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.
snip
Aren't you, in essence, saying that you want to search for Wash? Meaning
that your query could just say WHERE name = '$var' (where $var is set to
Wash)?

According to the MySql manual, the equal comparison operator works on
strings and numbers. But maybe text searches work differently than I thought
and it will return strings wherever the letter combination wash appears.
If that's the case I'm sure somebody will correct me and I'll learn
something in the process.

-Original Message-
From: ron wallace [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 4:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] adding a space in mysql


How can I add a space to the end of a varchar string
in mysql?  I can't seem to do it directly, and I tried
str_pad and other things, but no luck so far.  The db
doesnt hold the value of the space...its getting
trimmed somewhere(?)

The reason I want to do this is so I can search for
exact matches on one word strings without stemming:
...WHERE name LIKE '$var %'.

If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.

Thank You All

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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

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




RE: [PHP-DB] adding a space in mysql

2002-07-31 Thread Jim Hunter

Richard,

   You are correct. For Ron to achieve his goal, the SQL needs to be changed
to:

WHERE name = '$var'

If you use the LIKE operator and have a trailing %, that is telling mySQL to
match the first characters exactly and then match ANY trailing characters.
If you use the equals operator, then you are guaranteed an exact match. If
you are concerned about matching any case, then set both strings to UPPER
case then do the compare.

Jim Hunter



---Original Message---

From: Hutchins, Richard
Date: Wednesday, July 31, 2002 13:48:17
To: 'ron wallace'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] adding a space in mysql

I haven't set up any text-based searches before, but when you say:
snip
If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.
snip
Aren't you, in essence, saying that you want to search for Wash? Meaning
that your query could just say WHERE name = '$var' (where $var is set to
Wash)?

According to the MySql manual, the equal comparison operator works on
strings and numbers. But maybe text searches work differently than I thought
and it will return strings wherever the letter combination wash appears.
If that's the case I'm sure somebody will correct me and I'll learn
something in the process.

-Original Message-
From: ron wallace [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 4:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] adding a space in mysql


How can I add a space to the end of a varchar string
in mysql? I can't seem to do it directly, and I tried
str_pad and other things, but no luck so far. The db
doesnt hold the value of the space...its getting
trimmed somewhere(?)

The reason I want to do this is so I can search for
exact matches on one word strings without stemming:
WHERE name LIKE '$var %'.

If the user types 'Wash' I don't want any matches for
'Washington', 'Washing', etc.

Thank You All

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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

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

.


[PHP-DB] Re: adding a space in mysql

2002-07-31 Thread Dan Koken

Ron
I do believe that placing a space in '%$var %' will do the same as a 
varchar and sprip it off the end. Not positive. However I believe 
something like this will do the trick:
SELECT something
FROM a_file
WHERE replace(CONCAT_WS('','.',a_file.field,'.'),' ','.') LIKE '%.$var.%'
HTH... Dan

Ron Wallace wrote:
 How can I add a space to the end of a varchar string
 in mysql?  I can't seem to do it directly, and I tried
 str_pad and other things, but no luck so far.  The db
 doesnt hold the value of the space...its getting
 trimmed somewhere(?)
 
 The reason I want to do this is so I can search for
 exact matches on one word strings without stemming:
 ...WHERE name LIKE '$var %'.
 
 If the user types 'Wash' I don't want any matches for
 'Washington', 'Washing', etc.
 
 Thank You All
 
 __
 Do You Yahoo!?
 Yahoo! Health - Feel better, live better
 http://health.yahoo.com



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




[PHP-DB] Re: Benefits of assigning query to variable

2002-07-31 Thread Jas

sure there are, you can call the query in multiple places, for example:

$sql = mysql_query(INSERT INTO $table_name WHERE db_field =
$search_string);

Then say you have a routine to check for missing for elements and you would
like to log failed vs. successfull attempts your code flow would be
something like:

if (!$search_string  !$var02) {
$sql;
} else {
$sql; }
HTH
Jas

Brian Graham [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Are there any benefits to assigning a query to a variable?





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




[PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Adam Royle

Yes, I see a few benefits.

1. It makes the code easier to read.
2. It makes the code easier to debug.

Imagine the following:

$sql = SELECT * FROM tblName;
$result = mysql_query($sql);

Now if you want to print the sql and not do the select, you would simply add a line

$sql = SELECT * FROM tblName;
test($sql);
$result = mysql_query($sql);

where the function test is:

function test($var){
echo $var;
exit();
}

The benefits are more evident when you have bigger sql queries, such as:

$sql = INSERT INTO tblName SET
field1 = 'something1',
field2 = 'something2',
field3 = 'something3',
field4 = 'something4';

$result = mysql_query($sql);

Hope that answers your question.
Adam



[PHP-DB] adding a space in mysql

2002-07-31 Thread ron wallace

thanks, helpers, but I think I have a simple solution:
 I will insert a space at the front of the string,
where the db must accept and retain it.

BTW, here is the SQL I am working with:
//
elseif ($desc==desc) {
  $sql=SELECT bandid, bandname, bandesc, bin_id,
genre
  FROM bands, genre WHERE
(bands.genreid=genre.genreid) AND ;

  while (list($key, $word)=each($wordsarray)) 
//$wordsarray from textbox input
 { 
$sql=$sql.(bandname LIKE '$word %' OR 
 bandname LIKE '% $word %' OR 
 bandname LIKE '% $word' OR 
 bandesc LIKE '$word%' OR 
 bandesc LIKE '% $word %' OR 
 bandesc LIKE '% $word' OR 
 genre LIKE '$word%' OR 
 genre LIKE '% $word') AND ; 
  }
$sql=substr($sql, 0, (strlen($sql)-5));
$sql=$sql.  ORDER BY genre.genre ASC, bandname ASC;
   }
///
If I do bandname='$var' I would not hit the band 'Red
Letter Day' if the user jusr types 'red'.


__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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




[PHP-DB] Re: adding a space in mysql

2002-07-31 Thread Dan Koken



Ron Wallace wrote:
 thanks, helpers, but I think I have a simple solution:
  I will insert a space at the front of the string,
 where the db must accept and retain it.
 
 BTW, here is the SQL I am working with:
 //
 elseif ($desc==desc) {
   $sql=SELECT bandid, bandname, bandesc, bin_id,
 genre
   FROM bands, genre WHERE
 (bands.genreid=genre.genreid) AND ;
 
   while (list($key, $word)=each($wordsarray)) 
 //$wordsarray from textbox input
  { 
 $sql=$sql.(bandname LIKE '$word %' OR 
  bandname LIKE '% $word %' OR 
  bandname LIKE '% $word' OR 
  bandesc LIKE '$word%' OR 
  bandesc LIKE '% $word %' OR 
  bandesc LIKE '% $word' OR 
  genre LIKE '$word%' OR 
  genre LIKE '% $word') AND ; 
   }
 $sql=substr($sql, 0, (strlen($sql)-5));
 $sql=$sql.  ORDER BY genre.genre ASC, bandname ASC;
}
 ///
 If I do bandname='$var' I would not hit the band 'Red
 Letter Day' if the user jusr types 'red'.

Howerver if bandname was 'My name is Fred'
you will get a hit, because it is LIKE '$word%'
where Fred ends with 'red';


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




[PHP-DB] 2 groups of random result pls help...

2002-07-31 Thread rainydays_sunshine

Hi..

I need to get 2 groups of random result with 1 group always on top of the
other.
Can anyone help me with this please..

Something like

id|group|name
21john
51smith
32  1sara
12  1michael
12don
92beth
42bob


Thanks heaps..
imn




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




Re: [PHP-DB] Benefits of assigning query to variable

2002-07-31 Thread Gerard Samuel

Me personally, so I can echo out the variable to see if the query is 
making sense.  Look at it as a debugging...

Brian Graham wrote:

Are there any benefits to assigning a query to a variable?



  


-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/




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




[PHP-DB] RE: [PHP] Re: [PHP-DEV] [CROSS POST] PHP Meetup Texas PHP Users

2002-07-31 Thread Jay Blanchard

[snip]
First of all, sorry for the additional cross post. MeetUp.com lacks the
ability to let you contact other folks who have signed up. In my general
area, Massachusetts, there are a bunch of tiny groups scattered about,
and I'd like a chance to get all of them to converge in one place to make
the meetup worth it for all of us. I know there's only a few days before the
meetup is to take place, but if folks from the following areas could email
me, then we can try and work out somewhere we can all meet, instead of there
being 5 groups of 2 or 3 people.
[/snip]

Agreed Gabriel, meetup.com, while a nice idea, does not work well at all due
to the lack of contact information provided. But look what it may have
started!

I encourage PHP developers to seek each other and form their own groups. But
even the PHP lists barely scratch the surface of developers who are out
there. Contact other computer users groups in your area and you may be
surprised at what pops-up.

Jay

LOTTERY: A tax on people who are bad at math

***
* *
* Texas PHP Developers Meeting*
* Spring 2003 *
* T Bar M Resort  Conference Center  *
* New Braunfels, Texas*
* Interested? Contact;*
* [EMAIL PROTECTED] *
* *
***



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




Re: [PHP-DB] Re: Unified DB Query function

2002-07-31 Thread Manuel Lemos

Hello,

On 07/25/2002 04:35 PM, Andrew Hill wrote:
  Manual,
 
  Certainly - please help us pinpoint any issues.
 
  Dan Kalowsky has done some great work in resolving lingering ODBC issues
  in PHP, and I help in my way with testing and iODBC support.
 
  I respect the work you have done with Metabase, but it's a fallacy to
  suggest that ODBC is weak - some ODBC drivers are indeed week, but a
  proper driver provides more complete functionality than even native
  drivers, and is often faster.

Andrew you ought to try developing really portable Web applications with 
PHP using ODBC so you can understand better what I am talking.

The real problem is that ODBC was not meant for addressing specifically 
the actual needs of Web development.

The ODBC driver was the most frustrating driver that I developed for 
Metabase. The problem is that ODBC API does not expose enough 
information from the underlying database so Metabase could figure how to 
implement some abstracted features.

For instance, Metabase abstracts sequences. If the underlying database 
supports auto_increment fields, Metabase creates a separate table with a 
single auto_increment field to emulate a sequence. So far, so good. But 
how do I retrieve the last inserted number in a database independent 
way? Is it possible at all with ODBC API? Even if it is possible, I 
can't see support for the in ODBC API PHP functions.

Another issue is selecting specific ranges of result rows. Doing this 
efficiently depends a lot on the underlying database. In MySQL we use 
LIMIT. On MS-SQL I use server side cursors. Other database have special 
keywords that prevent hogging the server or the database connecting 
sending unnecessary query result data.

I know ODBC has several cursor models. Client side cursors are what 
Metabase ODBC uses already, but that is not as efficient as using 
specific database keywords. Even if I can use a server side cursor, how 
can I know with the current ODBC API PHP functions tell if the ODBC 
driver is capable of using such cursors? There doesn't seem to be a way 
to do it.

Another thing are transactions. How do I tell if the underlying ODBC 
driver supports transactions? I know you can know it in C calling the 
ODBC API but there is no support to tell that from PHP.

A major flop of ODBC PHP API are NULLs. How do I tell if a result set 
column has a NULL? It returns an empty string. How do I distinguish 
result set column empty string values from real NULLs? This needs to be 
fixed.

Other than that, there were problems with odbc_gettypeinfo() more than 
once in the same script. Depending when you would free the result set it 
was either crashing PHP or returning an empty result set. I don't know 
if this was fixed since PHP 4.0.6 but the problem existed and prevented 
Metabase ODBC driver to figure how to correctly create tables and using 
correctly certain types of fields like blobs.

There are probably other types of problems, but these are those that I 
remember immediately.

Anyway, so far, it seems that using ODBC with PHP is pretty useless 
especially to write portable database independent applications until 
these problems are addressed. Because of this I will need to develop 
ODBC sub-drivers for Metabase that are aware of database specific 
details that PHP ODBC support is uncapable of providing.

Regards,
Manuel Lemos


  -Original Message-
  From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, July 25, 2002 1:39 PM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] Re: Unified DB Query function
 
  Hello,
 
  On 07/25/2002 02:34 PM, Andrew Hill wrote:
 
 Pierre,
 
 Why not use ODBC functions everywhere?
 
 
  I already told you before. ODBC is very weak API for real database
  abstraction. To make it worse, PHP ODBC API is buggy and not as complete
 
  as it could be.
 
  As the maintainer of PHP ODBC support, if you are willing to do anything
 
  about it, I can help you to pin point the problems that need to be
  addressed. Otherwise it is quite pointless to even consider using ODBC
  in PHP unless it is your really alternative.
 
  Regards,
  Manuel Lemos
 
 
 
 Best regards,
 Andrew Hill
 Director of Technology Evangelism
 OpenLink Software  http://www.openlinksw.com
 Universal Data Access  Virtuoso Universal Server
 
 
 -Original Message-
 From: Pierre-Alain Joye [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 01, 2002 1:01 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] Re: Unified DB Query function
 
 On Mon, 01 Jul 2002 14:55:01 -0300
 Manuel Lemos [EMAIL PROTECTED] wrote:
 
 
 
 Hello,
 
 On 07/01/2002 06:46 AM, Casey Allen Shobe wrote:
 
 
 I'm trying to write a unified database query function for an
 
 application I
 
 
 have which currently accesses data from both DB2 and Microsoft SQL
 
 from a
 
 
 Linux server.  I'm using ODBC functions for DB2, and Sybase
 
 functions for
 
 
 Microsoft SQL.
 
 Why do you re-invent the wheeel and don't you use a 

Re: [PHP-DB] 2 groups of random result pls help...

2002-07-31 Thread leo g. divinagracia iii

did you mean you need help with an sql query for this?

sounds like

select id, group, name from MYTABLE order by group;

since i cant read your mind and you didnt specify anything else and since
this is a php-db mailing list, hope that's what you are asking for...  of
course i could me a mile off...



[EMAIL PROTECTED] wrote:

 Hi..

 I need to get 2 groups of random result with 1 group always on top of the
 other.
 Can anyone help me with this please..

 Something like

 id|group|name
 21john
 51smith
 32  1sara
 12  1michael
 12don
 92beth
 42bob



--
Leo G. Divinagracia III
[EMAIL PROTECTED]



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