الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الربط بين Oracle و Web

مغلق
بدأه صهيب النورسي في 30 يناير 2003 · 2 رد · 1,146 مشاهدة · في قواعد بيانات Oracle
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

كيف اربط بين Oracle و الويب بطريقة ديناميكية اي استطيع التفاعل مع database .

#2

ما فهمت قصدك بالضبط لكن في developer 6i تقدر تعدل طريقة العرض على الـweb اما في developer 9i فطريقة العرض الوحيده هي الـweb ممكن الوصلة تساعدك كمان

http://otn.oracle.com/sample_code/tutorial...files/wsdyn.pdf

#3

مثال

----------------------------------------------------------------

قم بعمل ملف جديد وسميه (connect.php)

<?php
$ora_conn = ora_logon("databaseName@service","pass");
?>

----------------------------------------------------------------

قم بعمل ملف جديد وسميه (disconnect.php)

<?php
ora_logoff($ora_conn);
?>

----------------------------------------------------------------

قم باضافة الكود التالي في كل صفحة للاتصال

<?php
include("connect.php");
blah blah
include("disconnect.php");
?>

---------------------------------------------------------------

قم بعمل ملف جديد وسميه (select.php)

<?php
// Comment the line error_reporting if you want to
// debug your code - for example the "NO DATA FOUND"
// when no result. Oracle returns this like an error.
error_reporting(0);

// Create an array, a cursor, count number of cols,
// perform the fetch and insert in the array.
$results = array();
$ora_cur = ora_do($ora_conn, $query);
// Don't panic, the $query will be set, wait a bit :)

if ($ora_cur)
{
  // Number of cols
  $numCols = ora_numcols($ora_cur);

  // Put the first line in the array...
  $row = array();
  for($i=0; $i<$numCols; $i++)
  { // for each column
   $row[ora_columnname($ora_cur,$i)] = ora_getcolumn($ora_cur,$i);
  }
  array_push($results,$row);

  // "Fetch" all records, one by one, and create an array for each one.
  // Each array is "pushed" in the $results array.
  while (ora_fetch($ora_cur))
  { // for each record
   $row = array();
   for($i=0; $i<$numCols; $i++)
   { // for each column
     $row[ora_columnname($ora_cur,$i)] = ora_getcolumn($ora_cur,$i);
   }
   // Push $results
   array_push($results,$row);
  }
}
// Now turns error_reporting on. Comment this line if you want
// to see "NO DATA FOUND" warnings.
error_reporting(1);
?>

---------------------------------------------------------------------------------

صفحة العرض

<?
include("connect.php");
echo "blah blah";
$query = "select NAME, AGE from people where...";

include("select.php");

// Browse $results array and display results :
if (count($results)) // if no "NO DATA FOUND"
{
 reset($results);
 while($res=each($results))
 {
/*
 $res is like :
array(0 => array('NAME' => 'Sylvain', 'AGE' => '21'),
     1 => array('NAME' => 'Somebody','AGE' => '888'));
 */
  echo $res[1]['NAME']; // name
  echo $res[1]['AGE']; // age
  // ALLWAYS write in uppercase !
 }
}
else // NO_DATA_FOUND :(
{
 echo "There's nobody in your database :D";
}

echo "blah blah and again blah";
//...another queries
$query = "...";
include("select.php");...

include("disconnect.php");
?>

----------------------------------------------------------------------------------

للاضافة و التعديل

<?php
include("connect.php");
$query = "UPDATE people SET url='http://iubito.free.fr' where name='Sylvain'";
include("query.php");
include("disconnect.php");
?>

-----------------------------------------------------------------------------

الـــــــ query.php

<?php
$cursor = ora_open($ora_conn); // Create a cursor
if($cursor) // if created
{
  // Parse query
  $resultat = ora_parse($cursor,$query);
  $resultat = ora_exec($cursor); // Execute
  $a=ora_commit($ora_conn); // perform COMMIT
  $b=ora_close($cursor); // close cursor
}
else
{ // Write an error message
  echo "oh, oh ! problem...";
}
?>

--------------------------------------------------------------------------------

دعواتكم

هذا الموضوع مغلق.

مواضيع مشابهة