Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Pear
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Pear Pear programming, this is a very complex subject as with using pear with php can be a difficult task for some, so lets talk pear.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 05-20-2007, 7:42 PM   #1
Lorenzo Alberton
 
Lorenzo Alberton's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default cvs: pear /MDB2 package_oci8.php /MDB2/MDB2/Driver/Reverse oci8.php

quipo Wed May 16 20:31:55 2007 UTC

Modified files:
/pear/MDB2/MDB2/Driver/Reverse oci8.php
/pear/MDB2 package_oci8.php
Log:
initial support for FOREIGN KEY and CHECK constraints in the Reverse module

http://cvs.php.net/viewvc.cgi/pear/M...&diff_format=u
Index: pear/MDB2/MDB2/Driver/Reverse/oci8.php
diff -u pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.62 pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.63
--- pear/MDB2/MDB2/Driver/Reverse/oci8.php:1.62 Thu Mar 29 18:18:06 2007
+++ pear/MDB2/MDB2/Driver/Reverse/oci8.php Wed May 16 20:31:55 2007
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: oci8.php,v 1.62 2007/03/29 18:18:06 quipo Exp $
+// $Id: oci8.php,v 1.63 2007/05/16 20:31:55 quipo Exp $
//

require_once 'MDB2/Driver/Reverse/Common.php';
@@ -270,16 +270,35 @@
if (PEAR::isError($db)) {
return $db;
}
-
- $query = 'SELECT alc.constraint_name,
- alc.constraint_type,
+ //querying USER_CONSTRAINTS and USER_CONS_COLUMNS is slightly faster than ALL_CONSTRAINTS and ALL_CONS_COLUMNS
+ $query = 'SELECT alc.constraint_name,
+ CASE alc.constraint_type WHEN \'P\' THEN 1 ELSE 0 END "primary",
+ CASE alc.constraint_type WHEN \'R\' THEN 1 ELSE 0 END "foreign",
+ CASE alc.constraint_type WHEN \'U\' THEN 1 ELSE 0 END "unique",
+ CASE alc.constraint_type WHEN \'C\' THEN 1 ELSE 0 END "check",
+ alc.DELETE_RULE "on_delete",
+ \'NO ACTION\' "on_update",
+ CASE alc.deferrable WHEN \'NOT DEFERRABLE\' THEN 0 ELSE 1 END "is_deferrable",
+ CASE alc.deferred WHEN \'IMMEDIATE\' THEN 1 ELSE 0 END "is_deferred",
alc.search_condition,
- alc.r_constraint_name,
alc.search_condition,
+ alc.table_name,
cols.column_name,
- cols.position
- FROM all_constraints alc,
- all_cons_columns cols
+ cols.position,
+ r_alc.table_name "references_table",
+ r_cols.column_name "references_field",
+ r_cols.position "references_field_position"
+ FROM user_cons_columns cols
+ LEFT JOIN user_constraints alc
+ ON alc.constraint_name = cols.constraint_name
+ AND alc.owner = cols.owner
+ LEFT JOIN user_constraints r_alc
+ ON alc.r_constraint_name = r_alc.constraint_name
+ AND alc.r_owner = r_alc.owner
+ LEFT JOIN user_cons_columns r_cols
+ ON r_alc.constraint_name = r_cols.constraint_name
+ AND r_alc.owner = r_cols.owner
+ AND cols.position = r_cols.position
WHERE (alc.constraint_name=%s OR alc.constraint_name=%s)
AND alc.constraint_name = cols.constraint_name
AND alc.owner = '.$db->quote(strtoupper($db->dsn['username']), 'text');
@@ -321,6 +340,20 @@
$definition['fields'][$column_name] = array(
'position' => (int)$row['position']
);
+ if ($row['foreign']) {
+ $ref_column_name = $row['references_field'];
+ if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
+ if ($db->options['field_case'] == CASE_LOWER) {
+ $ref_column_name = strtolower($ref_column_name);
+ } else {
+ $ref_column_name = strtoupper($ref_column_name);
+ }
+ }
+ $definition['references_table'] = $row['references_table'];
+ $definition['references_fields'][$ref_column_name] = array(
+ 'position' => (int)$row['references_field_position']
+ );
+ }
$lastrow = $row;
// otherwise $row is no longer usable on exit from loop
}
@@ -329,14 +362,16 @@
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
$constraint_name . ' is not an existing table constraint', __FUNCTION__);
}
- if ($lastrow['constraint_type'] === 'P') {
- $definition['primary'] = true;
- } elseif ($lastrow['constraint_type'] === 'U') {
- $definition['unique'] = true;
- } elseif ($lastrow['constraint_type'] === 'R') {
- $definition['foreign'] = $lastrow['r_constraint_name'];
- } elseif ($lastrow['constraint_type'] === 'C') {
- $definition['check'] = true;
+ $definition['primary'] = (boolean)$lastrow['primary'];
+ $definition['unique'] = (boolean)$lastrow['unique'];
+ $definition['foreign'] = (boolean)$lastrow['foreign'];
+ $definition['check'] = (boolean)$lastrow['check'];
+ $definition['is_deferrable'] = (boolean)$lastrow['is_deferrable'];
+ $definition['is_deferred'] = (boolean)$lastrow['is_deferred'];
+ $definition['on_delete'] = $lastrow['on_delete'];
+ $definition['on_update'] = $lastrow['on_update'];
+
+ if ($definition['check']) {
// pattern match constraint for check constraint values into enum-style output:
$enumregex = '/'.$lastrow['column_name'].' in \((.+?)\)/i';
if (preg_match($enumregex, $lastrow['search_condition'], $rangestr)) {
@@ -350,6 +385,9 @@
}
}
}
+
+
+ //echo '<hr><pre>'; print_r($definition); echo '</pre><hr>';
return $definition;
}

http://cvs.php.net/viewvc.cgi/pear/M...&diff_format=u
Index: pear/MDB2/package_oci8.php
diff -u pear/MDB2/package_oci8.php:1.119 pear/MDB2/package_oci8.php:1.120
--- pear/MDB2/package_oci8.php:1.119 Thu May 3 18:54:16 2007
+++ pear/MDB2/package_oci8.php Wed May 16 20:31:55 2007
@@ -6,6 +6,7 @@
$version = 'XXX';
$state = 'stable';
$notes = <<<EOT
+- initial support for FOREIGN KEY and CHECK constraints in the Reverse module

note:
- please use the latest ext/oci8 version from pecl.php.net/oci8
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MDB2 - how to catch "MDB2 Error: constraint violation" error? l Burnerheimerton Pear 3 10-12-2008 10:44 AM
cvs: pear /MDB2 package_mssql.php /MDB2/MDB2/Driver/Reverse mssql.php Lorenzo Alberton Pear 0 05-20-2007 7:42 PM
cvs: pear /MDB2_Schema/MDB2 Schema.php /MDB2_Schema/MDB2/Schema Parser.php /MDB2_Schema/docs xml_schema_documentation.html Igor Feghali Pear 0 05-20-2007 7:41 PM
cvs: pear /MDB2/MDB2/Driver mysql.php mysqli.php pgsql.php David Coallier Pear 0 05-20-2007 7:41 PM
MDB2 ibase Reverse: strange case problem Alessandro Pasotti Pear 3 05-20-2007 6:34 PM


Featured Websites




All times are GMT +1. The time now is 8:09 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98