Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.php > #4211 > unrolled thread
| Started by | Jörg Burzeja <No_Spam_burzeja@gmx.de> |
|---|---|
| First post | 2017-08-21 20:45 +0200 |
| Last post | 2017-08-28 01:08 +0200 |
| Articles | 10 — 5 participants |
Back to article view | Back to de.comp.lang.php
OCI8 Jörg Burzeja <No_Spam_burzeja@gmx.de> - 2017-08-21 20:45 +0200
Re: OCI8 Claus Reibenstein <4spamersonly@kabelmail.de> - 2017-08-21 20:56 +0200
Re: OCI8 Jörg Burzeja <No_Spam_burzeja@gmx.de> - 2017-08-21 21:06 +0200
Re: OCI8 "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-08-21 22:56 +0200
Re: OCI8 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-22 14:43 +0200
Re: OCI8 "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-08-22 15:51 +0200
Re: OCI8 Jörg Burzeja <No_Spam_burzeja@gmx.de> - 2017-08-22 21:50 +0200
Re: OCI8 Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2017-08-22 20:36 +0000
Re: OCI8 Jörg Burzeja <No_Spam_burzeja@gmx.de> - 2017-08-22 22:58 +0200
Re: OCI8 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-28 01:08 +0200
| From | Jörg Burzeja <No_Spam_burzeja@gmx.de> |
|---|---|
| Date | 2017-08-21 20:45 +0200 |
| Subject | OCI8 |
| Message-ID | <f00o39Fpq2dU1@mid.individual.net> |
Hallo, hat jemand Erfahrung mit PHP und OCI8 auf eine ORACLE DB? Das funktioniert: $stid = oci_parse($conn, 'SELECT * FROM employees'); Das auch: $stid = oci_parse($conn, 'SELECT * FROM employees where 1 = 1'); Das nicht: $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = ''Lisa'''); double quotes scheinen bei ORACLE nicht zu funktionieren? Gibt es eine andere Lösung? Danke.
[toc] | [next] | [standalone]
| From | Claus Reibenstein <4spamersonly@kabelmail.de> |
|---|---|
| Date | 2017-08-21 20:56 +0200 |
| Message-ID | <f00om4Fpub7U1@mid.individual.net> |
| In reply to | #4211 |
Jörg Burzeja schrieb am 21.08.2017 um 20:45: > hat jemand Erfahrung mit PHP und OCI8 auf eine ORACLE DB? Nein, aber ... > $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = > ''Lisa'''); ... diesen syntaktischen PHP-Müll erkennt man auch ohne ORACLE-Kenntnisse. Versuch's mal hiermit: $stid = oci_parse($conn, "SELECT * FROM employees where first_name = 'Lisa'"); Oder hiermit: $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = \'Lisa\''); Gruß Claus
[toc] | [prev] | [next] | [standalone]
| From | Jörg Burzeja <No_Spam_burzeja@gmx.de> |
|---|---|
| Date | 2017-08-21 21:06 +0200 |
| Message-ID | <f00p9hFq1r7U1@mid.individual.net> |
| In reply to | #4212 |
Am 21.08.2017 um 20:56 schrieb Claus Reibenstein: > Versuch's mal hiermit: > > $stid = oci_parse($conn, "SELECT * FROM employees where first_name = > 'Lisa'"); Bingo. Vielen Dank Claus.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2017-08-21 22:56 +0200 |
| Message-ID | <onfhdg$4t8$1@solani.org> |
| In reply to | #4212 |
Am 21.08.2017 um 20:56 schrieb Claus Reibenstein:
> Jörg Burzeja schrieb am 21.08.2017 um 20:45:
>
>> $stid = oci_parse($conn, 'SELECT * FROM employees where first_name =
>> ''Lisa''');
>
> ... diesen syntaktischen PHP-Müll erkennt man auch ohne ORACLE-Kenntnisse.
>
> Versuch's mal hiermit:
>
> $stid = oci_parse($conn, "SELECT * FROM employees where first_name =
> 'Lisa'");
Oder vielleicht besser:
$stdi = oci_parse(
$conn, 'SELECT * FROM employees where first_name = :first_name'
);
oci_bind_by_name($stdid, ':first_name', 'Lisa');
Solange es sich bei dem Wert um ein Literal handelt, braucht man
natürlich nicht zu "binden" – das sieht allerdings anders aus, wenn man
nach User-Input selektieren will.
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-08-22 14:43 +0200 |
| Message-ID | <2827824.5fSG56mABF@PointedEars.de> |
| In reply to | #4214 |
Christoph M. Becker wrote:
> Am 21.08.2017 um 20:56 schrieb Claus Reibenstein:
>> $stid = oci_parse($conn, "SELECT * FROM employees where first_name =
^^^^^
>> 'Lisa'");
>
> Oder vielleicht besser:
>
> $stdi = oci_parse(
^^^^^
> $conn, 'SELECT * FROM employees where first_name = :first_name'
> );
> oci_bind_by_name($stdid, ':first_name', 'Lisa');
^^^^^^
> Solange es sich bei dem Wert um ein Literal handelt, braucht man
> natürlich nicht zu "binden" – das sieht allerdings anders aus, wenn man
> nach User-Input selektieren will.
ACK.
--
PointedEars
Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2017-08-22 15:51 +0200 |
| Message-ID | <onhcss$6r3$1@solani.org> |
| In reply to | #4216 |
Am 22.08.2017 um 14:43 schrieb Thomas 'PointedEars' Lahn: > Christoph M. Becker wrote: > >> Am 21.08.2017 um 20:56 schrieb Claus Reibenstein: >>> $stid = oci_parse($conn, "SELECT * FROM employees where first_name = > ^^^^^ >>> 'Lisa'"); >> >> Oder vielleicht besser: >> >> $stdi = oci_parse( > ^^^^^ >> $conn, 'SELECT * FROM employees where first_name = :first_name' >> ); >> oci_bind_by_name($stdid, ':first_name', 'Lisa'); > ^^^^^^ Danke! Ich hatte mich schon gewundert, was dieser kryptische Variablenname bedeuten soll. Nun ist es klar: statement ID. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Jörg Burzeja <No_Spam_burzeja@gmx.de> |
|---|---|
| Date | 2017-08-22 21:50 +0200 |
| Message-ID | <f03g8eFesedU1@mid.individual.net> |
| In reply to | #4212 |
Am 21.08.2017 um 20:56 schrieb Claus Reibenstein: > Jörg Burzeja schrieb am 21.08.2017 um 20:45: > >> hat jemand Erfahrung mit PHP und OCI8 auf eine ORACLE DB? > > Nein, aber ... > >> $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = >> ''Lisa'''); > > ... diesen syntaktischen PHP-Müll erkennt man auch ohne ORACLE-Kenntnisse. Danke Euch noch mal für alle Antworten. Diesen syntakischen Müll - wie Claus es nannte - hatte ich übrigens direkt von der PHP-Seite: http://php.net/manual/de/function.oci-parse.php
[toc] | [prev] | [next] | [standalone]
| From | Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) |
|---|---|
| Date | 2017-08-22 20:36 +0000 |
| Message-ID | <1t599c95a9i4f22n3e8%sfroehli@Froehlich.Priv.at> |
| In reply to | #4218 |
On Tue, 22 Aug 2017 21:50:37 Jörg Burzeja wrote: > Am 21.08.2017 um 20:56 schrieb Claus Reibenstein: > > Jörg Burzeja schrieb am 21.08.2017 um 20:45: > >> $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = ''Lisa'''); > > ... diesen syntaktischen PHP-Müll erkennt man auch ohne ORACLE-Kenntnisse. > Danke Euch noch mal für alle Antworten. > > Diesen syntakischen Müll - wie Claus es nannte - hatte ich übrigens > direkt von der PHP-Seite: > > http://php.net/manual/de/function.oci-parse.php Das Quoten eines "'" durch "''" (und darauf hat sich Claus' Äußerung IMHO bezogen) aber wohl nicht, oder? Servus, Stefan -- http://kontaktinser.at/ - die kostenlose Kontaktboerse fuer Oesterreich Offizieller Erstbesucher(TM) von mmeike Der infinite Hauch der Freiheit! Stefan. (Sloganizer)
[toc] | [prev] | [next] | [standalone]
| From | Jörg Burzeja <No_Spam_burzeja@gmx.de> |
|---|---|
| Date | 2017-08-22 22:58 +0200 |
| Message-ID | <f03k89FfpjkU1@mid.individual.net> |
| In reply to | #4219 |
Am 22.08.2017 um 22:36 schrieb Stefan Froehlich: >>>> $stid = oci_parse($conn, 'SELECT * FROM employees where first_name = ''Lisa'''); > >>> ... diesen syntaktischen PHP-Müll erkennt man auch ohne ORACLE-Kenntnisse. > >> Danke Euch noch mal für alle Antworten. >> >> Diesen syntakischen Müll - wie Claus es nannte - hatte ich übrigens >> direkt von der PHP-Seite: >> >> http://php.net/manual/de/function.oci-parse.php > > Das Quoten eines "'" durch "''" (und darauf hat sich Claus' Äußerung > IMHO bezogen) aber wohl nicht, oder? Das kam aus dem (dynamischen) MSSQL. War ein Versuch. "SELECT * ... (Claus) unterscheidet sich aber doch etwas von: 'SELECT * ... (PHP-Seite) und dann wäre das ganze Quotten in der WHERE Klausel nicht notwendig gewesen.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2017-08-28 01:08 +0200 |
| Message-ID | <5236230.MhkbZ0Pkbq@PointedEars.de> |
| In reply to | #4220 |
[2. Supersedes wegen Verwechslung] Jörg Burzeja wrote: > Am 22.08.2017 um 22:36 schrieb Stefan Froehlich: >> Das Quoten eines "'" durch "''" (und darauf hat sich Claus' Äußerung >> IMHO bezogen) aber wohl nicht, oder? > > Das kam aus dem (dynamischen) MSSQL. War ein Versuch. Das *kann* (je nach SQL-Implementierung) funktionieren, aber (ohne Escaping) natürlich _nicht_ in einem PHP-String, der bereits durch Apostrophe begrenzt ist. Ich empfehle zum Programmieren mit PHP einen Quelltexteditor mit (mindestens PHP-)Syntax-Highlighting (vor kurzem wurden hier einige diskutiert), dann fallen solche Felher eher auf. > "SELECT * ... (Claus) > unterscheidet sich aber doch etwas von: > 'SELECT * ... (PHP-Seite) > > und dann wäre das ganze Quotten in der WHERE Klausel nicht notwendig > gewesen. Doch, natürlich. _Gequotet_ werden sollte (und muss hier) *immer* (siehe „SQL Injection“); optimal – wie schon erwähnt – sollten sogar (aus diesem Grund und anderen Gründen) _Prepared Statements_ verwendet werden. -- PointedEars Zend Certified PHP Engineer <http://www.zend.com/en/yellow-pages/ZEND024953> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | de.comp.lang.php
csiph-web