🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #1428

Re: Script en PHP

#1428
From: T_Q_LEO
Date: Mon, 14 Aug 2006 18:22
51 lines
2207 bytes
Hola:

Es una interesate sugerencia la que me haces, creo que la implementare en
futuros proyectos que tenga en PHP.

Gracias =)

-- 
Ricardo Carcass�n
Depto. Inform�tica
Inspectorate Griffith S.A
Santiago - Chile
"Cristian Gutierrez" <crgutier@dcc.uchile.cl> escribi� en el mensaje
news:87fyfzi4dm.fsf@guti.cl...
> 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
> mantenibile) 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 seria 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: <44e0bd00$1_2@nova.entelchile.net>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!nova.entelchile.net!not-for-mail
References: <44e09fc4$1_1@nova.entelchile.net> <87fyfzi4dm.fsf@guti.cl>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,68886b01d65beeee
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
From: "T_Q_LEO" <programNOSPAM@inspectorate.cl>
Newsgroups: chile.comp.programacion
References: <44e09fc4$1_1@nova.entelchile.net> <87fyfzi4dm.fsf@guti.cl>
Subject: Re: Script en PHP
Date: Mon, 14 Aug 2006 14:22:20 -0400
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 200.72.224.46
X-Original-NNTP-Posting-Host: 200.72.224.46
Message-ID: <44e0bd00$1_2@nova.entelchile.net>
X-Trace: nova.entelchile.net 1155579136 200.72.224.46 (14 Aug 2006 14:12:16 -0400)
X-Original-NNTP-Posting-Host: 200.72.224.46
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!nova.entelchile.net!not-for-mail