RE: [PHP] Extra (persistant) tier

2005-06-24 Thread Leila Lappin
[quote]
I REALLY don't understand why anybody would abstract out every single
table as a separate class like that.

Surely there are some COMMON features and behaviours between the fields of
any given MySQL type.

[\quote]

IMHO, the answer is simplicity of implementation and to some extent
performance.  If I have two tables with different layouts and names, using
just one generic class to manipulate them will require that the class be
implemented with additional and often complex logic to take care of the
differences in the names and layouts of the tables. I personally find there
is no advantage in doing that in terms of performance or maintenance.


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 23, 2005 11:41 PM
To: Leila Lappin
Cc: Evert | Rooftop; PHP-Users
Subject: RE: [PHP] Extra (persistant) tier


On Wed, June 22, 2005 8:35 pm, Leila Lappin said:
 When I worked with other OO languages, I usually designed my persistent
 business objects in two levels.  A level (lower level) designed and
 implemented direct database calls.  Each database table had a class
 abstraction at this level which provided the database calls for saving,
 loading and etc.  At this level I also provided for the caching
 considerations, i.e. if a table was already queried and a list was
 available
 the list in memory was used instead of querying again.

I had a guy hired me to do that once.

He had me budgeted for about a month to write all the classes.

I spent two days writing a PHP script to write a PHP class for each table
in the database, using mysql_* introspection functions instead. :-)

He was pretty happy, since I saved him about $10,000, give or take.

The project died long before he ever got to the point of having me do the
next level...

Which is just as well.

I REALLY don't understand why anybody would abstract out every single
table as a separate class like that.

Surely there are some COMMON features and behaviours between the fields of
any given MySQL type.

Wouldn't it make a LOT more sense to have a single abstract class that,
given a MySQL table-name, would provide an object cache of data structures
that matched the table field names/types?

Surely the text field in table foo isn't all that different from the
text field in table bar at that level.

Maybe that's just me being ornery.

 The next level was where the business model was implemented.  If a
 business
 object required information from three tables that related to each other
 in
 a certain way the load methods would access the objects from cached lists
 in
 three different classes (each representing a database table) and created
 the
 final list.  At this stage the list was cached and also represented the
 business logic.

Woof.

Now see, there, I gotta wonder is your cache really faster than a good
single query?

Cuz I'm thinking three separate queries for the data is gonna be a lot
more expensive.  Sure, maybe it's cached.  Or maybe it's not.

With the relatively SHORT life-time of a PHP script (you hope) the odds on
any given datum being cached should be pretty LOW, I would think.

Plus, the way this works out, you're probably going to end up having a
separate query for every row if you are displaying, say, 10 rows of
inter-related data from three tables.

That's 30 queries instead of 1.

That can't be faster than one well-written query.

 Although I haven't done this in PHP I think with PHP5 it's possible.  The
 only challenge may be the caching of query results but I think Pear
 modules
 already have something about that.

Caching query results should be relatively easy...

Of course, your DATABASE server and your Operating System are *already*
caching data for you. Will your cache on top of their cache really provide
significant performance boost in PHP?

Plus, if you design the Application Logic correctly, you shouldn't *HAVE*
duplicate queries to get the same data in a single script.

This whole data-cache thing might make sense in a language where there is
a central shared cache (Java?  JSP?) but in PHP I just don't see it being
all that

By the time you've filled up your cache with all the stuff you are going
to re-use, the script should be FINISHING.

PHP is not Java.

The solutions that are great in Java aren't in PHP sometimes.  And vice
versa, of course.

Now if you combine this with some kind of PHP Application Framework, and
throw away the whole point of the cornerstone of the share-nothing
architecture (which has pros and cons) then you might maybe have a
significant performance increase...  But there ain't such a beast yet, far
as I know, though some folks are working on them.

So, I gotta say, if you did this in PHP, you've made a fundamental error
in assessing the performance/benefit/cost ratios of what makes a PHP
Application fast.

This is all just MY OPINION.

I'm sure somebody is going to tell me just how stupid and naive I mussed
be for not undersanding OO.

Never mind I spent 15

RE: [PHP] Extra (persistant) tier

2005-06-22 Thread Leila Lappin
When I worked with other OO languages, I usually designed my persistent
business objects in two levels.  A level (lower level) designed and
implemented direct database calls.  Each database table had a class
abstraction at this level which provided the database calls for saving,
loading and etc.  At this level I also provided for the caching
considerations, i.e. if a table was already queried and a list was available
the list in memory was used instead of querying again.

The next level was where the business model was implemented.  If a business
object required information from three tables that related to each other in
a certain way the load methods would access the objects from cached lists in
three different classes (each representing a database table) and created the
final list.  At this stage the list was cached and also represented the
business logic.

Although I haven't done this in PHP I think with PHP5 it's possible.  The
only challenge may be the caching of query results but I think Pear modules
already have something about that.

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 22, 2005 9:14 PM
To: Evert | Rooftop
Cc: PHP-Users
Subject: Re: [PHP] Extra (persistant) tier


On Mon, June 20, 2005 11:44 am, Evert | Rooftop said:
 I'm writing a big web application, and trying really hard to seperate
 business logic and presentation, which been no problem up to now.
 Because I abstracted the business logic so much the framework became
 heavier, sometimes a simple action can take up to 2 mb memory and
 several extra milliseconds.

Perhaps you have abstracted the business logic in an inefficient manner...
 It's real easy to get carried away making a ton of objects that look real
purty in the abstract, but are really just clutter when you get down to
what you want the application to *DO*.

Take a break from it, step back, and try to look at it sideways

Sometimes the obvious set of classes is actually not the right answer

I don't know how else to describe this...

 I know this doesn't sound much and I'm applying all kinds of technique's
 to reduce resource-usage and increase speed. The thing is, I feel like I
 need to split the business tier up in 2 tiers, one of them being my
 persisitant object manager. The main reason is because every script that
 is executed must do some initialization and database calls, and I think
 I could reduce this by making a persistant tier, but there doesn't seem
 a good way to do this using php except when I would use sockets.

I don't think you are going to get the database connection to persist
across scripts, period. You can use _pconnect so that the database server
will re-use a connection data structure, which can improve performance.

The penalties for _pconnect are memory and number of active connections.

Each persistent connection will chew up a little bit of memory.

The way it works out, each persistent connection ends up being tied to an
Apache child.  So you *MUST* configure your database to have *more*
connections active than the number of Apache children.  You want a few
extra so you can still use mysql from shell or mysqladmin to bring down
the server if you need to.  You do *NOT* want to be locked out of
mysqladmin because all the connections are tied up in Apache children.
[shudder]

If you really have a good chunk of semi-static persistent data, you should
consider moving those into a PHP Module by re-writing the data load in C.

 Shared memory doesn't really seem like an option, because I would still
 need to include all the classes to manage it, and when I use shared
 memory, the memory would still be copied into the php memory + having a
 central manager seems like a good idea.

Perhaps the data wouldn't *ALL* need to be copied into each PHP Module,
but some of it could be accessed on an as-needed basis.

 I know I'm pretty vague in my requirements, but I think it should be
 enough to explain what kind of solution I´m looking for, because this
 seems like a big advantage of java over php, or am I mistaken?
 If you have any ideas, let me know :)

I dunno how stable/mature the PHP/Java interface is, but maybe it would be
an option to move the semi-static data into a Java object...  Though you'd
probably be even slower to get that data to/from PHP then.  Worth checking
out other's experience, or even a quickie trial run if you can hack up a
test for a benchmark.

Maybe (gasp) Java is what you should have written this in in the first
place.

OTOH, maybe you shouldn't have gone the route of Object-Oriented
abstraction of business logic.  If blazing speed is the requirement,
that's not gonna be the answer, most times.  A well-designed procedural
body of code will generally out-perform OO and can still have sufficient
separation of business logic from presentation logic.  YMMV

--
Like Music?
http://l-i-e.com/artists.htm

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

RE: [PHP] Problem with array

2005-06-17 Thread Leila Lappin
Try this I think it will work.

$count = count($arry);

for ($i=0; $i$count; $i++) {
   // do something with $array[$i]
}

cout($array) brings back the number of elements in the array which limits
the lookup index.



-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]
Sent: Friday, June 17, 2005 2:30 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Problem with array


Quoting Ross [EMAIL PROTECTED]:

 As with my previous post the problem is the pieces of the array can vary
 from 1 to 4 items. So pieces 3 and 4 are often undefined giving the
 'undefined index' notice. All I really want to do is display the array
 pieces if they EXIST. But as they are inside a echo statement so I can't
 even to a for loop...can I?

Not sure about a for loop inside the echo.

 Any ideas?

Yes. Something like this should work:

echo beginning html tags;
foreach ($pieces as $this_piece) {
   echo $this_piece .  ;
}
echo middle html tags;
echo $formatted_price;
echo closing html tags;

This should at least give you a starting point. I'm fairly new to php,
so maybe one of the gurus will give a better idea (or explain why mine
won't work, if it won't).

hth,
Rick

P.S. I would usually trim out the rest of the message, but am leaving
the code below as reference. Sorry for the long post.

 if ($quantity == 0){

}
   else {

 $pieces = explode( , $quantity);


   $formatted_price = sprintf('%0.2f', $pricecode);
  echo table width=\240\ border=\0\ cellpadding=\2\
 cellspacing=\5\trtd valign=\top\ align=\right\
 width=\40\$pieces[0]/tdtd align=\left\ width=\60\/tdtd
 align=\left\ width=\200\$pieces[1]  $pieces[2] $pieces[3]
 $pieces[4]/tdtd valign=\top\ align=\left\
 width=\80\$formatted_price/td/tr/table;





   }
   }

--
Rick Emery

When once you have tasted flight, you will forever walk the Earth
with your eyes turned skyward, for there you have been, and there
you will always long to return
  -- Leonardo Da Vinci

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

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



[PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hello all,

I hope this hasn’t been answered a zillion times already, I've tried
everything I know and nothing has worked. The following is the PHP statement
and the HTML rendering.  The apostrophe is displayed as is and breaks the
browser.  May be I am wrong but I was under the impression that escaping
special characters with one of the these, htmlspecialchars, htmlentities,
and addslashes would replace them with encoded (hex?) value so they wont
break the browser. But it hasn’t worked that way.  I am using
charset=iso-8859-1.  This is my PHP:

=== This is the PHP ===
li
a href=#
onclick='document.form1.how.value=?=htmlentities($row['how'])?;
document.form1.factor.value=?=addslashes($row['factor'])?;document.form1
..submit();'?= addslashes($row['factor'])?
  /a
/li

== This is the rendering ===
== (note the heart's apostrophe breaks IE and firefox) ===
li
 a href=# onclick='document.form1.how.value=Pulmonary edema is a
condition in which fluid accumulates in the lungs, usually because the
heart's left ventricle does not pump adequately. In cases of severe
pulmonary edema, the symptoms will worsen and include A drop in blood
pressure resulting in a thready pulse.;
document.form1.factor.value=Pulmonary
edema;document.form1.submit();'Pulmonary edema
/a
/li

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



[PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hello all,

I hope this hasn’t been answered a zillion times already, I've tried
everything I know and nothing has worked. The following is the PHP statement
and the HTML rendering.  The apostrophe is displayed as is and breaks the
browser.  May be I am wrong but I was under the impression that escaping
special characters with one of the these, htmlspecialchars, htmlentities,
and addslashes would replace them with encoded (hex?) value so they wont
break the browser. But it hasn’t worked that way.  I am using
charset=iso-8859-1.  This is my PHP:

=== This is the PHP ===
li
a href=#
onclick='document.form1.how.value=?=htmlentities($row['how'])?;
document.form1.factor.value=?=addslashes($row['factor'])?;document.form1
..submit();'?= addslashes($row['factor'])?
  /a
/li

== This is the rendering ===
== (note the heart's apostrophe breaks IE and firefox) ===
li
 a href=# onclick='document.form1.how.value=Pulmonary edema is a
condition in which fluid accumulates in the lungs, usually because the
heart's left ventricle does not pump adequately. In cases of severe
pulmonary edema, the symptoms will worsen and include A drop in blood
pressure resulting in a thready pulse.;
document.form1.factor.value=Pulmonary
edema;document.form1.submit();'Pulmonary edema
/a
/li

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



RE: [PHP] Re: Getting help on using the PHP lists

2005-06-10 Thread Leila Lappin
Have you tried changing the subscription options through the website?  I
think you can do it by just checking the type of list you're interested in
subscribing.



-Original Message-
From: Jim Elliott [mailto:[EMAIL PROTECTED]
Sent: Friday, June 10, 2005 4:24 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Getting help on using the PHP lists


JamesBenson wrote:
 I thin they must get loads of spam so tighten up security, when I tried
 signing up it never worked for at least two weeks then finally when it
 did I had to wait another few weeks for a reply to my subscription
request.

I am subscribed just fine, I just want to see if I can change my
subscription options so I only use the web site and get the list via a
digest (one per day) instead of individual e-mails. Thus the HELP
request as per the instructions, which did not work.

Jim

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

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



RE: Re[2]: [PHP] Problems escaping apostrophe, please help

2005-06-10 Thread Leila Lappin
Hi,

I solved the problem by using htmlspecialchars and passing it ENT_QUOTES.
But I'll try your way as a more general way too.  Thanks


-Original Message-
From: Tom Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, June 10, 2005 8:36 PM
To: php-general@lists.php.net
Cc: Leila Lappin
Subject: Re[2]: [PHP] Problems escaping apostrophe, please help


Hi,

TR What I do to overcome this is in PHP do:

TR $content = rawurlencode($content);

TR and in the html javascript:

TR unescape($content);


I didn't do that very well, your code would look something like:

li
  a href=#
onclick='document.form1.how.value=unescape(?php
rawurlencode($row['how'])?);
document.form1.factor.value=unescape(?php
rawurlencode($row['factor']))?);
document.form1.submit();'?php htmlentities($row['factor'])?
  /a
/li




--
regards,
Tom

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

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



RE: [PHP] Blank page in browser

2005-05-17 Thread Leila Lappin
Blank page usually means there was an error during parsing of PHP.  The
error will be in the error.log file under apache.  Find that file and check
it, it'll show you what happened.



-Original Message-
From: Nayeem [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 17, 2005 4:42 AM
To: php-general@lists.php.net
Subject: [PHP] Blank page in browser


Dear All,

I'm new to PHP programming and I just try to display small information from
database on web page but its shows blank page. So my code is mention below
and let me know what's wrong in it but when I execute same program on
command prompt then its shows all result correctly with HTML Tags

?php

  PutEnv(ORACLE_SID=TSH1);
  PutEnv(ORACLE_HOME=/u01/app/oracle/product/10.1.0/db_1);
  PutEnv(TNS_ADMIN=/var/opt/oracle);

   $db_conn = ocilogon(scott, tiger, );

   $cmdstr = select ename, sal from emp;
   $parsed = ociparse($db_conn, $cmdstr);
   ociexecute($parsed);
   $nrows = ocifetchstatement($parsed, $results);
   echo Found: $nrows resultsbrbr\n;

   echo table border=1 cellspacing='0' width='50%'\n;
   echo tr\n;
   echo tdbName/b/td\n;
   echo tdbSalary/b/td\n;
   echo /tr\n;

   for ($i = 0; $i  $nrows; $i++ ) {
 echo tr\n;
 echo td . $results[ENAME][$i] . /td;
 echo td$  . number_format($results[SAL][$i], 2). /td;
 echo /tr\n;
   }

   echo /table\n;

   ?

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

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



RE: [PHP] beginner needs help!

2005-05-12 Thread Leila Lappin
Will this work?

?php
$string = Export..date(mdy)..txt;
echo $string;
? 

-Original Message-
From: Clinton, Rochelle A [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 12, 2005 12:55 PM
To: php-general@lists.php.net
Subject: [PHP] beginner needs help!


Dear Much Needed Advisor,

 

I am definitely a PHP novice and making some code changes to a PHP
script.

 

I need to change a declared output file to include the date as an
extension.

 

My file is declared at the beginning of the script as:

var $exportFile = Export.txt;

 

I need it to be, for instance, Export.051205.txt.

 

I have played around with the date function many ways:

Ex 1:

var $exportFile = Export . date(mdy);

 

Ex 2:

$file = Export;

$ext = date(mdy);

var $exportFile = $file . $ext;

 

I can't seem to get anything to work.

 

Also, could you point me to somewhere where I can learn the difference
between declaring variables as:

 

$exportFile = Export.txt;

and 

var $exportFile = Export.txt

 

Thank you! Thank you!

 

Rochelle Clinton

Bioinformatics Coordinator

University of Kentucky

200 Thomas Hunt Morgan Building

office: (859) 257-2161

cell: (406) 570-5383

email: [EMAIL PROTECTED]

 

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



Re: [PHP] Informix - ifx_num_rows

2001-08-24 Thread Leila

Thanks for all that answered my question.
I wanted this function because i use Postgres too in the same project , i
will use informix or postgres , so
the logic in my implementation was based on postgres functions...
But if to Informix it doesn't work ... I will do of another way.
Leila
Martín marqués [EMAIL PROTECTED] escreveu nas notícias de
mensagem:[EMAIL PROTECTED]
 On Jue 23 Ago 2001 21:21, Chris Fry wrote:
  This function does not work reliably with most databases, not just
  Informix. Caused me a lot of problems as I have a number of pages where
I'd
  like to display a No records found message.

 I normally have a count(*) query to know how much records belong to the
query
 (especially when I use LIMIT and that stuff).

 With Informix, you'll have to use sqlca.sqlerrd[0..5]. One of the elements
of
 the array is the amount of records.

  Just have to do it the hard way.
 
  I think there's a disclaimer in the docs about this being unreliable.

 It once was on the informix docs, but not anymore. The source may have
 changed.


 Saludos... :-)

 P.D.: No problems with pg_num_rows() :-)

 --
 Porqué usar una base de datos relacional cualquiera,
 si podés usar PostgreSQL?
 -
 Martín Marqués  |[EMAIL PROTECTED]
 Programador, Administrador, DBA |   Centro de Telematica
Universidad Nacional
 del Litoral
 -



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Informix - ifx_num_rows

2001-08-23 Thread Leila

Hi all,

I have Php 4.0.6 on Linux with Informix Dynamic Server 7.31.UD1.
I try to use the function ifx_num_rows after afx_query and the value
returned is always 0,  but i can see
the result with ifx_fetch_row.
Does Anyone know if there is a bug with this function ifx_num_rows ?

Thanks in advance.
Leila





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]