PHP and oracle database 10g Enterprise Edition Part 2

Posted by Shek on May 1, 2011 under Oracle, PHP | Be the First to Comment | Total View: 4,039 views

In this post, I will continue my recording on PHP and oracle database 10g Enterprise Edition


This is a continuation of PHP and oracle database 10g Enterprise Edition Part 1.

To update fields in the oracle database:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$itemA = "ABC";
$itemB = "DEF";
$itemC = "GHI";
$itemD = "condition";
$query = oci_parse($conn, 'UPDATE "tablename" SET "fieldA" = :itemA, "fieldB" = :itemB, "fieldC" = :itemC  WHERE "fieldA" = :itemD');
oci_bind_by_name($query, ":itemA", $itemA);
oci_bind_by_name($query, ":itemB", $itemB);
oci_bind_by_name($query, ":itemC", $itemC);
oci_bind_by_name($query, ":itemD", $itemD);
$result = oci_execute($query);
if(!$result)
      {
      $errormsg=oci_error($query);
      var_dump($errormsg);
      } 
else 
      {
      echo "you have successfully update the table";
      }

To insert data into the oracle database:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$itemA = "something";
$itemB = "somethingB";
$query = oci_parse($conn, 'INSERT INTO "table" ("field1", "field2") VALUES (:itemA,:itemB)');
oci_bind_by_name($query, ":itemA", $itemA);
oci_bind_by_name($query, ":itemB", $itemB);
$result = oci_execute($query);
if(!$result)
	{
	$errormsg=oci_error($query);
	var_dump($errormsg);
	}
else 
	{
	 echo "you have successful insert the item";
	}

To get count from the oracle database:

1
2
3
4
5
6
7
8
9
10
11
$item = "something";
$query = oci_parse($conn, 'SELECT COUNT(*) AS TotalCount FROM "table" WHERE "field" = :item');
oci_bind_by_name($query, ":item", $item);
oci_define_by_name($query, 'TotalCount', $TotalCount);
$result = oci_execute($query);
if(!$result)
	{
	$errormsg=oci_error($query);
	var_dump($errormsg);
	}
echo $TotalCount;

This concluded my topic of “PHP and oracle database 10g Enterprise Edition” at this moment.

Not what you want? Try a Search

Add A Comment

*