php-general Digest 2 Jul 2007 12:14:09 -0000 Issue 4880

2007-07-02 Thread php-general-digest-help

php-general Digest 2 Jul 2007 12:14:09 - Issue 4880

Topics (messages 258025 through 258028):

Re: Selecting Rows Based on Row Values Being in Array
258025 by: Jim Lucas

Re: Anybody had luck compiling memcache with php6 ?
258026 by: M. Sokolewicz
258027 by: Stut

Re: mail function problem
258028 by: web2.get-telecom.fr

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---

kvigor wrote:

Jim,

Please excuse the ignorance, I'm a newbie, but I'm only use to simple 
SELECT, INSERT statements.



Your original code: $SQL = SELECT * FROM my_Table WHERE CONCAT(value1, 
value2, value3) IN ('.join(',', $list).')


This can be broken down into smaller parts so to explain by example.

# This is to clean the input values for the SQL statement
function mysql_clean($value) {
return mysql_real_escape_string($value);
}

# Define your list of values to compare to
$list = array(
'6blue40lbs',
'7orange50lbs',
'8orange60lbs',
'9purple70lbs',
);

# You will want to do something like this with the values of the $list
# array just to make sure they are clean: reference the function above
array_walk($list, 'mysql_clean');

# This will return a string formated like this.
# '6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs'
$IN_VALUE = '.join(',', $list).';

$SQL = SELECT *
FROMmy_Table
WHERE   CONCAT(value1, value2, value3)
IN ({$IN_VALUE});

# The final query string will look like this
SELECT  *
FROMmy_Table
WHERE   CONCAT(value1, value2, value3)
IN ('6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs')

# Now run this through your query function and get the results
$results = mysql_query($SQL) OR die('SQL Failure: '.$SQL);

So basically what we have is a comparison that is based off the output 
of the CONCAT() function that creates one string out of value1, value2, 
value3 and then compares that with each of the values listed within the 
parenthesis.  the IN (...) part of the SQL statement tells SQL that it 
is getting a list of values that it should compare the concat() value 
against.


Doing it this way, will allow you to only run one query instead of 
running one per value that you want to compare against.  As you can 
tell, as your data set grows your multiple queries would drag your DB to 
a halt


Hope this explains it.

Let me know if you need further explanation.



OK, I get everything up to  the ('''.join(''','''$list).''')
I'm guessing that the .join( ). putting together some values, but I don't 
know what
also the .join( ). is to be preceded by something... I don't know what. 
//Forgive my ignorance, I'll can get it.


Also the .join( ). what is this doing I looked at the PHP and MySQL function 
of each, and haven't seen comparable code.


I'm asking because I don't know where we're telling the code to compare the 
values.


You stated...

and create one string from them

Where do I give the name to the string?

So this is where I am so far:

$sql = SELECT* FROM table WHERE CONCAT(size,color,weight) IN( );


Jim Lucas [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

K. Hayes wrote:

Will do.  Thanks.


- Original Message - From: Jim Lucas [EMAIL PROTECTED]
To: kvigor [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, June 30, 2007 1:46 AM
Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array



kvigor wrote:

Hello All,

I'm attempting to return rows from a mysql DB based on this criteria:

I have a list, in the form of an array that I need to compare against 
each row

in the table.  Where theres a match I need that entire row returned.

e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
8orange60lbs, 9purple70lbs);


The array contains 3 of the db row fields in 1 value. However there are 
10 fields/columns in the table.


===
what table looks like  |
===
  size   colorweight
ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |

So how could I set up a query that would SELECT the entire row, if the 
row contained $varListof 3outOf_10Fields[1].


Open to any suggestions or work arounds.  I'm playing with extract() 
but code is too crude to even post.


I would suggest approaching the problem with a slightly different 
thought.


just have the sql concat() the columns together and then compare.

something like this should do the trick

$list = array(
'6blue40lbs',
'7orange50lbs',
'8orange60lbs',
'9purple70lbs',
);

$SQL = 
SELECT *
FROM my_Table
WHERE CONCAT(value1, value2, value3) IN ('.join(',', $list).')
;

mysql_query($SQL);

this should take, for each row in the DB, value1 

Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-02 Thread Jim Lucas

kvigor wrote:

Jim,

Please excuse the ignorance, I'm a newbie, but I'm only use to simple 
SELECT, INSERT statements.



Your original code: $SQL = SELECT * FROM my_Table WHERE CONCAT(value1, 
value2, value3) IN ('.join(',', $list).')


This can be broken down into smaller parts so to explain by example.

# This is to clean the input values for the SQL statement
function mysql_clean($value) {
return mysql_real_escape_string($value);
}

# Define your list of values to compare to
$list = array(
'6blue40lbs',
'7orange50lbs',
'8orange60lbs',
'9purple70lbs',
);

# You will want to do something like this with the values of the $list
# array just to make sure they are clean: reference the function above
array_walk($list, 'mysql_clean');

# This will return a string formated like this.
# '6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs'
$IN_VALUE = '.join(',', $list).';

$SQL = SELECT *
FROMmy_Table
WHERE   CONCAT(value1, value2, value3)
IN ({$IN_VALUE});

# The final query string will look like this
SELECT  *
FROMmy_Table
WHERE   CONCAT(value1, value2, value3)
IN ('6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs')

# Now run this through your query function and get the results
$results = mysql_query($SQL) OR die('SQL Failure: '.$SQL);

So basically what we have is a comparison that is based off the output 
of the CONCAT() function that creates one string out of value1, value2, 
value3 and then compares that with each of the values listed within the 
parenthesis.  the IN (...) part of the SQL statement tells SQL that it 
is getting a list of values that it should compare the concat() value 
against.


Doing it this way, will allow you to only run one query instead of 
running one per value that you want to compare against.  As you can 
tell, as your data set grows your multiple queries would drag your DB to 
a halt


Hope this explains it.

Let me know if you need further explanation.



OK, I get everything up to  the ('''.join(''','''$list).''')
I'm guessing that the .join( ). putting together some values, but I don't 
know what
also the .join( ). is to be preceded by something... I don't know what. 
//Forgive my ignorance, I'll can get it.


Also the .join( ). what is this doing I looked at the PHP and MySQL function 
of each, and haven't seen comparable code.


I'm asking because I don't know where we're telling the code to compare the 
values.


You stated...

and create one string from them

Where do I give the name to the string?

So this is where I am so far:

$sql = SELECT* FROM table WHERE CONCAT(size,color,weight) IN( );


Jim Lucas [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

K. Hayes wrote:

Will do.  Thanks.


- Original Message - From: Jim Lucas [EMAIL PROTECTED]
To: kvigor [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Saturday, June 30, 2007 1:46 AM
Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array



kvigor wrote:

Hello All,

I'm attempting to return rows from a mysql DB based on this criteria:

I have a list, in the form of an array that I need to compare against 
each row

in the table.  Where theres a match I need that entire row returned.

e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
8orange60lbs, 9purple70lbs);


The array contains 3 of the db row fields in 1 value. However there are 
10 fields/columns in the table.


===
what table looks like  |
===
  size   colorweight
ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |

So how could I set up a query that would SELECT the entire row, if the 
row contained $varListof 3outOf_10Fields[1].


Open to any suggestions or work arounds.  I'm playing with extract() 
but code is too crude to even post.


I would suggest approaching the problem with a slightly different 
thought.


just have the sql concat() the columns together and then compare.

something like this should do the trick

$list = array(
'6blue40lbs',
'7orange50lbs',
'8orange60lbs',
'9purple70lbs',
);

$SQL = 
SELECT *
FROM my_Table
WHERE CONCAT(value1, value2, value3) IN ('.join(',', $list).')
;

mysql_query($SQL);

this should take, for each row in the DB, value1 + value2 + value3 and 
create one string from them, then it will compare each string in the

IN (...)  portion to each entry in the $list array().

Let me know if you need any further help
one other thing, make sure that you run each of the values in the $list 
array() through mysql_real_escape_string().  That way it is all nicely 
encoded for the SQL statement. 




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



[PHP] Re: Anybody had luck compiling memcache with php6 ?

2007-07-02 Thread M. Sokolewicz
PHP 6 is about as broken as can be, and buggy as hell... why would you 
even want to compile it? or extensions for it...?


- Tul

Cathy Murphy wrote:

I am trying to compile memcache 2.1.2 with php6 , but getting errors .
Anybody had luck with this?

Thanks,
Cathy
www.nachofoto.com



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



Re: [PHP] Re: Anybody had luck compiling memcache with php6 ?

2007-07-02 Thread Stut

M. Sokolewicz wrote:
PHP 6 is about as broken as can be, and buggy as hell... why would you 
even want to compile it? or extensions for it...?


1) To help out the developers by testing it

2) To test a project against the next major version

3) For funzies! ;)

Cathy: You might have better luck by contacting the maintainer of that 
extension. Failing that the internals list may be able to help, but that 
should be a last resort.


-Stut

--
http://stut.net/


Cathy Murphy wrote:

I am trying to compile memcache 2.1.2 with php6 , but getting errors .
Anybody had luck with this?

Thanks,
Cathy
www.nachofoto.com



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



Re: [PHP] mail function problem

2007-07-02 Thread web2

I've already checked :

- the mail logs : no mail send

- and the apache error and access logs : nothing except this :

192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET /~ee/mail.php 
HTTP/1.1 200 49291 - Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; 
rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET 
/~ee/mail.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200 
2524 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows; 
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET 
/~ee/mail.php?=SUHO8567F54-D428-14d2-A769-00DA302A5F18 HTTP/1.1 200 
2813 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows; 
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET 
/~ee/mail.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200 
2146 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows; 
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4




Chris a écrit :

[EMAIL PROTECTED] wrote:

Hi,

I'm running PHP 5.2.3 on Solaris 10 (AMD64).

My mail function doesn't send any mail, the return value of mail 
function is false...
But sendmail_path value is OK in php.ini, and I've tried to send a 
mail with sendmail on console with the same user (the apache user), 
and everything's ok...


Does anyone have solution ?


Check your mail logs and your apache logs to see if any errors are 
showing up.




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



Re: [PHP] Date Calculation Help

2007-07-02 Thread Fredrik Thunberg

$q = ceil( month / 4 );

--
/Thunis

The ships hung in the sky in much the same way that bricks don't.
  --The Hitchikers Guide to the Galaxy

revDAVE skrev:

I have segmented a year into four quarters (3 months each)

nowdate = the month of the chosen date (ex: 5-30-07 = month 5)

Q: What is the best way to calculate which quarter  (1-2-3 or 4) the chosen
date falls on?

Result - Ex: 5-30-07 = month 5 and should fall in quarter 2



--
Thanks - RevDave
[EMAIL PROTECTED]
[db-lists]



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



[PHP] need help

2007-07-02 Thread Muhammad Hassan Samee

hay
i m a C++ programmer and new to web development with basic knowledge of
HTML, CSS and j.script now i want to start learning PHP anybody can direct
me to some good/fast track tutorials \ books  for getting start


Re: [PHP] Date Calculation Help

2007-07-02 Thread Fredrik Thunberg

of course ceil( month / 3 );

--
/Thunis

Don't panic.
  --The Hitchikers Guide to the Galaxy

Fredrik Thunberg skrev:

$q = ceil( month / 4 );



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



Re: [PHP] need help

2007-07-02 Thread Davide Bernard
I've found http://php.net/ to be very helpful. Especially in
troubleshooting.

 Muhammad Hassan Samee [EMAIL PROTECTED] 7/2/2007 8:38 AM

hay
i m a C++ programmer and new to web development with basic knowledge
of
HTML, CSS and j.script now i want to start learning PHP anybody can
direct
me to some good/fast track tutorials \ books  for getting start

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



Re: [PHP] mail function problem

2007-07-02 Thread Daniel Brown

On 7/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

I've already checked :

- the mail logs : no mail send

- and the apache error and access logs : nothing except this :

192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET /~ee/mail.php
HTTP/1.1 200 49291 - Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;
rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
2524 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=SUHO8567F54-D428-14d2-A769-00DA302A5F18 HTTP/1.1 200
2813 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
2146 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4



Chris a écrit :
 [EMAIL PROTECTED] wrote:
 Hi,

 I'm running PHP 5.2.3 on Solaris 10 (AMD64).

 My mail function doesn't send any mail, the return value of mail
 function is false...
 But sendmail_path value is OK in php.ini, and I've tried to send a
 mail with sendmail on console with the same user (the apache user),
 and everything's ok...

 Does anyone have solution ?

 Check your mail logs and your apache logs to see if any errors are
 showing up.


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




   Is it possible for you to provide your code so that we can take a
look at it for you?

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] need help

2007-07-02 Thread Mohamed Yusuf

checkout this site http://www.w3schools.com/php/default.asp

On 7/2/07, Davide Bernard [EMAIL PROTECTED] wrote:


I've found http://php.net/ to be very helpful. Especially in
troubleshooting.

 Muhammad Hassan Samee [EMAIL PROTECTED] 7/2/2007 8:38 AM

hay
i m a C++ programmer and new to web development with basic knowledge
of
HTML, CSS and j.script now i want to start learning PHP anybody can
direct
me to some good/fast track tutorials \ books  for getting start

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




[PHP] calling parent class method from the outside

2007-07-02 Thread admin

Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj-foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;

Some contrived example to illustrate the point:

class AParent {
  public function foo() { .. }
}

class A extends AParent {
  public function foo() {
doit($this, __CLASS__, __FUNCTION__);
  }
}

function doit($obj, $classname, $funcname) {
  if (...)
//$obj-classname_parent::$funcname();
}


Thanks.

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



Re: [PHP] need help

2007-07-02 Thread Sancar Saran
On Monday 02 July 2007 16:38:10 Muhammad Hassan Samee wrote:
 hay
 i m a C++ programmer and new to web development with basic knowledge of
 HTML, CSS and j.script now i want to start learning PHP anybody can direct
 me to some good/fast track tutorials \ books  for getting start

Hi,

good/fast track tutorials \ books are isn't. Because you haven't got any HTML, 
CSS and Js background. Php was very easy to use (even I can use it) and in 
this situation handling php was minor problem (because of your programming 
background) 

And dealing HTML CSS and JS issues requires knowladge(lots of). Because you 
are going to mix up 3 different language (wich all of them having serious 
problems with different OS,Browsers,Versions etc) with using php glue.

Also having good html design capability is beyond the language knowladge.

www.webmonkey.com, www.sitepoint.com, www.phpbuilder.net are good point to 
start.

Also 

Beatiful web design one of the best webs site design books also this kind of 
books wery hard to find (because most of them try to teach you html tag by 
tag).

You may look some other photoshop books for generating images. 

And of course practice makes perfect

Regards

Sancar

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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread Jochem Maas
admin wrote:
 Inside the body of method foo() you can of course use syntax like
 parent::foo(). But is there a way to call the parent version of
 obj-foo() outside the class? That kind of syntax is allowed in C++, for
 example: Aclass a; if (a.Aparent::foo()) ...;

there is nothing in the language that provides this functionality
and I would argue that the caller should be able to do such things ...
the object should be in control of the functionality it provides not the user.

hmm, I don't think I explained that very well - I'm having a bit of a
brain freeze ...

if you need to expose parent::foo() via a subclass then you shouldn't
override it in the subclass but rather create a foo2() (for instance)

 
 Some contrived example to illustrate the point:
 
 class AParent {
   public function foo() { .. }
 }
 
 class A extends AParent {
   public function foo() {
 doit($this, __CLASS__, __FUNCTION__);
   }
 }
 
 function doit($obj, $classname, $funcname) {
   if (...)
 //$obj-classname_parent::$funcname();
 }
 
 
 Thanks.
 

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



Re: [PHP] mail function problem

2007-07-02 Thread web2

Daniel Brown a écrit :

On 7/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

I've already checked :

- the mail logs : no mail send

- and the apache error and access logs : nothing except this :

192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET /~ee/mail.php
HTTP/1.1 200 49291 - Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;
rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
2524 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=SUHO8567F54-D428-14d2-A769-00DA302A5F18 HTTP/1.1 200
2813 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
/~ee/mail.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
2146 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4



Chris a écrit :
 [EMAIL PROTECTED] wrote:
 Hi,

 I'm running PHP 5.2.3 on Solaris 10 (AMD64).

 My mail function doesn't send any mail, the return value of mail
 function is false...
 But sendmail_path value is OK in php.ini, and I've tried to send a
 mail with sendmail on console with the same user (the apache user),
 and everything's ok...

 Does anyone have solution ?

 Check your mail logs and your apache logs to see if any errors are
 showing up.


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




   Is it possible for you to provide your code so that we can take a
look at it for you?



Yes, my PHP test code is :

?
ini_set(display_errors, true);
ini_set(error_reporting, E_ALL);
$Email=[EMAIL PROTECTED];
$headers = From:  . $Email . \r\nX-Mailer: PHP/ . phpversion();
if ( mail([EMAIL PROTECTED] , essai , test, $headers) )
echo OK : .ini_get('sendmail_path');
else
echo NOK : .ini_get('sendmail_path');
?

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



[PHP] Re: calling parent class method from the outside

2007-07-02 Thread Colin Guthrie
admin wrote:
 Inside the body of method foo() you can of course use syntax like
 parent::foo(). But is there a way to call the parent version of
 obj-foo() outside the class? That kind of syntax is allowed in C++, for
 example: Aclass a; if (a.Aparent::foo()) ...;
 
 Some contrived example to illustrate the point:
 
 class AParent {
   public function foo() { .. }
 }
 
 class A extends AParent {
   public function foo() {
 doit($this, __CLASS__, __FUNCTION__);
   }
 }
 
 function doit($obj, $classname, $funcname) {
   if (...)
 //$obj-classname_parent::$funcname();
 }
 
 
 Thanks.


I agree with Jochem that if you find you need to do this, then you're
probably not designing the code correctly.

There are a few options in my mind that you can potentially use
depending on what you're actually doing:

1. Don't overload the function in A at all. Then you call $obj-foo(),
it will be the parent method that is called.

2. If you have a large chunk of code in the parent and you don't want to
reimplement it in the child as it's only slightly different, break up
the functionality into a Protected method:

Class AParent {
protected function foo_() {
 
}
public function foo() {
 return $this-foo_()
}
}

class A extends AParent {
public function foo() {
  $something = 'a bit different';
  return $this-foo_();
}


3. Sometimes a neater version of the above can be used if you only ever
extend something:
Class AParent {
public function foo() {
 
}
}

class A extends AParent {
public function foo() {
  $something = 'a bit different';
  return parent::foo();
}


HTHs

Col

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



[PHP] Re: need help

2007-07-02 Thread Colin Guthrie
Sancar Saran wrote:
 Beatiful web design one of the best webs site design books also this kind 
 of 
 books wery hard to find (because most of them try to teach you html tag by 
 tag).
 
 You may look some other photoshop books for generating images. 
 
 And of course practice makes perfect

As a programmer you may think like I do, in that you like examples
rather than language theory.

In this respect and for the HTML/CSS part (I agree with Sancar that as a
C++ programmer you probably wont struggle with PHP itself), I find
www.csszengarden.com a great please for insipration and clean HTML
design. I would say that you have to watch out as some people do take
things a little far with their CSS and do some odd things make it fit
the fixed HTML available.

Col.

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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread Richard Heyes

admin wrote:

Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj-foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;


Not sure I get your requirement exactly, but you could try this:

class A
{
public function foo ()
{
// ...
}
}

class B {
public parent;

// Constructor
public function __construct ()
{
$this-parent = new A();
}
}


// And then...

$b = new B();
$b-parent-foo();

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk
Currently looking for partnerships

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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread Jim Lucas

admin wrote:

Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj-foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;

Some contrived example to illustrate the point:

class AParent {
  public function foo() { .. }
}

class A extends AParent {
  public function foo() {
doit($this, __CLASS__, __FUNCTION__);
  }
}

function doit($obj, $classname, $funcname) {
  if (...)
//$obj-classname_parent::$funcname();
}


Thanks.



To use Richards example, but with a little different twist for accessing the 
parent methods/properties

class A
{
public __construct()
{
// ...
}
public function foo ()
{
// ...
}
}

class B extends A {
// Constructor
public function __construct ()
{
parent::__construct();
}
}


// And then...

$b = new B();
$b-foo();


This will bring all methods/properties from class A into class B.

You can choose to override class A methods/properties when you define class B.
But the idea here is that only need to write the methods/properties once in the 
parent class,
then you can extend your class with class A and have all the methods/properties 
available to you
within your current class.

It is good to practice the DRY principle here.



Note: Richard Heyes thanks for the code snippet



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] mail function problem

2007-07-02 Thread Daniel Brown

On 7/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Daniel Brown a écrit :
 On 7/2/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I've already checked :

 - the mail logs : no mail send

 - and the apache error and access logs : nothing except this :

 192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET /~ee/mail.php
 HTTP/1.1 200 49291 - Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;
 rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
 192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
 /~ee/mail.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
 2524 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
 U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
 192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
 /~ee/mail.php?=SUHO8567F54-D428-14d2-A769-00DA302A5F18 HTTP/1.1 200
 2813 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
 U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
 192.168.0.1 - - [02/Jul/2007:14:07:22 +0200] GET
 /~ee/mail.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1 200
 2146 http://mysite.domain.do/~ee/mail.php; Mozilla/5.0 (Windows;
 U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4



 Chris a écrit :
  [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm running PHP 5.2.3 on Solaris 10 (AMD64).
 
  My mail function doesn't send any mail, the return value of mail
  function is false...
  But sendmail_path value is OK in php.ini, and I've tried to send a
  mail with sendmail on console with the same user (the apache user),
  and everything's ok...
 
  Does anyone have solution ?
 
  Check your mail logs and your apache logs to see if any errors are
  showing up.
 

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



Is it possible for you to provide your code so that we can take a
 look at it for you?


Yes, my PHP test code is :

?
ini_set(display_errors, true);
ini_set(error_reporting, E_ALL);
$Email=[EMAIL PROTECTED];
$headers = From:  . $Email . \r\nX-Mailer: PHP/ . phpversion();
if ( mail([EMAIL PROTECTED] , essai , test, $headers) )
echo OK : .ini_get('sendmail_path');
else
echo NOK : .ini_get('sendmail_path');
?



Try this:
?
$email = [EMAIL PROTECTED];
$headers  = From: .$email.\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;
if(mail([EMAIL PROTECTED],essai,test,$headers)) {
   echo OK: .ini_get('sendmail_path');
} else {
   echo NOK: .ini_get('sendmail_path');
}
?

   Note

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] mail function problem

2007-07-02 Thread Daniel Brown

On 7/2/07, Daniel Brown [EMAIL PROTECTED] wrote:
{snip}

Note


   Sorry, hit the button before I was done typing.

   Note the trailing \r\n after the X-Mailer line as well.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



[PHP] PHP vs Delphi Comparison?

2007-07-02 Thread Dan
I'm looking for a way to introduce PHP to some Delphi programmers, so I 
thought a comparison would show them the major differences, but I can't find 
anything like that on the web.  Anyone have an article like that or know of 
one?


- Dan 


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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread Jochem Maas
Jim Lucas wrote:
 admin wrote:
 Inside the body of method foo() you can of course use syntax like
 parent::foo(). But is there a way to call the parent version of
 obj-foo() outside the class? That kind of syntax is allowed in C++, for
 example: Aclass a; if (a.Aparent::foo()) ...;

 Some contrived example to illustrate the point:

 class AParent {
   public function foo() { .. }
 }

 class A extends AParent {
   public function foo() {
 doit($this, __CLASS__, __FUNCTION__);
   }
 }

 function doit($obj, $classname, $funcname) {
   if (...)
 //$obj-classname_parent::$funcname();
 }


 Thanks.

 
 To use Richards example, but with a little different twist for accessing
 the parent methods/properties
 
 class A
 {
 public __construct()
 {
 // ...
 }
 public function foo ()
 {
 // ...
 }
 }
 
 class B extends A {
 // Constructor
 public function __construct ()
 {
 parent::__construct();
 }
 }
 
 
 // And then...
 
 $b = new B();
 $b-foo();
 
 
 This will bring all methods/properties from class A into class B.

both methods  properties of the parent (class A) are available assuming they
are public or protected - if you don't call the parent ctor the only
thing your missing is whatever initialization of data and/or property values 
(etc)
would have been done by the parent ctor.

class A {
public function foo() {echo achoo;}
}
class B extends A {}

$b = new B;
$b-foo();

it is quite normal to call parent::__construct(); in the subclass' ctor but it's
not required to make methods/properties available and I don't see what baring
it has on the OP's question.

another solution for the OP might be (although I think it goes against all
design principles):

class A {
  function foo() {
echo achoo\n;
  }
}

class B extends A {
  function foo() {
echo cough\n;
  }
  function __call($meth, $args) {
$func = array(parent, strtolower(str_replace(parent,, $meth)));
if (is_callable($func))
  return call_user_func_array($func, $args);
  }
}

$b = new B;
$b-foo();
$b-parentFoo();

 
 You can choose to override class A methods/properties when you define
 class B.
 But the idea here is that only need to write the methods/properties once
 in the parent class,
 then you can extend your class with class A and have all the
 methods/properties available to you
 within your current class.
 
 It is good to practice the DRY principle here.
 
 
 
 Note: Richard Heyes thanks for the code snippet
 
 
 

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



[PHP] Re: calling parent class method from the outside

2007-07-02 Thread admin

Colin Guthrie wrote:

admin wrote:

Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj-foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;


[snipped]


I agree with Jochem that if you find you need to do this, then you're
probably not designing the code correctly.



OK, here we go: Propel in Symfony uses generated model classes
representing DB rows, stub classes inheriting from them ready to be used
(such as below), and accessors representing data columns:

class Foo extends BaseFoo
{
public function setBar($value)
{
$this-doSetColumn(FooPeer::BAR, $value, __FUNCTION__);
}

public function setBaz($value)
{
$this-doSetColumn(FooPeer::BAZ, $value, __FUNCTION__);
}

public function setXyzzy($value)
{
$this-doSetColumn(FooPeer::XYZZY, $value, __FUNCTION__);
}

// several more of these, and finally...

private function doSetColumn($colname, $value, $col_mutator)
{
/* setter does what it has to do and calls the parent
 * version of self to do the real work of modifying
 * state
 */
// ...
if ($something)
parent::$col_mutator($junk_to_trigger_modified);
// ...

parent::$col_mutator($value);
}
}

There are several models (tables) such as Foo, and they all have the
same body of doSetColumn(), so a logical next step was to factor that
method away _and_ leave most of the code intact, in which I've failed.

Once again, calling the parent version of a method externally is
allowed in C++ (and whoever said it was bad design should speak up to
Bjarne Stroustrup ;-)) Any such trick in PHP?

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



[PHP] Replace/Update record in dbase using dbase_replace_record()

2007-07-02 Thread Rahul Sitaram Johari

Ave,

Can¹t figure this one out. I¹m using the dbase_replace_record() function to
replace a record in a dbase (.dbf) database. I just want to replace the
value of one of the fields with another value. This is my code:

$db = dbase_open(CRUMBS.DBF, 2) or die(Fatal Error: Could not open
database!);
if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i = $record_numbers; $i++) {
 $row = dbase_get_record_with_names($db, $i);
 if ($row['PHONE'] == $thekey) {
  print_r($row);
  $row['A'] == F;
  dbase_replace_record($db, $row, 1);
}
  }
}
dbase_close($db);

Basically I have a database called ³CRUMBS.DBF², and the record where PHONE
= $thekey, I want to replace the value of the field ³A² with ³F². I keep
getting the error: ³Wrong number of fields specified².
I have over 60 fields in each row ­ and I just want to replace the value of
the field ³A². 

Any suggestions?

~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²



Re: [PHP] Re: calling parent class method from the outside

2007-07-02 Thread Jim Lucas

admin wrote:

Colin Guthrie wrote:

admin wrote:

Inside the body of method foo() you can of course use syntax like
parent::foo(). But is there a way to call the parent version of
obj-foo() outside the class? That kind of syntax is allowed in C++, for
example: Aclass a; if (a.Aparent::foo()) ...;


[snipped]


I agree with Jochem that if you find you need to do this, then you're
probably not designing the code correctly.



OK, here we go: Propel in Symfony uses generated model classes
representing DB rows, stub classes inheriting from them ready to be used
(such as below), and accessors representing data columns:

class Foo extends BaseFoo
{
public function setBar($value)
{
$this-doSetColumn(FooPeer::BAR, $value, __FUNCTION__);
}

public function setBaz($value)
{
$this-doSetColumn(FooPeer::BAZ, $value, __FUNCTION__);
}

public function setXyzzy($value)
{
$this-doSetColumn(FooPeer::XYZZY, $value, __FUNCTION__);
}

// several more of these, and finally...

private function doSetColumn($colname, $value, $col_mutator)
{
/* setter does what it has to do and calls the parent
 * version of self to do the real work of modifying
 * state
 */
// ...
if ($something)

What are you wanting to test for?


parent::$col_mutator($junk_to_trigger_modified);

does this setup the next call to $col_mutator() ?  when you pass the value?


// ...

parent::$col_mutator($value);
}
}

There are several models (tables) such as Foo, and they all have the
same body of doSetColumn(), so a logical next step was to factor that
method away _and_ leave most of the code intact, in which I've failed.

Once again, calling the parent version of a method externally is
allowed in C++ (and whoever said it was bad design should speak up to
Bjarne Stroustrup ;-)) Any such trick in PHP?



This is a little different then what you are trying above, but maybe it is close to what you are 
looking for:


?php
class FooPeer {
function BAR() {
return 'BAR';
}
function BAZ() {
return 'BAZ';
}
function XYZZY() {
return 'XYZZY';
}
}
class BaseFoo {
function setBar($value) {
echo BaseFoo::setBar({$value});\n;
}

function setBaz($value) {
echo BaseFoo::setBaz({$value});\n;
}

function setXyzzy($value) {
echo BaseFoo::setXyzzy({$value});\n;
}

}
class Foo extends BaseFoo {
function setBar($value) {
$this-doSetColumn(FooPeer::BAR(), $value, __FUNCTION__);
}

function setBaz($value) {
$this-doSetColumn(FooPeer::BAZ(), $value, __FUNCTION__);
}

function setXyzzy($value) {
$this-doSetColumn(FooPeer::XYZZY(), $value, __FUNCTION__);
}

function doSetColumn($colname, $value, $col_mutator) {
parent::$col_mutator($value);
}
}

$Foo = new Foo();
echo pre;
$Foo-setBar('my value for bar');
$Foo-setBaz('my value for baz');
$Foo-setXyzzy('my value for xyzzy');





--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Re: calling parent class method from the outside

2007-07-02 Thread Rihad

Jim Lucas wrote:

admin wrote:

OK, here we go: Propel in Symfony uses generated model classes
representing DB rows, stub classes inheriting from them ready to be used
(such as below), and accessors representing data columns:


[snipped]
This is a little different then what you are trying above, but maybe it 
is close to what you are looking for:


?php
class FooPeer {
function BAR() {
return 'BAR';
}
function BAZ() {
return 'BAZ';
}
function XYZZY() {
return 'XYZZY';
}
}
class BaseFoo {
function setBar($value) {
echo BaseFoo::setBar({$value});\n;
}

function setBaz($value) {
echo BaseFoo::setBaz({$value});\n;
}

function setXyzzy($value) {
echo BaseFoo::setXyzzy({$value});\n;
}

}
class Foo extends BaseFoo {
function setBar($value) {
$this-doSetColumn(FooPeer::BAR(), $value, __FUNCTION__);
}

function setBaz($value) {
$this-doSetColumn(FooPeer::BAZ(), $value, __FUNCTION__);
}

function setXyzzy($value) {
$this-doSetColumn(FooPeer::XYZZY(), $value, __FUNCTION__);
}

function doSetColumn($colname, $value, $col_mutator) {
parent::$col_mutator($value);
}
}

$Foo = new Foo();
echo pre;
$Foo-setBar('my value for bar');
$Foo-setBaz('my value for baz');
$Foo-setXyzzy('my value for xyzzy');



Now will you mentally copy and paste the above code several times, doing 
the necessary text substitutions, what will you get? Three identical 
copies of doSetColumn() in each class! And the real doSetColumn() is a 
bit heavier than a one-liner. We come full circle.


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



[PHP] Re: simple OCR in php

2007-07-02 Thread Zeb Packard

Linux journal had an article for tesseract

code.google.com/p/tesseract-ocr

the files needed to be cleaned up first though (contrast black text
against white background), so understanding gimp or some other equally
functional command-line image editor is essential. Suggested
alternative was netpbm.sourceforge.net for image editing and for OCR
the alternative was ocrad. It was suggested that the images be scanned
in at 150dpi or greater.

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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread admin

Jochem Maas wrote:

another solution for the OP might be (although I think it goes against all
design principles):

class A {
  function foo() {
echo achoo\n;
  }
}

class B extends A {
  function foo() {
echo cough\n;
  }
  function __call($meth, $args) {
$func = array(parent, strtolower(str_replace(parent,, $meth)));
if (is_callable($func))
  return call_user_func_array($func, $args);
  }
}

$b = new B;
$b-foo();
$b-parentFoo();



Barring the s/parent/get_parent_class/ the idea is really really cute, 
thanks. Beautiful. Heck, maybe I'll even hack the code to do it like 
that... after some grace period.


P.S.: I thought calling array('classname', 'method') only worked for 
static methods? It turns out there's an implied $this being passed around?


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



Re: [PHP] Re: calling parent class method from the outside

2007-07-02 Thread Jim Lucas

Rihad wrote:


Now will you mentally copy and paste the above code several times, doing 
the necessary text substitutions, what will you get? Three identical 
copies of doSetColumn() in each class! And the real doSetColumn() is a 
bit heavier than a one-liner. We come full circle.




I don't understand, which part(s) are you copying multiple times?  Foo, 
FooBase, all the above...

if you are talking about having multiple Foo classes with one common FooBase class for each that 
they all inherit then it would be simple, move soSetColumn() to the FooBase class.


Maybe this?

?php
class FooPeer {
function BAR() {
return 'BAR';
}
function BAZ() {
return 'BAZ';
}
function XYZZY() {
return 'XYZZY';
}
}
class BaseFoo {
function setBar($colname, $value) {
echo BaseFoo::setBar({$colname}, {$value});\n;
}
function setBaz($colname, $value) {
echo BaseFoo::setBaz({$colname}, {$value});\n;
}
function setXyzzy($colname, $value) {
echo BaseFoo::setXyzzy({$colname}, {$value});\n;
}
function doSetColumn($colname, $value, $col_mutator) {
BaseFoo::$col_mutator($colname, $value);
}
}
class Foo1 extends BaseFoo {
function setBar($value) {
$this-doSetColumn(FooPeer::BAR(), $value, __FUNCTION__);
}
function setBaz($value) {
$this-doSetColumn(FooPeer::BAZ(), $value, __FUNCTION__);
}
function setXyzzy($value) {
$this-doSetColumn(FooPeer::XYZZY(), $value, __FUNCTION__);
}
}
class Foo2 extends BaseFoo {
function setBar($value) {
$this-doSetColumn(FooPeer::BAR(), $value, __FUNCTION__);
}
function setBaz($value) {
$this-doSetColumn(FooPeer::BAZ(), $value, __FUNCTION__);
}
function setXyzzy($value) {
$this-doSetColumn(FooPeer::XYZZY(), $value, __FUNCTION__);
}
}

echo pre;

$Foo1 = new Foo1();
$Foo1-setBar('my value for bar');
$Foo1-setBaz('my value for baz');
$Foo1-setXyzzy('my value for xyzzy');

$Foo2 = new Foo2();
$Foo2-setBar('my value for bar');
$Foo2-setBaz('my value for baz');
$Foo2-setXyzzy('my value for xyzzy');


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] Re: calling parent class method from the outside

2007-07-02 Thread Colin Guthrie
admin wrote:
 Once again, calling the parent version of a method externally is
 allowed in C++ (and whoever said it was bad design should speak up to
 Bjarne Stroustrup ;-)) Any such trick in PHP?

I stand suitably corrected :)

I didn't realise you could do that in C++ to be honest. I'm trying to
think of a use of this feature in my many C++ programs but can't think
of a practical use of such a feature. I guess I'll have to think
differently when designing things but I can't help but think that one of
the major advantages of deriving classes is the extension and
abstraction of your models. If I can pick and choose which parent's
implementation of a given method is used then it could totally change
how the classes are supposed to function. I guess you can make the
parent methods protected but but would have other negative trade offs.

Ach, I'll have to go and dig out my old notes from Uni.

/me misses programming in C++ :(

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



Re: [PHP] Re: calling parent class method from the outside

2007-07-02 Thread admin

Jim Lucas wrote:

Rihad wrote:


Now will you mentally copy and paste the above code several times, 
doing the necessary text substitutions, what will you get? Three 
identical copies of doSetColumn() in each class! And the real 
doSetColumn() is a bit heavier than a one-liner. We come full circle.




I don't understand, which part(s) are you copying multiple times?  Foo, 
FooBase, all the above...


if you are talking about having multiple Foo classes with one common 
FooBase class for each that they all inherit then it would be simple, 
move soSetColumn() to the FooBase class.



[snipped]

In short: there are several sets of Xxx, XxxPeer, BaseXxx, BaseXxxPeer.

The long and uncut story: please take a look at how Symfony and more 
specifically its ORM Propel does things to better understand the 
nightmare I'm talking about. Computers don't have a hard time with code 
duplication when generating source code: they can always scratch things 
and start anew in a second (or half a second on a dual-cpu box). Code 
generation is the latest hot topic that lays the Web 2.0 buzzword 
hands down. The funny part starts when humans, who are not really good 
at code duplication, try interfacing with the kilobytes of generated 
masses of source code at the API level. You find yourself repeating code 
everywhere, and it occurs so naturally that you begin to kind of like it 
that way. Just kidding.


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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread Jochem Maas
admin wrote:
 Jochem Maas wrote:
 another solution for the OP might be (although I think it goes against
 all
 design principles):

 class A {
   function foo() {
 echo achoo\n;
   }
 }

 class B extends A {
   function foo() {
 echo cough\n;
   }
   function __call($meth, $args) {
 $func = array(parent, strtolower(str_replace(parent,, $meth)));
 if (is_callable($func))
   return call_user_func_array($func, $args);
   }
 }

 $b = new B;
 $b-foo();
 $b-parentFoo();

 
 Barring the s/parent/get_parent_class/ the idea is really really cute,
 thanks. Beautiful. Heck, maybe I'll even hack the code to do it like
 that... after some grace period.

sure it might be a neat little hack - __call() can be used for alsorts
of wonderful madness but do note it can become a maintainance and/or
documentation nightmare ... not to mention that it doesn't work with code
completion in any editor I know.

and having read what you wrote about Propel/Symphony I still don't
get what the problem is that your trying to solve ... although I suspect
that your probably suffering from a lack of late static binding
(which, if we had it, could be used to minimize alot of repetitive boiler
plate code in [for instance] 'data object' classes that extend a common
base ... then again I may be wrong :-)

[Do not get me started on LSB - I've been moaning about it since 5.0RC3]

 P.S.: I thought calling array('classname', 'method') only worked for
 static methods? It turns out there's an implied $this being passed around?

the 'callback' type has a number of forms:

'myFunc'
array('className', 'myMeth')
array(self, 'myMeth')
array(parent, 'myMeth')
array($object, 'myMeth')

self and parent adhere to the same 'context' rules when used in 
call_user_func*()
as when you use them directly - whether $this is present within the scope of the
called method is essentially down to whether the method being called is defined 
as
static or not. AFAIK call_user_func*() respects PPP modifiers and works 
transparently
with regard to access to the relevant object variable ($this)



 

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



Re: [PHP] Replace/Update record in dbase using dbase_replace_record()

2007-07-02 Thread Jochem Maas
Rahul Sitaram Johari wrote:
 Ave,
 
 Can¹t figure this one out. I¹m using the dbase_replace_record() function to
 replace a record in a dbase (.dbf) database. I just want to replace the
 value of one of the fields with another value. This is my code:
 
 $db = dbase_open(CRUMBS.DBF, 2) or die(Fatal Error: Could not open
 database!);
 if ($db) {
   $record_numbers = dbase_numrecords($db);
   for ($i = 1; $i = $record_numbers; $i++) {
  $row = dbase_get_record_with_names($db, $i);
  if ($row['PHONE'] == $thekey) {
   print_r($row);
   $row['A'] == F;
   dbase_replace_record($db, $row, 1);
 }
   }
 }
 dbase_close($db);
 
 Basically I have a database called ³CRUMBS.DBF², and the record where PHONE
 = $thekey, I want to replace the value of the field ³A² with ³F². I keep
 getting the error: ³Wrong number of fields specified².
 I have over 60 fields in each row ­ and I just want to replace the value of
 the field ³A². 
 
 Any suggestions?

get a big jar of 'clue'. as in learn to investigate and read ...

not having ever used these functions here are my hypotheses based on 5 seconds 
of
investigation and reading:

1. dbase_get_record_with_names() gives a assoc. array - it may also have
fields as indexed items in that array (like other DB extensions often do) ergo 
double
the fields that you want.

2. quoting the following page: http://php.net/dbase_get_record_with_names

Return Values
An associative array with the record. This will also include a key named 
deleted which is set to 1 if the record has
been marked for deletion

so dbase_replace_record() is possibly seeing 'deleted' as a extra erranous 
field.

3. maybe looking at and comparing the output of print_r($row), 
dbase_get_record_with_names($db, $i)
and dbase_get_record($db, $i) might tell you something;

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



Re: [PHP] str_replace new line

2007-07-02 Thread Greg Donald

On 6/30/07, jekillen [EMAIL PROTECTED] wrote:

Hello;
I have the following  code:

$prps = str_replace(\n, ' ', $input[3]);


Are you sure $input[3] doesn't have two newlines at the end?

Why not use trim() to be sure?


  $request = str_replace(// var purpose = {} ;\n, var purpose =
'$prps';\n, $request);

In the first line $input[3] is a string formatted with new lines at the
end of each line.
It is to be used to initialize a javascript variable (in the second
line above), in an html file
template.
When the html file is generated from the template, the javascript
written to it fails
with unterminated string literal error message.
When opening a view source window, the 'var purpose...' line does have
the string
broken up with extra spaces at the beginning of each line. This
indicates that
the new line was not replaced with the space. The space was merely
added after
the new line.
How do you replace a new line with php in a case like this?


Why do you want to replace it, you just said you wanted to remove it above?


Testing this is very tedious.


Do you use Firebug?  It's a Firefox extension.  Makes debugging
Javascript very easy.

Also you might try the 'view rendered source' extension.  Lets you
view the live DOM, not just the possibly outdated version of your html
the view source option gives.


Each time I have to go through and undo
file modifications that this function performs in addition to the above.
So it is not just a case of making a change and reloading the file
and rerunning it.


Brutal.  :(


--
Greg Donald
http://destiney.com/

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



Re: [PHP] Date Calculation Help

2007-07-02 Thread Dan
Well then after or before that you have to check that the month value is 
between 1 and 12 to make sure there's no input errors, then what if you ever 
want ot change the quarters yeah anway I just wanted an excuse to tell 
people to go low tech and use a switch, it's only 12 entries, and you could 
set a default.


- Dan

Fredrik Thunberg [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

of course ceil( month / 3 );

--
/Thunis

Don't panic.
  --The Hitchikers Guide to the Galaxy

Fredrik Thunberg skrev:

$q = ceil( month / 4 );



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



Re: [PHP] implementation of guest book

2007-07-02 Thread Dan
The username and password are probably in a configuration file, look arround 
for a config.php, or anything of that variant.  Also check in whatever php 
code you have ad see if there isnt' a username and pass set in there as a 
variagble.  There usually is in these guest book scripts.  They're small 
enough not to need a configuration file.  Failing that if it uses a 
database, the user and pass are probably in there.


- Dan

brian [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Shiv Prakash wrote:

Sir,

I have implemented the guest book in web site successfully and its
working also without any problem but administration side is asking
for ID and Password, my request is how do I get that because I have
tried my level best to find it in the site but I couldn’t get it
,there was not any option for that and as of downloading is concern
it was free, therefore I request you to help me out of this and solve
my problem,



It seems that the guestbook script you're using was written by somebody 
else. If that's the case then you should probably contact whomever you got 
this code from.


Failing that, you'll probably have to write your own administrative 
scripts to access the guestbook tables in the database. That should be 
pretty straightforward by studying the script you have.


brian 


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



Re: [PHP] generate letter combination..

2007-07-02 Thread Greg Donald

On 6/26/07, jeffry s [EMAIL PROTECTED] wrote:

i made a mistake when i say i can solve this problem to a friend.
finally i realize it is not as simple as i appear to be.

what he ask me to do is write a simple script that, given a word.. the
script will generate a list of words combinaton
from the each character in in that word. i am tired thinking.

to make it clear. i give a simple scenario. i don't have an idea what i
should name my baby.
so, i took my wife  name and me and input to the script.(i want a name that
is from our name combination).

later the output will present many words that i can choose.

the input string can be of any length.

anyone have an idea?


It's a called a 'permutation'.  The example in the second comment
seems to meet your requirements:

http://php.net/shuffle


function fact( $int )
{
  if( $int  2 ) return 1;
  for( $f = 2; $int - 1  1; $f *= $int-- );
  return $f;
}

function del( $s, $n )
{
   return substr( $s, 0, $n ) . substr( $s, $n + 1 );
}

function perm( $s, $n = null )
{
   if( $n === null ) return perms( $s );

   $r = '';

   $l = strlen( $s );

   while( $l-- )
   {
   $f = fact( $l );
   $p = floor( $n / $f );
   $r .= $s{$p};
   $s = del( $s, $p );
   $n-= $p * $f;
   }

   $r .= $s;

   return $r;
}

function perms( $s )
{
   $p = array();
   for( $i = 0; $i  fact( strlen( $s ) ); $i++ )
   $p[] = perm( $s, $i );
   return $p;
}

$s = 'foobar';

$strings = perms( $s );

foreach( $strings as $s )
{
   echo $s\n;
}


--
Greg Donald
http://destiney.com/

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



Re: [PHP] functions for sorting/paging functionality for imap mailboxes

2007-07-02 Thread Greg Donald

On 6/25/07, Yashesh Bhatia [EMAIL PROTECTED] wrote:

  i'm implementing an imap based mail client


That's a major wheel to go reinventing, have you not tried IMP/Horde?

http://www.horde.org/imp/


--
Greg Donald
http://destiney.com/

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



Re: [PHP] str_replace new line

2007-07-02 Thread jekillen


On Jul 2, 2007, at 6:07 PM, jekillen wrote:



On Jul 2, 2007, at 3:15 PM, Greg Donald wrote:


On 6/30/07, jekillen [EMAIL PROTECTED] wrote:

Hello;
I have the following  code:

$prps = str_replace(\n, ' ', $input[3]);


Are you sure $input[3] doesn't have two newlines at the end?

Why not use trim() to be sure?


  $request = str_replace(// var purpose = {} ;\n, var purpose =
'$prps';\n, $request);

In the first line $input[3] is a string formatted with new lines at 
the

end of each line.
It is to be used to initialize a javascript variable (in the second
line above), in an html file
template.
When the html file is generated from the template, the javascript
written to it fails
with unterminated string literal error message.
When opening a view source window, the 'var purpose...' line does 
have

the string
broken up with extra spaces at the beginning of each line. This
indicates that
the new line was not replaced with the space. The space was merely
added after
the new line.
How do you replace a new line with php in a case like this?


Why do you want to replace it, you just said you wanted to remove it 
above?


So it will not cause javascript errors when written as a javascript 
variable value

The out put goes like this:
var string = 'this is some text(\n)
with a new line in the string.'
It cause a javascript unterminated string literal error because of the 
line break
caused by the new line. I need to replace the new lines with spaces so 
it is

one long string.
It is that simple, Please.


Do you use Firebug?  It's a Firefox extension.

I do not need to debug the javascript, It is the php which
is tedious to change and retest.  The php code writes
the javascript to an html file, So I need to change the php
or find another way.

Does anyone have a simple answer to a simple question?
I am trying to replace newlines in a string with spaces. The code
I posted originally is not working. Perhaps I am doing something
wrong in that code,
That is all I am asking.
JK



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



[PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
Need to remove all spaces from Array Values... And this doesn't work.

This is similar info that's within array values: $someArray[0] = PHP is 
awesome;s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = The Toy 
Boat;s/b TheToyBoat

Begin Code===
$num = count($someArray);

for($num = 0; $cntr  $num; $cntr++)
{
 str_replace(' ','',$someArray[$num]);
 echo $someArray[$num]br /;
}
End Code=== 

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



Re: [PHP] Removing Spaces from Array Values

2007-07-02 Thread Adam Schroeder
The function str_replace() DOES NOT change the parameter.  Rather, 
str_replace() returns the desired string.  Try changing your code to:



for($num = 0; $cntr  $num; $cntr++)
{
$someArray[$num] = str_replace(' ','',$someArray[$num]);
echo $someArray[$num]br /;
}



http://us.php.net/manual/en/function.str-replace.php


Adam

kvigor wrote:


Need to remove all spaces from Array Values... And this doesn't work.

This is similar info that's within array values: $someArray[0] = PHP is 
awesome;s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = The Toy 
Boat;s/b TheToyBoat


Begin Code===
$num = count($someArray);

for($num = 0; $cntr  $num; $cntr++)
{
str_replace(' ','',$someArray[$num]);
echo $someArray[$num]br /;
}
End Code=== 

 



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



Re: [PHP] str_replace new line

2007-07-02 Thread Jim Lucas

jekillen wrote:


On Jul 2, 2007, at 6:07 PM, jekillen wrote:



On Jul 2, 2007, at 3:15 PM, Greg Donald wrote:


On 6/30/07, jekillen [EMAIL PROTECTED] wrote:

Hello;
I have the following  code:

$prps = str_replace(\n, ' ', $input[3]);


Are you sure $input[3] doesn't have two newlines at the end?

Why not use trim() to be sure?


  $request = str_replace(// var purpose = {} ;\n, var purpose =
'$prps';\n, $request);

In the first line $input[3] is a string formatted with new lines at the
end of each line.
It is to be used to initialize a javascript variable (in the second
line above), in an html file
template.
When the html file is generated from the template, the javascript
written to it fails
with unterminated string literal error message.
When opening a view source window, the 'var purpose...' line does have
the string
broken up with extra spaces at the beginning of each line. This
indicates that
the new line was not replaced with the space. The space was merely
added after
the new line.
How do you replace a new line with php in a case like this?


Why do you want to replace it, you just said you wanted to remove it 
above?


So it will not cause javascript errors when written as a javascript 
variable value

The out put goes like this:
var string = 'this is some text(\n)
with a new line in the string.'
It cause a javascript unterminated string literal error because of the 
line break
caused by the new line. I need to replace the new lines with spaces so 
it is

one long string.
It is that simple, Please.


Do you use Firebug?  It's a Firefox extension.

I do not need to debug the javascript, It is the php which
is tedious to change and retest.  The php code writes
the javascript to an html file, So I need to change the php
or find another way.

Does anyone have a simple answer to a simple question?
I am trying to replace newlines in a string with spaces. The code
I posted originally is not working. Perhaps I am doing something
wrong in that code,
That is all I am asking.
JK



$out = str_replace(\n, '\n', $in);

This will actually have a \n show in the javascript, so when it is 
printed/used by JS it will have a line feed in the output of JS.


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



Re: [PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
Got I'm my bad I really feel SHEEPISH...  s/b have done '$someArray ='
Re-read what I thought I read a it worked like a dream.

Thanks Adam


Adam Schroeder [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 The function str_replace() DOES NOT change the parameter.  Rather, 
 str_replace() returns the desired string.  Try changing your code to:


 for($num = 0; $cntr  $num; $cntr++)
 {
 $someArray[$num] = str_replace(' ','',$someArray[$num]);
 echo $someArray[$num]br /;
 }



 http://us.php.net/manual/en/function.str-replace.php


 Adam

 kvigor wrote:

Need to remove all spaces from Array Values... And this doesn't work.

This is similar info that's within array values: $someArray[0] = PHP is 
awesome;s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = The Toy 
Boat;s/b TheToyBoat

Begin Code===
$num = count($someArray);

for($num = 0; $cntr  $num; $cntr++)
{
 str_replace(' ','',$someArray[$num]);
 echo $someArray[$num]br /;
}
End Code===
 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-02 Thread kvigor
Ok Jim,

This is what I have so far and I'm still working it out.

$in_list = .join('',$someArrayList);  // do I really need to concatenate 
or separate anything here since my array values will be '7orange50lbs'? // 
this is the format I want.

$query_One = SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN({$in_list});// size, color, weight are my column names
$result = mysql_query($query_One ,$connection) or die(Query failed: . 
mysql_error($connection));
$row = mysql_fetch_array($result);

This is the error I get back from the query:
Query failed: Unknown column '6blue40lbs' in 'where clause'// where am I 
going wrong?
==
Jim Lucas [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 kvigor wrote:
 Jim,

 Please excuse the ignorance, I'm a newbie, but I'm only use to simple 
 SELECT, INSERT statements.


 Your original code: $SQL = SELECT * FROM my_Table WHERE CONCAT(value1, 
 value2, value3) IN ('.join(',', $list).')

 This can be broken down into smaller parts so to explain by example.

 # This is to clean the input values for the SQL statement
 function mysql_clean($value) {
 return mysql_real_escape_string($value);
 }

 # Define your list of values to compare to
 $list = array(
 '6blue40lbs',
 '7orange50lbs',
 '8orange60lbs',
 '9purple70lbs',
 );

 # You will want to do something like this with the values of the $list
 # array just to make sure they are clean: reference the function above
 array_walk($list, 'mysql_clean');

 # This will return a string formated like this.
 # '6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs'
 $IN_VALUE = '.join(',', $list).';

 $SQL = SELECT *
 FROM my_Table
 WHERE CONCAT(value1, value2, value3)
 IN ({$IN_VALUE});

 # The final query string will look like this
 SELECT *
 FROM my_Table
 WHERE CONCAT(value1, value2, value3)
 IN ('6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs')

 # Now run this through your query function and get the results
 $results = mysql_query($SQL) OR die('SQL Failure: '.$SQL);

 So basically what we have is a comparison that is based off the output of 
 the CONCAT() function that creates one string out of value1, value2, 
 value3 and then compares that with each of the values listed within the 
 parenthesis.  the IN (...) part of the SQL statement tells SQL that it is 
 getting a list of values that it should compare the concat() value 
 against.

 Doing it this way, will allow you to only run one query instead of running 
 one per value that you want to compare against.  As you can tell, as your 
 data set grows your multiple queries would drag your DB to a halt

 Hope this explains it.

 Let me know if you need further explanation.


 OK, I get everything up to  the ('''.join(''','''$list).''')
 I'm guessing that the .join( ). putting together some values, but I don't 
 know what
 also the .join( ). is to be preceded by something... I don't know what. 
 //Forgive my ignorance, I'll can get it.

 Also the .join( ). what is this doing I looked at the PHP and MySQL 
 function of each, and haven't seen comparable code.

 I'm asking because I don't know where we're telling the code to compare 
 the values.

 You stated...
 and create one string from them
 Where do I give the name to the string?

 So this is where I am so far:

 $sql = SELECT* FROM table WHERE CONCAT(size,color,weight) IN( );


 Jim Lucas [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 K. Hayes wrote:
 Will do.  Thanks.


 - Original Message - From: Jim Lucas [EMAIL PROTECTED]
 To: kvigor [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Sent: Saturday, June 30, 2007 1:46 AM
 Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array


 kvigor wrote:
 Hello All,

 I'm attempting to return rows from a mysql DB based on this criteria:

 I have a list, in the form of an array that I need to compare against 
 each row
 in the table.  Where theres a match I need that entire row returned.

 e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
 8orange60lbs, 9purple70lbs);

 The array contains 3 of the db row fields in 1 value. However there 
 are 10 fields/columns in the table.

 ===
 what table looks like  |
 ===
   size   colorweight
 ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |

 So how could I set up a query that would SELECT the entire row, if 
 the row contained $varListof 3outOf_10Fields[1].

 Open to any suggestions or work arounds.  I'm playing with extract() 
 but code is too crude to even post.

 I would suggest approaching the problem with a slightly different 
 thought.

 just have the sql concat() the columns together and then compare.

 something like this should do the trick

 $list = array(
 '6blue40lbs',
 '7orange50lbs',
 '8orange60lbs',
 '9purple70lbs',
 );

 $SQL = 
 SELECT *
 FROM my_Table
 WHERE CONCAT(value1, value2, value3) IN ('.join(',', 

Re: [PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
I meant to say:  Got It, My bad, I really feel SHEEPISH... should have 
done...

This is what happens when you're trying to code with a migraine, You start 
speaking another language.

Thanks Again

kvigor [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Got I'm my bad I really feel SHEEPISH...  s/b have done '$someArray ='
 Re-read what I thought I read a it worked like a dream.

 Thanks Adam


 Adam Schroeder [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 The function str_replace() DOES NOT change the parameter.  Rather, 
 str_replace() returns the desired string.  Try changing your code to:


 for($num = 0; $cntr  $num; $cntr++)
 {
 $someArray[$num] = str_replace(' ','',$someArray[$num]);
 echo $someArray[$num]br /;
 }



 http://us.php.net/manual/en/function.str-replace.php


 Adam

 kvigor wrote:

Need to remove all spaces from Array Values... And this doesn't work.

This is similar info that's within array values: $someArray[0] = PHP is 
awesome;s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = The Toy 
Boat;s/b TheToyBoat

Begin Code===
$num = count($someArray);

for($num = 0; $cntr  $num; $cntr++)
{
 str_replace(' ','',$someArray[$num]);
 echo $someArray[$num]br /;
}
End Code===
 

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



Re: [PHP] Re: calling parent class method from the outside

2007-07-02 Thread Richard Lynch
On Mon, July 2, 2007 3:44 pm, admin wrote:

IMHO, you were f'ed from the microsecond where you decided it was a
Good Idea (tm) to have an object instance for each row in the DB...

That just plain won't scale up very well at all for a large table, if
you ever need to get code re-use and do something to every row in PHP.

PHP is not C++

If you want to write C++, go ahead and write C++

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] str_replace new line

2007-07-02 Thread Richard Lynch
On Sat, June 30, 2007 12:04 pm, jekillen wrote:
 Hello;
 I have the following  code:

 $prps = str_replace(\n, ' ', $input[3]);
   $request = str_replace(// var purpose = {} ;\n, var purpose =
 '$prps';\n, $request);

 In the first line $input[3] is a string formatted with new lines at
 the
 end of each line.
 It is to be used to initialize a javascript variable (in the second
 line above), in an html file
 template.
 When the html file is generated from the template, the javascript
 written to it fails
 with unterminated string literal error message.
 When opening a view source window, the 'var purpose...' line does have
 the string
 broken up with extra spaces at the beginning of each line. This
 indicates that
 the new line was not replaced with the space. The space was merely
 added after
 the new line.
 How do you replace a new line with php in a case like this?

I don't know what you think you did, but I know that what you are
saying about \n not actually getting replaced is wrong...

 Testing this is very tedious. Each time I have to go through and undo
 file modifications that this function performs in addition to the
 above.
 So it is not just a case of making a change and reloading the file
 and rerunning it.

COPY the file before the mods, and just copy it back after.

Or change your code to just output what it's doing and not overwrite
the file for development.

Or...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Date Calculation Help

2007-07-02 Thread Richard Lynch
If the date is coming from a database, there might be a
function/format already for that...

And http://php.net/date may also have a format specifier for Quarter.

If not, try this:

$quarter = ((int) ($month / 4)) + 1;

On Sat, June 30, 2007 10:14 am, revDAVE wrote:
 I have segmented a year into four quarters (3 months each)

 nowdate = the month of the chosen date (ex: 5-30-07 = month 5)

 Q: What is the best way to calculate which quarter  (1-2-3 or 4) the
 chosen
 date falls on?

 Result - Ex: 5-30-07 = month 5 and should fall in quarter 2



 --
 Thanks - RevDave
 [EMAIL PROTECTED]
 [db-lists]

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-02 Thread Richard Lynch
I don't even being to understand your question, but it's a MySQL
question anyway.

http://dev.mysql.com/

On Sat, June 30, 2007 12:18 am, kvigor wrote:
 Hello All,

 I'm attempting to return rows from a mysql DB based on this criteria:

 I have a list, in the form of an array that I need to compare against
 each
 row
 in the table.  Where theres a match I need that entire row returned.

 e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs,
 8orange60lbs, 9purple70lbs);

 The array contains 3 of the db row fields in 1 value. However there
 are 10
 fields/columns in the table.

 ===
 what table looks like  |
 ===
   size   colorweight
 ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |

 So how could I set up a query that would SELECT the entire row, if the
 row
 contained $varListof 3outOf_10Fields[1].

 Open to any suggestions or work arounds.  I'm playing with extract()
 but
 code is too crude to even post.

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] calling parent class method from the outside

2007-07-02 Thread admin

Jochem Maas wrote:

admin wrote:

Jochem Maas wrote:

another solution for the OP might be (although I think it goes against
all
design principles):

class A {
  function foo() {
echo achoo\n;
  }
}

class B extends A {
  function foo() {
echo cough\n;
  }
  function __call($meth, $args) {
$func = array(parent, strtolower(str_replace(parent,, $meth)));
if (is_callable($func))
  return call_user_func_array($func, $args);
  }
}

$b = new B;
$b-foo();
$b-parentFoo();


Barring the s/parent/get_parent_class/ the idea is really really cute,
thanks. Beautiful. Heck, maybe I'll even hack the code to do it like
that... after some grace period.


sure it might be a neat little hack - __call() can be used for alsorts
of wonderful madness 


It was late in the night over where I live when I replied :-) But now I 
see that although your trick answers the subj perfectly, back then I 
didn't make it clear that the real intention was to get rid of code 
duplication in doSetColumn(). On closer inspection your trick would 
force me to scatter identical copies of __call() in every model class 
too, so I've gained nothing.


[snip]


and having read what you wrote about Propel/Symphony I still don't
get what the problem is that your trying to solve ... although I suspect


In Symfony/Propel you're on your own when things get to the point where 
you have to put the submitted data into DB. The main idea is that for 
columns that can be NULL the form submits empty values as empty string 
'', but I'd rather make that NULL. You would argue that simply leaving 
out the relevant update from the SQL clause would do the trick, but a 
second, more important issue prevents skipping NULL and is the basis for 
the former: for everything to work smoothly and transparently 
Symfony/Propel _insists_ on pre-hydrating the object right before the 
update, a requirement I cannot personally stand. So I've tried working 
around the requirement by populating the model myself with form data 
using setNew(false) and setXXX() calls. The real doSetColumn():


# these mutators help to skip pre-hydrating the object just to do an update
# treats NULL and empty string the same
# this also means empty input string will be converted to SQL NULL

private function doSetColumn($colname, $value, $col_mutator, 
$mod_trigger_value = '')

{
if ($value == '')
$value = null;
if (call_user_func(array(__CLASS__ . 'Peer', 
'getTableMap'))-getColumn($colname)-isNotNull()) {

if (is_null($value))
throw new Exception($col_mutator: $colname may 
not be NULL);

} else {
if (is_null($value)  !$this-isColumnModified($colname))
# XXX: as we don't know the current value in DB
# we need to force it to be set to NULL
parent::$col_mutator($mod_trigger_value);
}
parent::$col_mutator($value);
}

Hope you get the idea.



P.S.: I thought calling array('classname', 'method') only worked for
static methods? It turns out there's an implied $this being passed around?


the 'callback' type has a number of forms:

'myFunc'
array('className', 'myMeth')
array(self, 'myMeth')
array(parent, 'myMeth')
array($object, 'myMeth')

self and parent adhere to the same 'context' rules when used in 
call_user_func*()
as when you use them directly - whether $this is present within the scope of the
called method is essentially down to whether the method being called is defined 
as
static or not. AFAIK call_user_func*() respects PPP modifiers and works 
transparently
with regard to access to the relevant object variable ($this)



This undocumented (?) feature is fairly nice. Unfortunately there's no 
$this outside the class.


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



RE: [PHP] simple OCR in php

2007-07-02 Thread Richard Lynch
On Fri, June 29, 2007 11:32 am, Jay Blanchard wrote:
 [snip]
 I am looking for a way to incorporate some simple OCR into a php
 script.
 The
 user will bulk scan a pile of invoices. I want the php script to look
 at
 each
 invoice and read a number off the invoice. The image will then be
 renamed,
 and be organized into a directory and the file name will be added to a
 database. (all of these steps are straight forward once the number is
 read.)
 I have no problem with a system that requires a special OCR font
 and/or
 some
 sort of registration mark to help locate the Invoice number. Can
 anybody
 tell
 me of any tools out there that can do this?
 [/snip]

 In short PHP cannot perform OCR functions. You could insert an OCR
 application into the process and have the OCR app pass PHP the
 information.

Really?

So that OCR routine I wrote to hack a CAPTCHA doesn't exist?

Weird.

:-)

If you really do want to write OCR in PHP, it's pretty trivial:

http://php.net/imagecolorat

You'll need to build up a dictionary of known characters and define
a distance function to decide when two characters match or not,
but it's not rocket science.

It doesn't even qualify as Artificial Intelligence anymore. :-)

But since you have standard un-obfuscated content, using exec() to run
a well-established OCR package might be easier.

Or not, as I could never get the dang things to work in the first
place, personally. :-v

YMMV
NAIAA

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Flash / Ajax / PHP

2007-07-02 Thread Richard Lynch
On Fri, June 29, 2007 10:30 am, David Giragosian wrote:
 I've recently been using some limited free time to explore the
 Freemovie
 (Flash-PHP API) and Ajax technologies.

 Can anyone help me to understand whether these can be used together?
 Can I,
 for example, pull data from MySQL, dynamically alter Flash function
 parameters, then use Ajax to deliver the new content?

I did stuff like that with Ming once, so I don't see why Freemovie
couldn't do it...

But never played with Freemovie, so no promises.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Flash / Ajax / PHP

2007-07-02 Thread Richard Lynch
On Sun, July 1, 2007 5:32 am, Ryan A wrote:
 Sometimes this gets solved with spitting out some headers telling IE
 not to cache while others have (dirty) solved it by adding a hash or
 something else unique to the page or the image...

If you need serious legacy support for cave-man days browsers, there
is NO combination of headers that will work for ALL ancient browsers.

You're really better off, and it's WAY easier, to just throw some
random big into the URL that affects nothing server-side, but makes
every URL unique to the browser, so the cache is never used.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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