473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Oracle->not same result from php and from sql*plus

Hi,

Here is my query, ran from oracle sql*plus:

SELECT mrbs_room.id, start_time, end_time, name, mrbs_entry.id, type
FROM mrbs_entry, mrbs_room
WHERE mrbs_entry.room_id = mrbs_room.id
AND area_id = 101
AND start_time <= 1076068800
AND end_time > 1076065200

Here is the correct result :
SQL> Connected.

ID START_TIME END_TIME NAME ID T
---------- ---------- ---------- ---- -- -
82 1076065200 1076068800 test 41 I

Ran from php, I got this :

ID START_TIME END_TIME NAME T
---------- ---------- ---------- ---- -- -
41 1076065200 1076068800 test I

the two ID fields are named with their table name, but php keep the second
value and display it as the first one.

Thierry Bothorel

--
Click here to answer / cliquez ci dessous pour me repondre
http://cerbermail.com/?7O7SOrggJg
Jul 17 '05 #1
4 2257
Thierry B. wrote:
the two ID fields are named with their table name, but php keep the second
value and display it as the first one.


Rename the ID fields, so that they have different names for PHP.

select table1.id, ..., table2.id as id2, ...
Or maybe you can use integer indexing on the result;
instead of $res['id'] use $res[0] and $res[4]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Thanks,
I will use alias, but I already used integer indexing, the buffer returned
by oracle simply miss one column
--
--
Click here to answer / cliquez ci dessous pour me repondre
http://cerbermail.com/?7O7SOrggJg

"Pedro Graca" <he****@hotpop.com> a écrit dans le message de news:
c0*************@ID-203069.news.uni-berlin.de...
Thierry B. wrote:
the two ID fields are named with their table name, but php keep the second value and display it as the first one.


Rename the ID fields, so that they have different names for PHP.

select table1.id, ..., table2.id as id2, ...
Or maybe you can use integer indexing on the result;
instead of $res['id'] use $res[0] and $res[4]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--

Jul 17 '05 #3
On Sun, 8 Feb 2004 10:46:15 -0400, "Thierry B." <no****@nospam.com> wrote:
I will use alias, but I already used integer indexing, the buffer returned
by oracle simply miss one column


Unique identifiers for each column within a result set is certainly the way to
go, but just testing out whether it does lose data:

<pre>
<?php
$conn = OCILogon('test', 'test', 'dev92lnx');

$stmt = OCIParse($conn, 'select 1 id, 2 id from dual');
OCIExecute($stmt);
OCIFetch($stmt);

echo "OCIFetch:\n";
echo OCIResult($stmt, 1) . "\n";
echo OCIResult($stmt, 2) . "\n";
echo OCIResult($stmt, "ID") . "\n";

echo "\nOCIFetchInto:\n";
OCIExecute($stmt);
OCIFetchInto($stmt, $row, OCI_ASSOC+OCI_NUM);
var_dump($row)
?>
</pre>

Outputs:

OCIFetch:
1
2
1

OCIFetchInto:
array(3) {
[0]=>
string(1) "1"
["ID"]=>
string(1) "2"
[1]=>
string(1) "2"
}

The second identically named column isn't lost. Most of the PHP OCI8 functions
work using bind by name, rather than position, but the data is still there.

If you fetch into an associative array by name, clearly it can only keep one
of the values. (Although this could be better documented - can't spot a
reference from a quick read through). And the code above shows an inconsistency
between OCIResult and OCIFetchInto as to which one it picks in the case of
identical identifiers (which is almost certainly a bug).

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #4
Thanks,

using OCI_ASSOC, I just need to write :

SELECT mytable1.id AS id, mytable2.id AS id2

instead of

SELECT mytable1.id, mytable2.id

Thierry Bothorel
--
Click here to answer / cliquez ci dessous pour me repondre
http://cerbermail.com/?7O7SOrggJg
"Andy Hassall" <an**@andyh.co.uk> a écrit dans le message de news:
et********************************@4ax.com...
Unique identifiers for each column within a result set is certainly the way to go, but just testing out whether it does lose data:
The second identically named column isn't lost. Most of the PHP OCI8 functions work using bind by name, rather than position, but the data is still there.
If you fetch into an associative array by name, clearly it can only keep one of the values. (Although this could be better documented - can't spot a
reference from a quick read through). And the code above shows an inconsistency between OCIResult and OCIFetchInto as to which one it picks in the case of
identical identifiers (which is almost certainly a bug).

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: valexena | last post by:
In order to set SQL*PLUS session so that NLS_DATE_FORMAT information is altered in a specific way every time I log into Oracle which method would be used? -- Posted via http://dbforums.com
2
by: Matt | last post by:
I'm new to Java but experienced with PL/SQL. I've found what appears to be strange behaviour (a bug?) when attempting to create java stored objects using the UNIX version of Oracle SQL*PLUS...
1
by: Miori | last post by:
Dear all, Server machine running Oracle Database Server on Linux and a Client machine running Oracle Client on WIndows XP. HOw it is possible to shut down/start up the Oracle database on the...
2
by: Ant | last post by:
Hi, I have an SQL assignment to do and at my school we use SQL *Plus there however I don't have Oracle at home, where I would like to do the work ,so I was wondering whats the easiest way to get...
2
by: vvenk | last post by:
Hello: I am running VB.Net to access a oracle 10g table that has a sequence. This is what I tried: Dim liID As Integer = 0 Dim lodcCMD As OleDbCommand = New OleDbCommand("SELECT...
14
by: peteh | last post by:
Hi All; We have many production jobs that "load from cursor" to a UDB/AIX 8.2 (with dpf) data warehouse from source tables residing Oracle 9i. Since Oracle dates are (roughly) equivalent to DB2...
9
by: skyloon | last post by:
I've did a program using vb6 to connect to oracle9i, i can establish the connection, the problem is when i execute the query in oracle sql*plus, it can execute successfully, but when run in vb...
7
by: HARSHUL | last post by:
One table contains information about courses offered at a local college. A course number like MATH1301 or HIST2311 identifies each course. All course numbers are the same length. Each course has a...
0
by: kg6ypx | last post by:
Jeff/Dave- Thanks for your help. I am going to go buy Anthony Molinaro's "SQL Cookbook" (O'Reilly). Thanks again. Al.
4
by: Gator25 | last post by:
I'm using SQL Plus 10.2 to query an oracle 10G db. The script I have works great except several of the insurance company names begin with the same phrase before adding the additional identifier....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.