Article View: chile.comp.programacion
Article #1429Re: Script en PHP
From: Cristian Gutierrez
Date: Mon, 14 Aug 2006 18:06
Date: Mon, 14 Aug 2006 18:06
37 lines
1973 bytes
1973 bytes
Hoy en la tarde, T. Q. LEO dijo: [...] > select * from lider where cliente='$empresa' and > MONTH(FROM_UNIXTIME(fecha))='$mescons' and > YEAR(FROM_UNIXTIME(fecha))='$anocons' order by fecha DESC LIMIT > ".$st.",".$pp; Una sugerencia de estilo: es m�s legible (y hasta dir�a que un poco m�s mantenible) usar `sprintf' para componer sentencias SQL: ,---- | $template =<<<ENDOFTEMPLATE; | | SELECT * | FROM lider | WHERE cliente = '%s' | AND MONTH(FROM_UNIXTIME(fecha)) = '%s' | AND YEAR(FROM_UNIXTIME(fecha)) = '%s' | ORDER BY fecha DESC | LIMIT %d,%d | | ENDOFTEMPLATE | | $query = sprintf($template, | $empresa, $mescons, $anocons, $st, $pp); `---- Lo ideal ser�a usar �prepared statements�, pero no siempre est�n disponibles (entiendo que para PHP5 + MySQL 4.1 s�). Salu2, -- Guti Code runs faster when Chuck Norris watches it.
Technical Details
Message-ID:
<87ac67i43m.fsf@guti.cl>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!news.cec.uchile.cl!not-for-mailReferences:
<44e09fc4$1_1@nova.entelchile.net>Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,68886b01d65beeee X-Google-Attributes: gid1593cb,public X-Google-Language: SPANISH,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!news.cec.uchile.cl!not-for-mail From: Cristian Gutierrez <crgutier@dcc.uchile.cl> Newsgroups: chile.comp.programacion Subject: Re: Script en PHP Supersedes: <87d5b3i46b.fsf@guti.cl> Date: Mon, 14 Aug 2006 14:06:53 -0400 Organization: DCC/Uchile Lines: 37 Message-ID: <87ac67i43m.fsf@guti.cl> References: <44e09fc4$1_1@nova.entelchile.net> NNTP-Posting-Host: vpn-client-029.cec.uchile.cl Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1155578815 10097 172.17.35.29 (14 Aug 2006 18:06:55 GMT) X-Complaints-To: news@localhost.localdomain NNTP-Posting-Date: Mon, 14 Aug 2006 18:06:55 +0000 (UTC) User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Key: sha1:Ioom/BjOZrPDFwsCJWzEENBdSdM= Cancel-Lock: sha1:CS/EkRcqTN00QoyZY2BWjZXtj5g=