2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Add support for PHP7, update ADODB

This commit is contained in:
Adam Zammit
2017-03-27 15:39:17 +11:00
225 changed files with 51391 additions and 40151 deletions

View File

@@ -268,7 +268,7 @@ if (!defined('DB_USER')) define('DB_USER', 'quexs');
if (!defined('DB_PASS')) define('DB_PASS', 'quexs'); if (!defined('DB_PASS')) define('DB_PASS', 'quexs');
if (!defined('DB_HOST')) define('DB_HOST', 'localhost'); if (!defined('DB_HOST')) define('DB_HOST', 'localhost');
if (!defined('DB_NAME')) define('DB_NAME', 'quexs'); if (!defined('DB_NAME')) define('DB_NAME', 'quexs');
if (!defined('DB_TYPE')) define('DB_TYPE', 'mysqlt'); if (!defined('DB_TYPE')) define('DB_TYPE', 'mysqli');
/** /**
* The prefix for the limesurvey database * The prefix for the limesurvey database

View File

@@ -31,7 +31,7 @@ function injectglobalsettings()
{ {
foreach ($dbvaluearray as $setting) foreach ($dbvaluearray as $setting)
{ {
global $$setting['stg_name']; global ${$setting['stg_name']};
if (isset($$setting['stg_name'])) if (isset($$setting['stg_name']))
{ {
$$setting['stg_name']=$setting['stg_value']; $$setting['stg_name']=$setting['stg_value'];

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View File

@@ -0,0 +1,9 @@
<component name="ProjectDictionaryState">
<dictionary name="dregad">
<words>
<w>adodb</w>
<w>mssql</w>
<w>mssqlnative</w>
</words>
</dictionary>
</component>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

View File

@@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/adodb.iml" filepath="$PROJECT_DIR$/.idea/adodb.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,450 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ac81baa3-c781-40ee-8180-55d5a33882b9" name="Default" comment="" />
<ignored path="adodb.iws" />
<ignored path=".idea/" />
<ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="DatabaseView">
<option name="GROUP_SCHEMA" value="true" />
<option name="GROUP_CONTENTS" value="false" />
<option name="SORT_POSITIONED" value="false" />
<option name="SHOW_TABLE_DETAILS" value="true" />
<option name="SHOW_EMPTY_GROUPS" value="false" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="adodb" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="adodb-mysqli.inc.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/drivers/adodb-mysqli.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="201">
<caret line="39" column="23" selection-start-line="39" selection-start-column="23" selection-end-line="39" selection-end-column="23" />
<folding>
<marker date="1459409495629" expanded="true" signature="1434:1565" placeholder="SELECT TABLE... TABLES" />
<marker date="1459409495629" expanded="true" signature="6578:6620" placeholder="select ${$co... ${$tables}" />
<marker date="1459409495629" expanded="true" signature="8554:8601" placeholder="create table... if" />
<marker date="1459409495629" expanded="true" signature="8629:8652" placeholder="select count... " />
<marker date="1459409495629" expanded="true" signature="8676:8702" placeholder="insert into " />
<marker date="1459409495629" expanded="true" signature="8726:8749" placeholder="drop table i... " />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="changelog.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="150">
<caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/adodb.inc.php" root0="FORCE_HIGHLIGHTING" root1="FORCE_HIGHLIGHTING" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/adodb.inc.php" />
<option value="$PROJECT_DIR$/drivers/adodb-mysqli.inc.php" />
<option value="$PROJECT_DIR$/docs/changelog.md" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" />
<component name="JsBuildToolPackageJson" detection-done="true" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="PhpServers">
<servers />
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" interpreter_name="PHP 5.6" />
<component name="ProjectFrameBounds">
<option name="x" value="65" />
<option name="y" value="24" />
<option name="width" value="1855" />
<option name="height" value="1056" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>SQL</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>SqlNoDataSourceInspection</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="1" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="drivers" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="adodb" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="docs" />
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/.idea" />
<property name="settings.editor.selected.configurable" value="preferences.sourceCode" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="ChangesBrowser.SHOW_FLATTEN" value="true" />
</component>
<component name="RunManager">
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
<TestRunner />
<method />
</configuration>
<configuration default="true" type="PhpBehatConfigurationType" factoryName="Behat">
<BehatRunner />
<method />
</configuration>
<configuration default="true" type="PhpLocalRunConfigurationType" factoryName="PHP Console">
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<node-interpreter>project</node-interpreter>
<node-options />
<gulpfile />
<tasks />
<arguments />
<envs />
<method />
</configuration>
<configuration default="true" type="js.build_tools.npm" factoryName="npm">
<command value="run-script" />
<scripts />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="ac81baa3-c781-40ee-8180-55d5a33882b9" name="Default" comment="" />
<created>1459369231815</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1459369231815</updated>
<workItem from="1459369233886" duration="33000" />
<workItem from="1459369287408" duration="889000" />
<workItem from="1459370209069" duration="3711000" />
<workItem from="1459527565905" duration="26000" />
<workItem from="1459409039393" duration="9000" />
<workItem from="1459409291197" duration="1460000" />
</task>
<task id="LOCAL-00001" summary="Update changelog&#10;">
<created>1459370567207</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1459370567207</updated>
</task>
<task id="LOCAL-00002" summary="Fix PHP warning in ADORecordset_mysqli::__close()&#10;&#10;PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, integer given&#10;&#10;Fixes #217&#10;">
<created>1459411447176</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1459411447176</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="6128000" />
</component>
<component name="ToolWindowManager">
<frame x="65" y="24" width="1855" height="1056" extended-state="6" />
<editor active="false" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32960325" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39979655" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32901832" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18867925" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Update changelog&#10;" />
<MESSAGE value="Fix PHP warning in ADORecordset_mysqli::__close()&#10;&#10;PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, integer given&#10;&#10;Fixes #217&#10;" />
<option name="LAST_COMMIT_MESSAGE" value="Fix PHP warning in ADORecordset_mysqli::__close()&#10;&#10;PHP Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, integer given&#10;&#10;Fixes #217&#10;" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/drivers/adodb-mysqli.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1125">
<caret line="93" column="9" selection-start-line="93" selection-start-column="9" selection-end-line="93" selection-end-column="9" />
<folding>
<marker date="1459409495629" expanded="true" signature="1434:1565" placeholder="SELECT TABLE... TABLES" />
<marker date="1459409495629" expanded="true" signature="6578:6620" placeholder="select ${$co... ${$tables}" />
<marker date="1459409495629" expanded="true" signature="8554:8601" placeholder="create table... if" />
<marker date="1459409495629" expanded="true" signature="8629:8652" placeholder="select count... " />
<marker date="1459409495629" expanded="true" signature="8676:8702" placeholder="insert into " />
<marker date="1459409495629" expanded="true" signature="8726:8749" placeholder="drop table i... " />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="870">
<caret line="58" column="6" selection-start-line="58" selection-start-column="6" selection-end-line="58" selection-end-column="6" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/drivers/adodb-mysqli.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1230">
<caret line="100" column="9" selection-start-line="100" selection-start-column="9" selection-end-line="100" selection-end-column="9" />
<folding>
<marker date="1459409495629" expanded="true" signature="1434:1565" placeholder="SELECT TABLE... TABLES" />
<marker date="1459409495629" expanded="true" signature="6578:6620" placeholder="select ${$co... ${$tables}" />
<marker date="1459409495629" expanded="true" signature="8554:8601" placeholder="create table... if" />
<marker date="1459409495629" expanded="true" signature="8629:8652" placeholder="select count... " />
<marker date="1459409495629" expanded="true" signature="8676:8702" placeholder="insert into " />
<marker date="1459409495629" expanded="true" signature="8726:8749" placeholder="drop table i... " />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/drivers/adodb-mysqli.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1215">
<caret line="99" column="9" selection-start-line="99" selection-start-column="9" selection-end-line="99" selection-end-column="9" />
<folding>
<marker date="1459409495629" expanded="true" signature="1434:1565" placeholder="SELECT TABLE... TABLES" />
<marker date="1459409495629" expanded="true" signature="6578:6620" placeholder="select ${$co... ${$tables}" />
<marker date="1459409495629" expanded="true" signature="8554:8601" placeholder="create table... if" />
<marker date="1459409495629" expanded="true" signature="8629:8652" placeholder="select count... " />
<marker date="1459409495629" expanded="true" signature="8676:8702" placeholder="insert into " />
<marker date="1459409495629" expanded="true" signature="8726:8749" placeholder="drop table i... " />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/adodb.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30720">
<caret line="2058" column="30" selection-start-line="2058" selection-start-column="30" selection-end-line="2058" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/adodb.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="843">
<caret line="2058" column="30" selection-start-line="2058" selection-start-column="30" selection-end-line="2058" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/docs/changelog.md">
<provider editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" />
<folding />
</state>
</provider>
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="FIRST">
<first_editor relative-caret-position="150">
<caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/drivers/adodb-mysqli.inc.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="201">
<caret line="39" column="23" selection-start-line="39" selection-start-column="23" selection-end-line="39" selection-end-column="23" />
<folding>
<marker date="1459409495629" expanded="true" signature="1434:1565" placeholder="SELECT TABLE... TABLES" />
<marker date="1459409495629" expanded="true" signature="6578:6620" placeholder="select ${$co... ${$tables}" />
<marker date="1459409495629" expanded="true" signature="8554:8601" placeholder="create table... if" />
<marker date="1459409495629" expanded="true" signature="8629:8652" placeholder="select count... " />
<marker date="1459409495629" expanded="true" signature="8676:8702" placeholder="insert into " />
<marker date="1459409495629" expanded="true" signature="8726:8749" placeholder="drop table i... " />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View File

@@ -0,0 +1,4 @@
Andreas Fernandez <a.fernandez@scripting-base.de> <andreas.fernandez@aspedia.de>
Mike Benoit <mikeb@timetrex.com> MikeB <ipso@snappymail.ca>
Mike Benoit <mikeb@timetrex.com> mike.benoit

View File

@@ -0,0 +1,496 @@
ADOdb License
=============
ADOdb is dual licensed under BSD and LGPL.
In plain English, you do not need to distribute your application in source code form,
nor do you need to distribute ADOdb source code, provided you follow the rest of
terms of the BSD license.
For more info about ADOdb, visit http://adodb.sourceforge.net/
BSD 3-Clause License
--------------------
(c) 2000-2013 John Lim (jlim@natsoft.com)
(c) 2014 Damien Regad, Mark Newnham and the ADOdb community
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
### DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
GNU LESSER GENERAL PUBLIC LICENSE
---------------------------------
_Version 2.1, February 1999_
_Copyright © 1991, 1999 Free Software Foundation, Inc._
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
_This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1._
### Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: **(1)** we copyright the
library, and **(2)** we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the “Lesser” General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
“work based on the library” and a “work that uses the library”. The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
**0.** This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called “this License”).
Each licensee is addressed as “you”.
A “library” means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The “Library”, below, refers to any such software library or work
which has been distributed under these terms. A “work based on the
Library” means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term “modification”.)
“Source code” for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
**1.** You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
**2.** You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
* **a)** The modified work must itself be a software library.
* **b)** You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
* **c)** You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
* **d)** If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
**3.** You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
**4.** You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
**5.** A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a “work that uses the Library”. Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a “work that uses the Library” with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a “work that uses the
library”. The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a “work that uses the Library” uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
**6.** As an exception to the Sections above, you may also combine or
link a “work that uses the Library” with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
* **a)** Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable “work that
uses the Library”, as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
* **b)** Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
* **c)** Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
* **d)** If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
* **e)** Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the “work that uses the
Library” must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
**7.** You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
* **a)** Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
* **b)** Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
**8.** You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
**9.** You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
**10.** Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
**11.** If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
**12.** If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
**13.** The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
“any later version”, you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
**14.** If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
### NO WARRANTY
**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
_END OF TERMS AND CONDITIONS_

View File

@@ -0,0 +1,109 @@
ADOdb Library for PHP5
======================
[![Join chat on Gitter](https://img.shields.io/gitter/room/form-data/form-data.svg)](https://gitter.im/adodb/adodb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Download ADOdb](https://img.shields.io/sourceforge/dm/adodb.svg)](https://sourceforge.net/projects/adodb/files/latest/download)
(c) 2000-2013 John Lim (jlim@natsoft.com)
(c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both [BSD 3-Clause](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#bsd-3-clause-license)
and [GNU Lesser GPL library 2.1](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#gnu-lesser-general-public-license)
licenses.
This means you can use it in proprietary products;
see [License](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md) for details.
Home page: http://adodb.org/
> **WARNING: known issue with Associative Fetch Mode in ADOdb v5.19
-- PLEASE UPGRADE TO v5.20 !**
> When fetching data in Associative mode (i.e. when `$ADODB_FETCH_MODE` is
> set to *ADODB_FETCH_ASSOC*), recordsets do not return any data (empty strings)
> when using some database drivers. The problem has been reported on MSSQL,
> Interbase and Foxpro, but possibly affects other drivers as well; all drivers
> derived from the above are also impacted.
> For further details, please refer to [Issue #20](https://github.com/ADOdb/ADOdb/issues/20).
Introduction
============
PHP's database access functions are not standardized. This creates a
need for a database class library to hide the differences between the
different databases (encapsulate the differences) so we can easily
switch databases.
The library currently supports MySQL, Interbase, Sybase, PostgreSQL, Oracle,
Microsoft SQL server, Foxpro ODBC, Access ODBC, Informix, DB2,
Sybase SQL Anywhere, generic ODBC and Microsoft's ADO.
We hope more people will contribute drivers to support other databases.
Installation
============
Unpack all the files into a directory accessible by your web server.
To test, try modifying some of the tutorial examples.
Make sure you customize the connection settings correctly.
You can debug using:
``` php
<?php
include('adodb/adodb.inc.php');
$db = ADONewConnection($driver); # eg. 'mysql' or 'oci8'
$db->debug = true;
$db->Connect($server, $user, $password, $database);
$rs = $db->Execute('select * from some_small_table');
print "<pre>";
print_r($rs->GetRows());
print "</pre>";
```
Documentation and Examples
==========================
Refer to the [ADOdb website](http://adodb.org/) for library documentation and examples. The documentation can also be [downloaded for offline viewing](https://sourceforge.net/projects/adodb/files/Documentation/).
- [Main documentation](http://adodb.org/dokuwiki/doku.php?id=v5:userguide:userguide_index): Query, update and insert records using a portable API.
- [Data dictionary](http://adodb.org/dokuwiki/doku.php?id=v5:dictionary:dictionary_index) describes how to create database tables and indexes in a portable manner.
- [Database performance monitoring](http://adodb.org/dokuwiki/doku.php?id=v5:performance:performance_index) allows you to perform health checks, tune and monitor your database.
- [Database-backed sessions](http://adodb.org/dokuwiki/doku.php?id=v5:session:session_index).
There is also a [tutorial](http://adodb.org/dokuwiki/doku.php?id=v5:userguide:mysql_tutorial) that contrasts ADOdb code with PHP native MySQL code.
Files
=====
- `adodb.inc.php` is the library's main file. You only need to include this file.
- `adodb-*.inc.php` are the database specific driver code.
- `adodb-session.php` is the PHP4 session handling code.
- `test.php` contains a list of test commands to exercise the class library.
- `testdatabases.inc.php` contains the list of databases to apply the tests on.
- `Benchmark.php` is a simple benchmark to test the throughput of a SELECT
statement for databases described in testdatabases.inc.php. The benchmark
tables are created in test.php.
Support
=======
To discuss with the ADOdb development team and users, connect to our
[Gitter chatroom](https://gitter.im/adodb/adodb) using your Github credentials.
Please report bugs, issues and feature requests on Github:
https://github.com/ADOdb/ADOdb/issues
You may also find legacy issues in
- the old [ADOdb forums](http://phplens.com/lens/lensforum/topics.php?id=4) on phplens.com
- the [SourceForge tickets section](http://sourceforge.net/p/adodb/_list/tickets)
However, please note that they are not actively monitored and should
only be used as reference.

View File

@@ -1,19 +1,21 @@
<?php <?php
/* /*
@version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
Latest version is available at http://adodb.sourceforge.net @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Latest version is available at http://adodb.sourceforge.net
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Active Record implementation. Superset of Zend Framework's. Active Record implementation. Superset of Zend Framework's.
Version 0.92 Version 0.92
See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord
for info on Ruby on Rails Active Record implementation for info on Ruby on Rails Active Record implementation
*/ */
@@ -52,19 +54,23 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false)
foreach($_ADODB_ACTIVE_DBS as $k => $d) { foreach($_ADODB_ACTIVE_DBS as $k => $d) {
if (PHP_VERSION >= 5) { if (PHP_VERSION >= 5) {
if ($d->db === $db) return $k; if ($d->db === $db) {
} else {
if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database)
return $k; return $k;
} }
} else {
if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database) {
return $k;
}
}
} }
$obj = new ADODB_Active_DB(); $obj = new ADODB_Active_DB();
$obj->db = $db; $obj->db = $db;
$obj->tables = array(); $obj->tables = array();
if ($index == false) $index = sizeof($_ADODB_ACTIVE_DBS); if ($index == false) {
$index = sizeof($_ADODB_ACTIVE_DBS);
}
$_ADODB_ACTIVE_DBS[$index] = $obj; $_ADODB_ACTIVE_DBS[$index] = $obj;
@@ -87,10 +93,14 @@ class ADODB_Active_Record {
var $foreignName; // CFR: class name when in a relationship var $foreignName; // CFR: class name when in a relationship
var $lockMode = ' for update '; // you might want to change to
static function UseDefaultValues($bool=null) static function UseDefaultValues($bool=null)
{ {
global $ADODB_ACTIVE_DEFVALS; global $ADODB_ACTIVE_DEFVALS;
if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool; if (isset($bool)) {
$ADODB_ACTIVE_DEFVALS = $bool;
}
return $ADODB_ACTIVE_DEFVALS; return $ADODB_ACTIVE_DEFVALS;
} }
@@ -118,14 +128,21 @@ class ADODB_Active_Record {
} }
if (!$table) { if (!$table) {
if (!empty($this->_table)) $table = $this->_table; if (!empty($this->_table)) {
$table = $this->_table;
}
else $table = $this->_pluralize(get_class($this)); else $table = $this->_pluralize(get_class($this));
} }
$this->foreignName = strtolower(get_class($this)); // CFR: default foreign name $this->foreignName = strtolower(get_class($this)); // CFR: default foreign name
if ($db) { if ($db) {
$this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db);
} else if (!isset($this->_dbat)) { } else if (!isset($this->_dbat)) {
if (sizeof($_ADODB_ACTIVE_DBS) == 0) $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor'); if (sizeof($_ADODB_ACTIVE_DBS) == 0) {
$this->Error(
"No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",
'ADODB_Active_Record::__constructor'
);
}
end($_ADODB_ACTIVE_DBS); end($_ADODB_ACTIVE_DBS);
$this->_dbat = key($_ADODB_ACTIVE_DBS); $this->_dbat = key($_ADODB_ACTIVE_DBS);
} }
@@ -144,7 +161,9 @@ class ADODB_Active_Record {
function _pluralize($table) function _pluralize($table)
{ {
if (!ADODB_Active_Record::$_changeNames) return $table; if (!ADODB_Active_Record::$_changeNames) {
return $table;
}
$ut = strtoupper($table); $ut = strtoupper($table);
$len = strlen($table); $len = strlen($table);
@@ -158,8 +177,9 @@ class ADODB_Active_Record {
case 'X': case 'X':
return $table.'es'; return $table.'es';
case 'H': case 'H':
if ($lastc2 == 'CH' || $lastc2 == 'SH') if ($lastc2 == 'CH' || $lastc2 == 'SH') {
return $table.'es'; return $table.'es';
}
default: default:
return $table.'s'; return $table.'s';
} }
@@ -170,24 +190,28 @@ class ADODB_Active_Record {
function _singularize($tables) function _singularize($tables)
{ {
if (!ADODB_Active_Record::$_changeNames) return $table; if (!ADODB_Active_Record::$_changeNames) {
return $table;
}
$ut = strtoupper($tables); $ut = strtoupper($tables);
$len = strlen($tables); $len = strlen($tables);
if($ut[$len-1] != 'S') if($ut[$len-1] != 'S') {
return $tables; // I know...forget oxen return $tables; // I know...forget oxen
if($ut[$len-2] != 'E') }
if($ut[$len-2] != 'E') {
return substr($tables, 0, $len-1); return substr($tables, 0, $len-1);
switch($ut[$len-3]) }
{ switch($ut[$len-3]) {
case 'S': case 'S':
case 'X': case 'X':
return substr($tables, 0, $len-2); return substr($tables, 0, $len-2);
case 'I': case 'I':
return substr($tables, 0, $len-3) . 'y'; return substr($tables, 0, $len-3) . 'y';
case 'H'; case 'H';
if($ut[$len-4] == 'C' || $ut[$len-4] == 'S') if($ut[$len-4] == 'C' || $ut[$len-4] == 'S') {
return substr($tables, 0, $len-2); return substr($tables, 0, $len-2);
}
default: default:
return substr($tables, 0, $len-1); // ? return substr($tables, 0, $len-1); // ?
} }
@@ -214,7 +238,9 @@ class ADODB_Active_Record {
// use when you don't want ADOdb to auto-pluralize tablename // use when you don't want ADOdb to auto-pluralize tablename
static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record') static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record')
{ {
if (!is_array($tablePKey)) $tablePKey = array($tablePKey); if (!is_array($tablePKey)) {
$tablePKey = array($tablePKey);
}
$ar = new ADODB_Active_Record($table,$tablePKey); $ar = new ADODB_Active_Record($table,$tablePKey);
$ar->hasMany($foreignRef, $foreignKey, $foreignClass); $ar->hasMany($foreignRef, $foreignKey, $foreignClass);
} }
@@ -258,7 +284,9 @@ class ADODB_Active_Record {
static function TableKeyBelongsTo($table, $tablePKey, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record') static function TableKeyBelongsTo($table, $tablePKey, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record')
{ {
if (!is_array($tablePKey)) $tablePKey = array($tablePKey); if (!is_array($tablePKey)) {
$tablePKey = array($tablePKey);
}
$ar = new ADOdb_Active_Record($table, $tablePKey); $ar = new ADOdb_Active_Record($table, $tablePKey);
$ar->belongsTo($foreignRef, $foreignKey, $parentKey, $parentClass); $ar->belongsTo($foreignRef, $foreignKey, $parentKey, $parentClass);
} }
@@ -287,24 +315,34 @@ class ADODB_Active_Record {
{ {
$extras = array(); $extras = array();
$table = $this->TableInfo(); $table = $this->TableInfo();
if ($limit >= 0) $extras['limit'] = $limit; if ($limit >= 0) {
if ($offset >= 0) $extras['offset'] = $offset; $extras['limit'] = $limit;
}
if ($offset >= 0) {
$extras['offset'] = $offset;
}
if (strlen($whereOrderBy)) if (strlen($whereOrderBy)) {
if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy)) if (!preg_match('/^[ \n\r]*AND/i', $whereOrderBy)) {
if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i',$whereOrderBy)) if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i', $whereOrderBy)) {
$whereOrderBy = 'AND '.$whereOrderBy; $whereOrderBy = 'AND ' . $whereOrderBy;
}
}
}
if(!empty($table->_belongsTo[$name])) if(!empty($table->_belongsTo[$name])) {
{
$obj = $table->_belongsTo[$name]; $obj = $table->_belongsTo[$name];
$columnName = $obj->foreignKey; $columnName = $obj->foreignKey;
if(empty($this->$columnName)) if(empty($this->$columnName)) {
$this->$name = null; $this->$name = null;
else }
{ else {
if ($obj->parentKey) $key = $obj->parentKey; if ($obj->parentKey) {
else $key = reset($table->keys); $key = $obj->parentKey;
}
else {
$key = reset($table->keys);
}
$arrayOfOne = $obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras); $arrayOfOne = $obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras);
if ($arrayOfOne) { if ($arrayOfOne) {
@@ -313,8 +351,7 @@ class ADODB_Active_Record {
} }
} }
} }
if(!empty($table->_hasMany[$name])) if(!empty($table->_hasMany[$name])) {
{
$obj = $table->_hasMany[$name]; $obj = $table->_hasMany[$name];
$key = reset($table->keys); $key = reset($table->keys);
$id = @$this->$key; $id = @$this->$key;
@@ -323,7 +360,9 @@ class ADODB_Active_Record {
$id = $db->qstr($id); $id = $db->qstr($id);
} }
$objs = $obj->Find($obj->foreignKey.'='.$id. ' '.$whereOrderBy,false,false,$extras); $objs = $obj->Find($obj->foreignKey.'='.$id. ' '.$whereOrderBy,false,false,$extras);
if (!$objs) $objs = array(); if (!$objs) {
$objs = array();
}
$this->$name = $objs; $this->$name = $objs;
return $objs; return $objs;
} }
@@ -345,13 +384,15 @@ class ADODB_Active_Record {
$tableat = $this->_tableat; $tableat = $this->_tableat;
if (!$forceUpdate && !empty($tables[$tableat])) { if (!$forceUpdate && !empty($tables[$tableat])) {
$tobj = $tables[$tableat]; $acttab = $tables[$tableat];
foreach($tobj->flds as $name => $fld) { foreach($acttab->flds as $name => $fld) {
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) {
$this->$name = $fld->default_value; $this->$name = $fld->default_value;
else }
else {
$this->$name = null; $this->$name = null;
} }
}
return; return;
} }
$db = $activedb->db; $db = $activedb->db;
@@ -364,6 +405,16 @@ class ADODB_Active_Record {
if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) {
// abs(rand()) randomizes deletion, reducing contention to delete/refresh file // abs(rand()) randomizes deletion, reducing contention to delete/refresh file
// ideally, you should cache at least 32 secs // ideally, you should cache at least 32 secs
foreach($acttab->flds as $name => $fld) {
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) {
$this->$name = $fld->default_value;
}
else {
$this->$name = null;
}
}
$activedb->tables[$table] = $acttab; $activedb->tables[$table] = $acttab;
//if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname"); //if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname");
@@ -377,11 +428,15 @@ class ADODB_Active_Record {
$save = $ADODB_FETCH_MODE; $save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false); if ($db->fetchMode !== false) {
$savem = $db->SetFetchMode(false);
}
$cols = $db->MetaColumns($table); $cols = $db->MetaColumns($table);
if (isset($savem)) $db->SetFetchMode($savem); if (isset($savem)) {
$db->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save; $ADODB_FETCH_MODE = $save;
if (!$cols) { if (!$cols) {
@@ -393,7 +448,9 @@ class ADODB_Active_Record {
if (isset($fld->primary_key)) { if (isset($fld->primary_key)) {
$pkeys = array(); $pkeys = array();
foreach($cols as $name => $fld) { foreach($cols as $name => $fld) {
if (!empty($fld->primary_key)) $pkeys[] = $name; if (!empty($fld->primary_key)) {
$pkeys[] = $name;
}
} }
} else } else
$pkeys = $this->GetPrimaryKeys($db, $table); $pkeys = $this->GetPrimaryKeys($db, $table);
@@ -410,10 +467,12 @@ class ADODB_Active_Record {
case 0: case 0:
foreach($cols as $name => $fldobj) { foreach($cols as $name => $fldobj) {
$name = strtolower($name); $name = strtolower($name);
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
$this->$name = $fldobj->default_value; $this->$name = $fldobj->default_value;
else }
else {
$this->$name = null; $this->$name = null;
}
$attr[$name] = $fldobj; $attr[$name] = $fldobj;
} }
foreach($pkeys as $k => $name) { foreach($pkeys as $k => $name) {
@@ -425,10 +484,12 @@ class ADODB_Active_Record {
foreach($cols as $name => $fldobj) { foreach($cols as $name => $fldobj) {
$name = strtoupper($name); $name = strtoupper($name);
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
$this->$name = $fldobj->default_value; $this->$name = $fldobj->default_value;
else }
else {
$this->$name = null; $this->$name = null;
}
$attr[$name] = $fldobj; $attr[$name] = $fldobj;
} }
@@ -440,10 +501,12 @@ class ADODB_Active_Record {
foreach($cols as $name => $fldobj) { foreach($cols as $name => $fldobj) {
$name = ($fldobj->name); $name = ($fldobj->name);
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
$this->$name = $fldobj->default_value; $this->$name = $fldobj->default_value;
else }
else {
$this->$name = null; $this->$name = null;
}
$attr[$name] = $fldobj; $attr[$name] = $fldobj;
} }
foreach($pkeys as $k => $name) { foreach($pkeys as $k => $name) {
@@ -458,14 +521,18 @@ class ADODB_Active_Record {
if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) { if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) {
$activetab->_created = time(); $activetab->_created = time();
$s = serialize($activetab); $s = serialize($activetab);
if (!function_exists('adodb_write_file')) include(ADODB_DIR.'/adodb-csvlib.inc.php'); if (!function_exists('adodb_write_file')) {
include(ADODB_DIR.'/adodb-csvlib.inc.php');
}
adodb_write_file($fname,$s); adodb_write_file($fname,$s);
} }
if (isset($activedb->tables[$table])) { if (isset($activedb->tables[$table])) {
$oldtab = $activedb->tables[$table]; $oldtab = $activedb->tables[$table];
if ($oldtab) $activetab->_belongsTo = $oldtab->_belongsTo; if ($oldtab) {
if ($oldtab) $activetab->_hasMany = $oldtab->_hasMany; $activetab->_belongsTo = $oldtab->_belongsTo;
$activetab->_hasMany = $oldtab->_hasMany;
}
} }
$activedb->tables[$table] = $activetab; $activedb->tables[$table] = $activetab;
} }
@@ -483,17 +550,26 @@ class ADODB_Active_Record {
$fn = get_class($this).'::'.$fn; $fn = get_class($this).'::'.$fn;
$this->_lasterr = $fn.': '.$err; $this->_lasterr = $fn.': '.$err;
if ($this->_dbat < 0) $db = false; if ($this->_dbat < 0) {
$db = false;
}
else { else {
$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
$db = $activedb->db; $db = $activedb->db;
} }
if (function_exists('adodb_throw')) { if (function_exists('adodb_throw')) {
if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false); if (!$db) {
else adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db); adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false);
} else }
if (!$db || $db->debug) ADOConnection::outp($this->_lasterr); else {
adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db);
}
} else {
if (!$db || $db->debug) {
ADOConnection::outp($this->_lasterr);
}
}
} }
@@ -501,18 +577,26 @@ class ADODB_Active_Record {
function ErrorMsg() function ErrorMsg()
{ {
if (!function_exists('adodb_throw')) { if (!function_exists('adodb_throw')) {
if ($this->_dbat < 0) $db = false; if ($this->_dbat < 0) {
else $db = $this->DB(); $db = false;
}
else {
$db = $this->DB();
}
// last error could be database error too // last error could be database error too
if ($db && $db->ErrorMsg()) return $db->ErrorMsg(); if ($db && $db->ErrorMsg()) {
return $db->ErrorMsg();
}
} }
return $this->_lasterr; return $this->_lasterr;
} }
function ErrorNo() function ErrorNo()
{ {
if ($this->_dbat < 0) return -9999; // no database connection... if ($this->_dbat < 0) {
return -9999; // no database connection...
}
$db = $this->DB(); $db = $this->DB();
return (int) $db->ErrorNo(); return (int) $db->ErrorNo();
@@ -548,8 +632,11 @@ class ADODB_Active_Record {
// So, I find that for myTable, I want to reload an active record after saving it. -- Malcolm Cook // So, I find that for myTable, I want to reload an active record after saving it. -- Malcolm Cook
function Reload() function Reload()
{ {
$db =& $this->DB(); if (!$db) return false; $db = $this->DB();
$table =& $this->TableInfo(); if (!$db) {
return false;
}
$table = $this->TableInfo();
$where = $this->GenWhere($db, $table); $where = $this->GenWhere($db, $table);
return($this->Load($where)); return($this->Load($where));
} }
@@ -576,9 +663,10 @@ class ADODB_Active_Record {
if (sizeof($row) == 2 * sizeof($table->flds)) { if (sizeof($row) == 2 * sizeof($table->flds)) {
// Only keep string keys // Only keep string keys
$keys = array_filter(array_keys($row), 'is_string'); $keys = array_filter(array_keys($row), 'is_string');
if (sizeof($keys) == sizeof($table->flds)) if (sizeof($keys) == sizeof($table->flds)) {
$bad_size = FALSE; $bad_size = FALSE;
} }
}
if ($bad_size) { if ($bad_size) {
$this->Error("Table structure of $this->_table has changed","Load"); $this->Error("Table structure of $this->_table has changed","Load");
return false; return false;
@@ -605,10 +693,12 @@ class ADODB_Active_Record {
// get last inserted id for INSERT // get last inserted id for INSERT
function LastInsertID(&$db,$fieldname) function LastInsertID(&$db,$fieldname)
{ {
if ($db->hasInsertID) if ($db->hasInsertID) {
$val = $db->Insert_ID($this->_table,$fieldname); $val = $db->Insert_ID($this->_table,$fieldname);
else }
else {
$val = false; $val = false;
}
if (is_null($val) || $val === false) { if (is_null($val) || $val === false) {
// this might not work reliably in multi-user environment // this might not work reliably in multi-user environment
@@ -621,18 +711,26 @@ class ADODB_Active_Record {
function doquote(&$db, $val,$t) function doquote(&$db, $val,$t)
{ {
switch($t) { switch($t) {
case 'L':
if (strpos($db->databaseType,'postgres') !== false) {
return $db->qstr($val);
}
case 'D': case 'D':
case 'T': case 'T':
if (empty($val)) return 'null'; if (empty($val)) {
return 'null';
}
case 'B': case 'B':
case 'N': case 'N':
case 'C': case 'C':
case 'X': case 'X':
if (is_null($val)) return 'null'; if (is_null($val)) {
return 'null';
}
if (strlen($val)>1 && if (strlen($val)>0 &&
(strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) { (strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")
) {
return $db->qstr($val); return $db->qstr($val);
break; break;
} }
@@ -660,37 +758,60 @@ class ADODB_Active_Record {
function _QName($n,$db=false) function _QName($n,$db=false)
{ {
if (!ADODB_Active_Record::$_quoteNames) return $n; if (!ADODB_Active_Record::$_quoteNames) {
if (!$db) $db = $this->DB(); if (!$db) return false; return $n;
}
if (!$db) {
$db = $this->DB();
if (!$db) {
return false;
}
}
return $db->nameQuote.$n.$db->nameQuote; return $db->nameQuote.$n.$db->nameQuote;
} }
//------------------------------------------------------------ Public functions below //------------------------------------------------------------ Public functions below
function Load($where=null,$bindarr=false) function Load($where=null,$bindarr=false, $lock = false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$db = $this->DB(); if (!$db) return false; $db = $this->DB();
if (!$db) {
return false;
}
$this->_where = $where; $this->_where = $where;
$save = $ADODB_FETCH_MODE; $save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM; $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false); if ($db->fetchMode !== false) {
$savem = $db->SetFetchMode(false);
}
$qry = "select * from ".$this->_table; $qry = "select * from ".$this->_table;
if($where) { if($where) {
$qry .= ' WHERE '.$where; $qry .= ' WHERE '.$where;
} }
if ($lock) {
$qry .= $this->lockMode;
}
$row = $db->GetRow($qry,$bindarr); $row = $db->GetRow($qry,$bindarr);
if (isset($savem)) $db->SetFetchMode($savem); if (isset($savem)) {
$db->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save; $ADODB_FETCH_MODE = $save;
return $this->Set($row); return $this->Set($row);
} }
function LoadLocked($where=null, $bindarr=false)
{
$this->Load($where,$bindarr,true);
}
# useful for multiple record inserts # useful for multiple record inserts
# see http://phplens.com/lens/lensforum/msgs.php?id=17795 # see http://phplens.com/lens/lensforum/msgs.php?id=17795
function Reset() function Reset()
@@ -712,8 +833,12 @@ class ADODB_Active_Record {
// false on error // false on error
function Save() function Save()
{ {
if ($this->_saved) $ok = $this->Update(); if ($this->_saved) {
else $ok = $this->Insert(); $ok = $this->Update();
}
else {
$ok = $this->Insert();
}
return $ok; return $ok;
} }
@@ -722,7 +847,10 @@ class ADODB_Active_Record {
// false on error // false on error
function Insert() function Insert()
{ {
$db = $this->DB(); if (!$db) return false; $db = $this->DB();
if (!$db) {
return false;
}
$cnt = 0; $cnt = 0;
$table = $this->TableInfo(); $table = $this->TableInfo();
@@ -772,7 +900,10 @@ class ADODB_Active_Record {
function Delete() function Delete()
{ {
$db = $this->DB(); if (!$db) return false; $db = $this->DB();
if (!$db) {
return false;
}
$table = $this->TableInfo(); $table = $this->TableInfo();
$where = $this->GenWhere($db,$table); $where = $this->GenWhere($db,$table);
@@ -785,7 +916,10 @@ class ADODB_Active_Record {
// returns an array of active record objects // returns an array of active record objects
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()) function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array())
{ {
$db = $this->DB(); if (!$db || empty($this->_table)) return false; $db = $this->DB();
if (!$db || empty($this->_table)) {
return false;
}
$arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr,$extra); $arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr,$extra);
return $arr; return $arr;
} }
@@ -795,7 +929,10 @@ class ADODB_Active_Record {
{ {
global $ADODB_ASSOC_CASE; global $ADODB_ASSOC_CASE;
$db = $this->DB(); if (!$db) return false; $db = $this->DB();
if (!$db) {
return false;
}
$table = $this->TableInfo(); $table = $this->TableInfo();
$pkey = $table->keys; $pkey = $table->keys;
@@ -805,7 +942,9 @@ class ADODB_Active_Record {
/* /*
if (is_null($val)) { if (is_null($val)) {
if (isset($fld->not_null) && $fld->not_null) { if (isset($fld->not_null) && $fld->not_null) {
if (isset($fld->default_value) && strlen($fld->default_value)) continue; if (isset($fld->default_value) && strlen($fld->default_value)) {
continue;
}
else { else {
$this->Error("Cannot update null into $name","Replace"); $this->Error("Cannot update null into $name","Replace");
return false; return false;
@@ -816,22 +955,28 @@ class ADODB_Active_Record {
continue; continue;
} }
if (is_array($val)) continue; if (is_array($val)) {
continue;
}
$t = $db->MetaType($fld->type); $t = $db->MetaType($fld->type);
$arr[$name] = $this->doquote($db,$val,$t); $arr[$name] = $this->doquote($db,$val,$t);
$valarr[] = $val; $valarr[] = $val;
} }
if (!is_array($pkey)) $pkey = array($pkey); if (!is_array($pkey)) {
$pkey = array($pkey);
}
if ($ADODB_ASSOC_CASE == 0) {
if ($ADODB_ASSOC_CASE == 0)
foreach($pkey as $k => $v) foreach($pkey as $k => $v)
$pkey[$k] = strtolower($v); $pkey[$k] = strtolower($v);
elseif ($ADODB_ASSOC_CASE == 1) }
foreach($pkey as $k => $v) elseif ($ADODB_ASSOC_CASE == 1) {
foreach($pkey as $k => $v) {
$pkey[$k] = strtoupper($v); $pkey[$k] = strtoupper($v);
}
}
$ok = $db->Replace($this->_table,$arr,$pkey); $ok = $db->Replace($this->_table,$arr,$pkey);
if ($ok) { if ($ok) {
@@ -858,7 +1003,10 @@ class ADODB_Active_Record {
// returns 0 on error, 1 on update, -1 if no change in data (no update) // returns 0 on error, 1 on update, -1 if no change in data (no update)
function Update() function Update()
{ {
$db = $this->DB(); if (!$db) return false; $db = $this->DB();
if (!$db) {
return false;
}
$table = $this->TableInfo(); $table = $this->TableInfo();
$where = $this->GenWhere($db, $table); $where = $this->GenWhere($db, $table);
@@ -877,12 +1025,15 @@ class ADODB_Active_Record {
$val = $this->$name; $val = $this->$name;
$neworig[] = $val; $neworig[] = $val;
if (isset($table->keys[$name]) || is_array($val)) if (isset($table->keys[$name]) || is_array($val)) {
continue; continue;
}
if (is_null($val)) { if (is_null($val)) {
if (isset($fld->not_null) && $fld->not_null) { if (isset($fld->not_null) && $fld->not_null) {
if (isset($fld->default_value) && strlen($fld->default_value)) continue; if (isset($fld->default_value) && strlen($fld->default_value)) {
continue;
}
else { else {
$this->Error("Cannot set field $name to NULL","Update"); $this->Error("Cannot set field $name to NULL","Update");
return false; return false;
@@ -890,16 +1041,24 @@ class ADODB_Active_Record {
} }
} }
if (isset($this->_original[$i]) && $val == $this->_original[$i]) { if (isset($this->_original[$i]) && strcmp($val,$this->_original[$i]) == 0) {
continue; continue;
} }
if (is_null($this->_original[$i]) && is_null($val)) {
continue;
}
$valarr[] = $val; $valarr[] = $val;
$pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt); $pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt);
$cnt += 1; $cnt += 1;
} }
if (!$cnt) return -1; if (!$cnt) {
return -1;
}
$sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where; $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where;
$ok = $db->Execute($sql,$valarr); $ok = $db->Execute($sql,$valarr);
if ($ok) { if ($ok) {
@@ -912,25 +1071,27 @@ class ADODB_Active_Record {
function GetAttributeNames() function GetAttributeNames()
{ {
$table = $this->TableInfo(); $table = $this->TableInfo();
if (!$table) return false; if (!$table) {
return false;
}
return array_keys($table->flds); return array_keys($table->flds);
} }
}; };
function adodb_GetActiveRecordsClass(&$db, $class, $table,$whereOrderBy,$bindarr, $primkeyArr, function adodb_GetActiveRecordsClass(&$db, $class, $table,$whereOrderBy,$bindarr, $primkeyArr,
$extra) $extra)
{ {
global $_ADODB_ACTIVE_DBS; global $_ADODB_ACTIVE_DBS;
$save = $db->SetFetchMode(ADODB_FETCH_NUM); $save = $db->SetFetchMode(ADODB_FETCH_NUM);
$qry = "select * from ".$table; $qry = "select * from ".$table;
if (!empty($whereOrderBy)) if (!empty($whereOrderBy)) {
$qry .= ' WHERE '.$whereOrderBy; $qry .= ' WHERE '.$whereOrderBy;
if(isset($extra['limit'])) }
{ if(isset($extra['limit'])) {
$rows = false; $rows = false;
if(isset($extra['offset'])) { if(isset($extra['offset'])) {
$rs = $db->SelectLimit($qry, $extra['limit'], $extra['offset'],$bindarr); $rs = $db->SelectLimit($qry, $extra['limit'], $extra['offset'],$bindarr);
@@ -979,4 +1140,3 @@ $extra)
return $arr; return $arr;
} }
?>

File diff suppressed because it is too large Load Diff

View File

@@ -8,31 +8,33 @@ $ADODB_INCLUDED_CSV = 1;
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
Released under both BSD license and Lesser GPL library license. @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
Whenever there is any discrepancy between the two licenses, @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
the BSD license will take precedence. See License.txt. Released under both BSD license and Lesser GPL library license.
Set tabs to 4 for best viewing. Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Library for CSV serialization. This is used by the csv/proxy driver and is the Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format. CacheExecute() serialization format.
==== NOTE ==== ==== NOTE ====
Format documented at http://php.weblogs.com/ADODB_CSV Format documented at http://php.weblogs.com/ADODB_CSV
============== ==============
*/ */
/** /**
* convert a recordset into special format * convert a recordset into special format
* *
* @param rs the recordset * @param rs the recordset
* *
* @return the CSV formated data * @return the CSV formated data
*/ */
function _rs2serialize(&$rs,$conn=false,$sql='') function _rs2serialize(&$rs,$conn=false,$sql='')
{ {
$max = ($rs) ? $rs->FieldCount() : 0; $max = ($rs) ? $rs->FieldCount() : 0;
if ($sql) $sql = urlencode($sql); if ($sql) $sql = urlencode($sql);
@@ -77,22 +79,22 @@ function _rs2serialize(&$rs,$conn=false,$sql='')
$rs2->InitArrayFields($rows,$flds); $rs2->InitArrayFields($rows,$flds);
$rs2->fetchMode = $savefetch; $rs2->fetchMode = $savefetch;
return $line.serialize($rs2); return $line.serialize($rs2);
} }
/** /**
* Open CSV file and convert it into Data. * Open CSV file and convert it into Data.
* *
* @param url file/ftp/http url * @param url file/ftp/http url
* @param err returns the error message * @param err returns the error message
* @param timeout dispose if recordset has been alive for $timeout secs * @param timeout dispose if recordset has been alive for $timeout secs
* *
* @return recordset, or false if error occured. If no * @return recordset, or false if error occured. If no
* error occurred in sql INSERT/UPDATE/DELETE, * error occurred in sql INSERT/UPDATE/DELETE,
* empty recordset is returned * empty recordset is returned
*/ */
function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
{ {
$false = false; $false = false;
$err = false; $err = false;
$fp = @fopen($url,'rb'); $fp = @fopen($url,'rb');
@@ -257,15 +259,15 @@ function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
$rs->timeCreated = $ttl; $rs->timeCreated = $ttl;
$rs->InitArrayFields($arr,$flds); $rs->InitArrayFields($arr,$flds);
return $rs; return $rs;
} }
/** /**
* Save a file $filename and its $contents (normally for caching) with file locking * Save a file $filename and its $contents (normally for caching) with file locking
* Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked) * Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked)
*/ */
function adodb_write_file($filename, $contents,$debug=false) function adodb_write_file($filename, $contents,$debug=false)
{ {
# http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
# So to simulate locking, we assume that rename is an atomic operation. # So to simulate locking, we assume that rename is an atomic operation.
# First we delete $filename, then we create a $tempfile write to it and # First we delete $filename, then we create a $tempfile write to it and
@@ -292,7 +294,7 @@ function adodb_write_file($filename, $contents,$debug=false)
// the tricky moment // the tricky moment
@unlink($filename); @unlink($filename);
if (!@rename($tmpname,$filename)) { if (!@rename($tmpname,$filename)) {
unlink($tmpname); @unlink($tmpname);
$ok = 0; $ok = 0;
} }
if (!$ok) { if (!$ok) {
@@ -314,5 +316,4 @@ function adodb_write_file($filename, $contents,$debug=false)
} }
return $ok; return $ok;
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -11,23 +13,23 @@
DOCUMENTATION: DOCUMENTATION:
See adodb/tests/test-datadict.php for docs and examples. See adodb/tests/test-datadict.php for docs and examples.
*/ */
/* /*
Test script for parser Test script for parser
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
function Lens_ParseTest() function Lens_ParseTest()
{ {
$str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds"; $str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds";
print "<p>$str</p>"; print "<p>$str</p>";
$a= Lens_ParseArgs($str); $a= Lens_ParseArgs($str);
print "<pre>"; print "<pre>";
print_r($a); print_r($a);
print "</pre>"; print "</pre>";
} }
@@ -50,7 +52,7 @@ if (!function_exists('ctype_alnum')) {
@param endstmtchar Character that indicates end of statement @param endstmtchar Character that indicates end of statement
@param tokenchars Include the following characters in tokens apart from A-Z and 0-9 @param tokenchars Include the following characters in tokens apart from A-Z and 0-9
@returns 2 dimensional array containing parsed tokens. @returns 2 dimensional array containing parsed tokens.
*/ */
function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-') function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-')
{ {
$pos = 0; $pos = 0;
@@ -590,6 +592,8 @@ class ADODB_DataDict {
return $sql; return $sql;
} }
function _GenFields($flds,$widespacing=false) function _GenFields($flds,$widespacing=false)
{ {
if (is_string($flds)) { if (is_string($flds)) {
@@ -913,6 +917,21 @@ class ADODB_DataDict {
return $newopts; return $newopts;
} }
function _getSizePrec($size)
{
$fsize = false;
$fprec = false;
$dotat = strpos($size,'.');
if ($dotat === false) $dotat = strpos($size,',');
if ($dotat === false) $fsize = $size;
else {
$fsize = substr($size,0,$dotat);
$fprec = substr($size,$dotat+1);
}
return array($fsize, $fprec);
}
/** /**
"Florian Buzin [ easywe ]" <florian.buzin#easywe.de> "Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
@@ -958,9 +977,16 @@ class ADODB_DataDict {
$c = $cols[$k]; $c = $cols[$k];
$ml = $c->max_length; $ml = $c->max_length;
$mt = $this->MetaType($c->type,$ml); $mt = $this->MetaType($c->type,$ml);
if (isset($c->scale)) $sc = $c->scale;
else $sc = 99; // always force change if scale not known.
if ($sc == -1) $sc = false;
list($fsize, $fprec) = $this->_getSizePrec($v['SIZE']);
if ($ml == -1) $ml = ''; if ($ml == -1) $ml = '';
if ($mt == 'X') $ml = $v['SIZE']; if ($mt == 'X') $ml = $v['SIZE'];
if (($mt != $v['TYPE']) || $ml != $v['SIZE'] || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) { if (($mt != $v['TYPE']) || ($ml != $fsize || $sc != $fprec) || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) {
$holdflds[$k] = $v; $holdflds[$k] = $v;
} }
} else { } else {
@@ -1005,4 +1031,3 @@ class ADODB_DataDict {
return $sql; return $sql;
} }
} // class } // class
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@@ -41,11 +43,14 @@ if (!defined("DB_ERROR_SYNTAX")) {
define("DB_ERROR_EXTENSION_NOT_FOUND",-25); define("DB_ERROR_EXTENSION_NOT_FOUND",-25);
define("DB_ERROR_NOSUCHDB", -25); define("DB_ERROR_NOSUCHDB", -25);
define("DB_ERROR_ACCESS_VIOLATION", -26); define("DB_ERROR_ACCESS_VIOLATION", -26);
define("DB_ERROR_DEADLOCK", -27);
define("DB_ERROR_STATEMENT_TIMEOUT", -28);
define("DB_ERROR_SERIALIZATION_FAILURE", -29);
} }
function adodb_errormsg($value) function adodb_errormsg($value)
{ {
global $ADODB_LANG,$ADODB_LANG_ARRAY; global $ADODB_LANG,$ADODB_LANG_ARRAY;
if (empty($ADODB_LANG)) $ADODB_LANG = 'en'; if (empty($ADODB_LANG)) $ADODB_LANG = 'en';
if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ; if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ;
@@ -91,20 +96,23 @@ function adodb_error($provider,$dbType,$errno)
function adodb_error_pg($errormsg) function adodb_error_pg($errormsg)
{ {
if (is_numeric($errormsg)) return (integer) $errormsg; if (is_numeric($errormsg)) return (integer) $errormsg;
// Postgres has no lock-wait timeout. The best we could do would be to set a statement timeout.
static $error_regexps = array( static $error_regexps = array(
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/i' => DB_ERROR_NOSUCHTABLE, '(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$' => DB_ERROR_NOSUCHTABLE,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/i' => DB_ERROR_ALREADY_EXISTS, 'Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint' => DB_ERROR_ALREADY_EXISTS,
'/divide by zero$/i' => DB_ERROR_DIVZERO, 'database ".+" does not exist$' => DB_ERROR_NOSUCHDB,
'/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER, '(divide|division) by zero$' => DB_ERROR_DIVZERO,
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD, 'pg_atoi: error in .*: can\'t parse ' => DB_ERROR_INVALID_NUMBER,
'/parser: parse error at or near \"/i' => DB_ERROR_SYNTAX, 'ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']' => DB_ERROR_NOSUCHFIELD,
'/referential integrity violation/i' => DB_ERROR_CONSTRAINT, '(parser: parse|syntax) error at or near \"' => DB_ERROR_SYNTAX,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/i' 'referential integrity violation' => DB_ERROR_CONSTRAINT,
=> DB_ERROR_ALREADY_EXISTS 'deadlock detected$' => DB_ERROR_DEADLOCK,
'canceling statement due to statement timeout$' => DB_ERROR_STATEMENT_TIMEOUT,
'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
); );
reset($error_regexps); reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) { while (list($regexp,$code) = each($error_regexps)) {
if (preg_match($regexp, $errormsg)) { if (preg_match("/$regexp/mi", $errormsg)) {
return $code; return $code;
} }
} }
@@ -114,7 +122,7 @@ function adodb_error_pg($errormsg)
function adodb_error_odbc() function adodb_error_odbc()
{ {
static $MAP = array( static $MAP = array(
'01004' => DB_ERROR_TRUNCATED, '01004' => DB_ERROR_TRUNCATED,
'07001' => DB_ERROR_MISMATCH, '07001' => DB_ERROR_MISMATCH,
'21S01' => DB_ERROR_MISMATCH, '21S01' => DB_ERROR_MISMATCH,
@@ -145,7 +153,7 @@ function adodb_error_odbc()
function adodb_error_ibase() function adodb_error_ibase()
{ {
static $MAP = array( static $MAP = array(
-104 => DB_ERROR_SYNTAX, -104 => DB_ERROR_SYNTAX,
-150 => DB_ERROR_ACCESS_VIOLATION, -150 => DB_ERROR_ACCESS_VIOLATION,
-151 => DB_ERROR_ACCESS_VIOLATION, -151 => DB_ERROR_ACCESS_VIOLATION,
@@ -175,7 +183,7 @@ function adodb_error_ibase()
function adodb_error_ifx() function adodb_error_ifx()
{ {
static $MAP = array( static $MAP = array(
'-201' => DB_ERROR_SYNTAX, '-201' => DB_ERROR_SYNTAX,
'-206' => DB_ERROR_NOSUCHTABLE, '-206' => DB_ERROR_NOSUCHTABLE,
'-217' => DB_ERROR_NOSUCHFIELD, '-217' => DB_ERROR_NOSUCHFIELD,
@@ -193,7 +201,7 @@ function adodb_error_ifx()
function adodb_error_oci8() function adodb_error_oci8()
{ {
static $MAP = array( static $MAP = array(
1 => DB_ERROR_ALREADY_EXISTS, 1 => DB_ERROR_ALREADY_EXISTS,
900 => DB_ERROR_SYNTAX, 900 => DB_ERROR_SYNTAX,
904 => DB_ERROR_NOSUCHFIELD, 904 => DB_ERROR_NOSUCHFIELD,
@@ -212,7 +220,7 @@ function adodb_error_oci8()
function adodb_error_mssql() function adodb_error_mssql()
{ {
static $MAP = array( static $MAP = array(
208 => DB_ERROR_NOSUCHTABLE, 208 => DB_ERROR_NOSUCHTABLE,
2601 => DB_ERROR_ALREADY_EXISTS 2601 => DB_ERROR_ALREADY_EXISTS
); );
@@ -222,7 +230,7 @@ function adodb_error_mssql()
function adodb_error_sqlite() function adodb_error_sqlite()
{ {
static $MAP = array( static $MAP = array(
1 => DB_ERROR_SYNTAX 1 => DB_ERROR_SYNTAX
); );
@@ -231,7 +239,7 @@ function adodb_error_sqlite()
function adodb_error_mysql() function adodb_error_mysql()
{ {
static $MAP = array( static $MAP = array(
1004 => DB_ERROR_CANNOT_CREATE, 1004 => DB_ERROR_CANNOT_CREATE,
1005 => DB_ERROR_CANNOT_CREATE, 1005 => DB_ERROR_CANNOT_CREATE,
1006 => DB_ERROR_CANNOT_CREATE, 1006 => DB_ERROR_CANNOT_CREATE,
@@ -255,4 +263,3 @@ function adodb_error_mysql()
return $MAP; return $MAP;
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@@ -9,7 +11,7 @@
* *
* Latest version is available at http://php.weblogs.com * Latest version is available at http://php.weblogs.com
* *
*/ */
// added Claudio Bustos clbustos#entelchile.net // added Claudio Bustos clbustos#entelchile.net
@@ -18,16 +20,16 @@ if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_US
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler'); if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
/** /**
* Default Error Handler. This will be called with the following params * Default Error Handler. This will be called with the following params
* *
* @param $dbms the RDBMS you are connecting to * @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase) * @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database * @param $errno the native error number from the database
* @param $errmsg the native error msg from the database * @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below * @param $p1 $fn specific parameter - see below
* @param $p2 $fn specific parameter - see below * @param $p2 $fn specific parameter - see below
* @param $thisConn $current connection object - can be false if no connection object created * @param $thisConn $current connection object - can be false if no connection object created
*/ */
function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
{ {
if (error_reporting() == 0) return; // obey @ protocol if (error_reporting() == 0) return; // obey @ protocol
@@ -76,4 +78,3 @@ function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnec
//print "<p>$s</p>"; //print "<p>$s</p>";
trigger_error($s,ADODB_ERROR_HANDLER_TYPE); trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -9,39 +11,39 @@
* *
* Latest version is available at http://php.weblogs.com * Latest version is available at http://php.weblogs.com
* *
*/ */
include_once('PEAR.php'); include_once('PEAR.php');
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR'); if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
/* /*
* Enabled the following if you want to terminate scripts when an error occurs * Enabled the following if you want to terminate scripts when an error occurs
*/ */
//PEAR::setErrorHandling (PEAR_ERROR_DIE); //PEAR::setErrorHandling (PEAR_ERROR_DIE);
/* /*
* Name of the PEAR_Error derived class to call. * Name of the PEAR_Error derived class to call.
*/ */
if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error'); if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
/* /*
* Store the last PEAR_Error object here * Store the last PEAR_Error object here
*/ */
global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false; global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
/** /**
* Error Handler with PEAR support. This will be called with the following params * Error Handler with PEAR support. This will be called with the following params
* *
* @param $dbms the RDBMS you are connecting to * @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase) * @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database * @param $errno the native error number from the database
* @param $errmsg the native error msg from the database * @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below * @param $p1 $fn specific parameter - see below
* @param $P2 $fn specific parameter - see below * @param $P2 $fn specific parameter - see below
*/ */
function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
{ {
global $ADODB_Last_PEAR_Error; global $ADODB_Last_PEAR_Error;
if (error_reporting() == 0) return; // obey @ protocol if (error_reporting() == 0) return; // obey @ protocol
switch($fn) { switch($fn) {
@@ -75,14 +77,12 @@ function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
} }
/** /**
* Returns last PEAR_Error object. This error might be for an error that * Returns last PEAR_Error object. This error might be for an error that
* occured several sql statements ago. * occured several sql statements ago.
*/ */
function ADODB_PEAR_Error() function ADODB_PEAR_Error()
{ {
global $ADODB_Last_PEAR_Error; global $ADODB_Last_PEAR_Error;
return $ADODB_Last_PEAR_Error; return $ADODB_Last_PEAR_Error;
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/** /**
* @version V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@@ -18,20 +20,20 @@ if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_US
define('ADODB_ERROR_HANDLER','adodb_throw'); define('ADODB_ERROR_HANDLER','adodb_throw');
class ADODB_Exception extends Exception { class ADODB_Exception extends Exception {
var $dbms; var $dbms;
var $fn; var $fn;
var $sql = ''; var $sql = '';
var $params = ''; var $params = '';
var $host = ''; var $host = '';
var $database = ''; var $database = '';
function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{ {
switch($fn) { switch($fn) {
case 'EXECUTE': case 'EXECUTE':
$this->sql = $p1; $this->sql = is_array($p1) ? $p1[0] : $p1;
$this->params = $p2; $this->params = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n"; $s = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")\n";
break; break;
case 'PCONNECT': case 'PCONNECT':
@@ -58,25 +60,22 @@ class ADODB_Exception extends Exception {
} }
/** /**
* Default Error Handler. This will be called with the following params * Default Error Handler. This will be called with the following params
* *
* @param $dbms the RDBMS you are connecting to * @param $dbms the RDBMS you are connecting to
* @param $fn the name of the calling function (in uppercase) * @param $fn the name of the calling function (in uppercase)
* @param $errno the native error number from the database * @param $errno the native error number from the database
* @param $errmsg the native error msg from the database * @param $errmsg the native error msg from the database
* @param $p1 $fn specific parameter - see below * @param $p1 $fn specific parameter - see below
* @param $P2 $fn specific parameter - see below * @param $P2 $fn specific parameter - see below
*/ */
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{ {
global $ADODB_EXCEPTION; global $ADODB_EXCEPTION;
if (error_reporting() == 0) return; // obey @ protocol if (error_reporting() == 0) return; // obey @ protocol
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION; if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
else $errfn = 'ADODB_EXCEPTION'; else $errfn = 'ADODB_EXCEPTION';
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -22,9 +24,3 @@
Moved to adodb.inc.php to improve performance. Moved to adodb.inc.php to improve performance.
*/ */
?>

View File

@@ -1,8 +1,4 @@
<?php <?php
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -10,21 +6,23 @@ global $ADODB_INCLUDED_LIB;
$ADODB_INCLUDED_LIB = 1; $ADODB_INCLUDED_LIB = 1;
/* /*
@version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim\@natsoft.com.my). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Less commonly used functions are placed here to reduce size of adodb.inc.php. Less commonly used functions are placed here to reduce size of adodb.inc.php.
*/ */
function adodb_strip_order_by($sql) function adodb_strip_order_by($sql)
{ {
$rez = preg_match('/(\sORDER\s+BY\s[^)]*)/is',$sql,$arr); $rez = preg_match('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $arr);
if ($arr) if ($arr)
if (strpos($arr[0],'(') !== false) { if (strpos($arr[1], '(') !== false) {
$at = strpos($sql,$arr[0]); $at = strpos($sql, $arr[1]);
$cntin = 0; $cntin = 0;
for ($i=$at, $max=strlen($sql); $i < $max; $i++) { for ($i=$at, $max=strlen($sql); $i < $max; $i++) {
$ch = $sql[$i]; $ch = $sql[$i];
@@ -38,8 +36,9 @@ function adodb_strip_order_by($sql)
} }
} }
$sql = substr($sql,0,$at).substr($sql,$i); $sql = substr($sql,0,$at).substr($sql,$i);
} else } else {
$sql = str_replace($arr[0], '', $sql); $sql = str_replace($arr[1], '', $sql);
}
return $sql; return $sql;
} }
@@ -51,7 +50,7 @@ if (false) {
function adodb_probetypes(&$array,&$types,$probe=8) function adodb_probetypes(&$array,&$types,$probe=8)
{ {
// probe and guess the type // probe and guess the type
$types = array(); $types = array();
if ($probe > sizeof($array)) $max = sizeof($array); if ($probe > sizeof($array)) $max = sizeof($array);
else $max = $probe; else $max = $probe;
@@ -215,7 +214,7 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
$size=0, $selectAttr='',$compareFields0=true) $size=0, $selectAttr='',$compareFields0=true)
{ {
$hasvalue = false; $hasvalue = false;
@@ -261,7 +260,7 @@ $size=0, $selectAttr='',$compareFields0=true)
if ($fieldsize > 2) { if ($fieldsize > 2) {
$group = rtrim($zthis->fields[2]); $group = rtrim($zthis->fields[2]);
} }
/* /*
if ($optgroup != $group) { if ($optgroup != $group) {
$optgroup = $group; $optgroup = $group;
if ($firstgroup) { if ($firstgroup) {
@@ -272,7 +271,7 @@ $size=0, $selectAttr='',$compareFields0=true)
$s .="\n<optgroup label='". htmlspecialchars($group) ."'>"; $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
} }
} }
*/ */
if ($hasvalue) if ($hasvalue)
$value = " value='".htmlspecialchars($zval2)."'"; $value = " value='".htmlspecialchars($zval2)."'";
@@ -301,7 +300,7 @@ $size=0, $selectAttr='',$compareFields0=true)
// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM // Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
$size=0, $selectAttr='',$compareFields0=true) $size=0, $selectAttr='',$compareFields0=true)
{ {
$hasvalue = false; $hasvalue = false;
@@ -397,7 +396,7 @@ $size=0, $selectAttr='',$compareFields0=true)
$conn->Connect(...); $conn->Connect(...);
$cnt = _adodb_getcount($conn, $sql); $cnt = _adodb_getcount($conn, $sql);
*/ */
function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
{ {
$qryRecs = 0; $qryRecs = 0;
@@ -424,8 +423,11 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
} }
} else { } else {
// now replace SELECT ... FROM with SELECT COUNT(*) FROM // now replace SELECT ... FROM with SELECT COUNT(*) FROM
$rewritesql = preg_replace( if ( strpos($sql, '_ADODB_COUNT') !== FALSE ) {
'/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); $rewritesql = preg_replace('/^\s*?SELECT\s+_ADODB_COUNT(.*)_ADODB_COUNT\s/is','SELECT COUNT(*) ',$sql);
} else {
$rewritesql = preg_replace('/^\s*?SELECT\s.*?\s+(.*?)\s+FROM\s/is','SELECT COUNT(*) FROM ',$sql);
}
// fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
// with mssql, access and postgresql. Also a good speedup optimization - skips sorting! // with mssql, access and postgresql. Also a good speedup optimization - skips sorting!
// also see http://phplens.com/lens/lensforum/msgs.php?id=12752 // also see http://phplens.com/lens/lensforum/msgs.php?id=12752
@@ -455,9 +457,13 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0];
if ($secs2cache) {
$rstest = $zthis->CacheExecute($secs2cache,$rewritesql,$inputarr);
if (!$rstest) $rstest = $zthis->CacheExecute($secs2cache,$sql,$inputarr);
} else {
$rstest = $zthis->Execute($rewritesql,$inputarr); $rstest = $zthis->Execute($rewritesql,$inputarr);
if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr); if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr);
}
if ($rstest) { if ($rstest) {
$qryRecs = $rstest->RecordCount(); $qryRecs = $rstest->RecordCount();
if ($qryRecs == -1) { if ($qryRecs == -1) {
@@ -488,9 +494,9 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
Also if you are using CachePageExecute(), there is a strong possibility that Also if you are using CachePageExecute(), there is a strong possibility that
data will get out of synch. use CachePageExecute() only with tables that data will get out of synch. use CachePageExecute() only with tables that
rarely change. rarely change.
*/ */
function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
$inputarr=false, $secs2cache=0) $inputarr=false, $secs2cache=0)
{ {
$atfirstpage = false; $atfirstpage = false;
$atlastpage = false; $atlastpage = false;
@@ -542,46 +548,86 @@ $inputarr=false, $secs2cache=0)
return $rsreturn; return $rsreturn;
} }
// Iv<EFBFBD>n Oliva version // Iván Oliva version
function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
{ {
$atfirstpage = false; $atfirstpage = false;
$atlastpage = false; $atlastpage = false;
if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page if (!isset($page) || $page <= 1) {
// If page number <= 1, then we are at the first page
$page = 1; $page = 1;
$atfirstpage = true; $atfirstpage = true;
} }
if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page if ($nrows <= 0) {
// If an invalid nrows is supplied, we assume a default value of 10 rows per page
$nrows = 10;
}
// ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than $pagecounteroffset = ($page * $nrows) - $nrows;
// the last page number.
// To find out if there are more pages of rows, simply increase the limit or
// nrows by 1 and see if that number of records was returned. If it was,
// then we know there is at least one more page left, otherwise we are on
// the last page. Therefore allow non-Count() paging with single queries
// rather than three queries as was done before.
$test_nrows = $nrows + 1;
if ($secs2cache > 0) {
$rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
} else {
$rsreturn = $zthis->SelectLimit($sql, $test_nrows, $pagecounteroffset, $inputarr, $secs2cache);
}
// Now check to see if the number of rows returned was the higher value we asked for or not.
if ( $rsreturn->_numOfRows == $test_nrows ) {
// Still at least 1 more row, so we are not on last page yet...
// Remove the last row from the RS.
$rsreturn->_numOfRows = ( $rsreturn->_numOfRows - 1 );
} elseif ( $rsreturn->_numOfRows == 0 && $page > 1 ) {
// Likely requested a page that doesn't exist, so need to find the last
// page and return it. Revert to original method and loop through pages
// until we find some data...
$pagecounter = $page + 1; $pagecounter = $page + 1;
$pagecounteroffset = ($pagecounter * $nrows) - $nrows; $pagecounteroffset = ($pagecounter * $nrows) - $nrows;
if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); $rstest = $rsreturn;
if ($rstest) { if ($rstest) {
while ($rstest && $rstest->EOF && $pagecounter>0) { while ($rstest && $rstest->EOF && $pagecounter > 0) {
$atlastpage = true; $atlastpage = true;
$pagecounter--; $pagecounter--;
$pagecounteroffset = $nrows * ($pagecounter - 1); $pagecounteroffset = $nrows * ($pagecounter - 1);
$rstest->Close(); $rstest->Close();
if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); if ($secs2cache>0) {
else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
}
else {
$rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
}
} }
if ($rstest) $rstest->Close(); if ($rstest) $rstest->Close();
} }
if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it if ($atlastpage) {
// If we are at the last page or beyond it, we are going to retrieve it
$page = $pagecounter; $page = $pagecounter;
if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first if ($page == 1) {
//... page, that is, the recordset has only 1 page. // We have to do this again in case the last page is the same as
// the first page, that is, the recordset has only 1 page.
$atfirstpage = true;
}
} }
// We get the data we want // We get the data we want
$offset = $nrows * ($page-1); $offset = $nrows * ($page-1);
if ($secs2cache > 0) $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); if ($secs2cache > 0) {
else $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr);
}
else {
$rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
}
} elseif ( $rsreturn->_numOfRows < $test_nrows ) {
// Rows is less than what we asked for, so must be at the last page.
$atlastpage = true;
}
// Before returning the RecordSet, we set the pagination properties we need // Before returning the RecordSet, we set the pagination properties we need
if ($rsreturn) { if ($rsreturn) {
@@ -643,13 +689,19 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq
$type = 'C'; $type = 'C';
} }
if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) {
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; switch ($ADODB_QUOTE_FIELDNAMES) {
else case 'LOWER':
$fnameq = $zthis->nameQuote.strtolower($field->name).$zthis->nameQuote;break;
case 'NATIVE':
$fnameq = $zthis->nameQuote.$field->name.$zthis->nameQuote;break;
case 'UPPER':
default:
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;break;
}
} else
$fnameq = $upperfname; $fnameq = $upperfname;
// is_null requires php 4.0.4
//********************************************************// //********************************************************//
if (is_null($arrFields[$upperfname]) if (is_null($arrFields[$upperfname])
|| (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
@@ -754,9 +806,9 @@ function adodb_key_exists($key, &$arr,$force=2)
*/ */
function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2) function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
{ {
static $cacheRS = false; static $cacheRS = false;
static $cacheSig = 0; static $cacheSig = 0;
static $cacheCols; static $cacheCols;
global $ADODB_QUOTE_FIELDNAMES; global $ADODB_QUOTE_FIELDNAMES;
$tableName = ''; $tableName = '';
@@ -807,9 +859,17 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
$upperfname = strtoupper($field->name); $upperfname = strtoupper($field->name);
if (adodb_key_exists($upperfname,$arrFields,$force)) { if (adodb_key_exists($upperfname,$arrFields,$force)) {
$bad = false; $bad = false;
if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) {
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; switch ($ADODB_QUOTE_FIELDNAMES) {
else case 'LOWER':
$fnameq = $zthis->nameQuote.strtolower($field->name).$zthis->nameQuote;break;
case 'NATIVE':
$fnameq = $zthis->nameQuote.$field->name.$zthis->nameQuote;break;
case 'UPPER':
default:
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;break;
}
} else
$fnameq = $upperfname; $fnameq = $upperfname;
$type = $recordSet->MetaType($field->type); $type = $recordSet->MetaType($field->type);
@@ -1148,8 +1208,8 @@ function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0,$ishtml=null)
return $s; return $s;
} }
/* /*
function _adodb_find_from($sql) function _adodb_find_from($sql)
{ {
$sql = str_replace(array("\n","\r"), ' ', $sql); $sql = str_replace(array("\n","\r"), ' ', $sql);
$charCount = strlen($sql); $charCount = strlen($sql);
@@ -1187,7 +1247,5 @@ function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0,$ishtml=null)
return $i; return $i;
} }
} }
*/ */
?>

View File

@@ -7,17 +7,19 @@ global $ADODB_INCLUDED_MEMCACHE;
$ADODB_INCLUDED_MEMCACHE = 1; $ADODB_INCLUDED_MEMCACHE = 1;
global $ADODB_INCLUDED_CSV; global $ADODB_INCLUDED_CSV;
if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
/* /*
V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
Released under both BSD license and Lesser GPL library license. @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
Whenever there is any discrepancy between the two licenses, @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
the BSD license will take precedence. See License.txt. Released under both BSD license and Lesser GPL library license.
Set tabs to 4 for best viewing. Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Usage: Usage:
@@ -30,12 +32,12 @@ $db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses
$db->Connect(...); $db->Connect(...);
$db->CacheExecute($sql); $db->CacheExecute($sql);
Note the memcache class is shared by all connections, is created during the first call to Connect/PConnect. Note the memcache class is shared by all connections, is created during the first call to Connect/PConnect.
Class instance is stored in $ADODB_CACHE Class instance is stored in $ADODB_CACHE
*/ */
class ADODB_Cache_MemCache { class ADODB_Cache_MemCache {
var $createdir = false; // create caching directory structure? var $createdir = false; // create caching directory structure?
//----------------------------- //-----------------------------
@@ -48,7 +50,7 @@ class ADODB_Cache_MemCache {
var $_connected = false; var $_connected = false;
var $_memcache = false; var $_memcache = false;
function ADODB_Cache_MemCache(&$obj) function __construct(&$obj)
{ {
$this->hosts = $obj->memCacheHost; $this->hosts = $obj->memCacheHost;
$this->port = $obj->memCachePort; $this->port = $obj->memCachePort;
@@ -91,7 +93,7 @@ class ADODB_Cache_MemCache {
} }
if (!$this->_memcache) return false; if (!$this->_memcache) return false;
if (!$this->_memcache->set($filename, $contents, $this->compress, $secs2cache)) { if (!$this->_memcache->set($filename, $contents, $this->compress ? MEMCACHE_COMPRESSED : 0, $secs2cache)) {
if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n"); if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!<br>\n");
return false; return false;
} }
@@ -185,6 +187,4 @@ class ADODB_Cache_MemCache {
{ {
return true; return true;
} }
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -20,7 +22,7 @@
and no free support requests except for bug reports and no free support requests except for bug reports
will be entertained by the author. will be entertained by the author.
*/ */
class ADODB_Pager { class ADODB_Pager {
var $id; // unique id for pager (defaults to 'adodb') var $id; // unique id for pager (defaults to 'adodb')
var $db; // ADODB connection object var $db; // ADODB connection object
@@ -55,7 +57,7 @@ class ADODB_Pager {
// if you have multiple on 1 page. // if you have multiple on 1 page.
// $id should be only be [a-z0-9]* // $id should be only be [a-z0-9]*
// //
function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false) function __construct(&$db,$sql,$id = 'adodb', $showPageLinks = false)
{ {
global $PHP_SELF; global $PHP_SELF;
@@ -85,8 +87,7 @@ class ADODB_Pager {
global $PHP_SELF; global $PHP_SELF;
if ($anchor) { if ($anchor) {
?> ?>
<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> <a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp;
&nbsp;
<?php <?php
} else { } else {
print "$this->first &nbsp; "; print "$this->first &nbsp; ";
@@ -101,9 +102,7 @@ class ADODB_Pager {
if ($anchor) { if ($anchor) {
?> ?>
<a <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp;
href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a>
&nbsp;
<?php <?php
} else { } else {
print "$this->next &nbsp; "; print "$this->next &nbsp; ";
@@ -124,9 +123,7 @@ class ADODB_Pager {
if ($anchor) { if ($anchor) {
?> ?>
<a <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp;
href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a>
&nbsp;
<?php <?php
} else { } else {
print "$this->last &nbsp; "; print "$this->last &nbsp; ";
@@ -175,9 +172,7 @@ class ADODB_Pager {
global $PHP_SELF; global $PHP_SELF;
if ($anchor) { if ($anchor) {
?> ?>
<a <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp;
href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a>
&nbsp;
<?php <?php
} else { } else {
print "$this->prev &nbsp; "; print "$this->prev &nbsp; ";
@@ -292,6 +287,3 @@ class ADODB_Pager {
"</td></tr></table>"; "</td></tr></table>";
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@@ -13,7 +15,7 @@
* and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group. * and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
*/ */
/* /*
We support: We support:
DB_Common DB_Common
@@ -49,46 +51,42 @@ include_once ADODB_PEAR."/adodb-errorpear.inc.php";
include_once ADODB_PEAR."/adodb.inc.php"; include_once ADODB_PEAR."/adodb.inc.php";
if (!defined('DB_OK')) { if (!defined('DB_OK')) {
define("DB_OK", 1); define("DB_OK", 1);
define("DB_ERROR",-1); define("DB_ERROR",-1);
// autoExecute constants /**
define('DB_AUTOQUERY_INSERT', 1);
define('DB_AUTOQUERY_UPDATE', 2);
/**
* This is a special constant that tells DB the user hasn't specified * This is a special constant that tells DB the user hasn't specified
* any particular get mode, so the default should be used. * any particular get mode, so the default should be used.
*/ */
define('DB_FETCHMODE_DEFAULT', 0); define('DB_FETCHMODE_DEFAULT', 0);
/** /**
* Column data indexed by numbers, ordered from 0 and up * Column data indexed by numbers, ordered from 0 and up
*/ */
define('DB_FETCHMODE_ORDERED', 1); define('DB_FETCHMODE_ORDERED', 1);
/** /**
* Column data indexed by column names * Column data indexed by column names
*/ */
define('DB_FETCHMODE_ASSOC', 2); define('DB_FETCHMODE_ASSOC', 2);
/* for compatibility */ /* for compatibility */
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED);
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC);
/** /**
* these are constants for the tableInfo-function * these are constants for the tableInfo-function
* they are bitwised or'ed. so if there are more constants to be defined * they are bitwised or'ed. so if there are more constants to be defined
* in the future, adjust DB_TABLEINFO_FULL accordingly * in the future, adjust DB_TABLEINFO_FULL accordingly
*/ */
define('DB_TABLEINFO_ORDER', 1); define('DB_TABLEINFO_ORDER', 1);
define('DB_TABLEINFO_ORDERTABLE', 2); define('DB_TABLEINFO_ORDERTABLE', 2);
define('DB_TABLEINFO_FULL', 3); define('DB_TABLEINFO_FULL', 3);
} }
/** /**
@@ -370,5 +368,3 @@ class DB
return true; return true;
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
@@ -14,7 +16,7 @@
my needs. If you want to separate code from presentation, be my guest. Patches my needs. If you want to separate code from presentation, be my guest. Patches
are welcome. are welcome.
*/ */
if (!defined('ADODB_DIR')) include_once(dirname(__FILE__).'/adodb.inc.php'); if (!defined('ADODB_DIR')) include_once(dirname(__FILE__).'/adodb.inc.php');
include_once(ADODB_DIR.'/tohtml.inc.php'); include_once(ADODB_DIR.'/tohtml.inc.php');
@@ -201,18 +203,18 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
/* /*
The settings data structure is an associative array that database parameter per element. The settings data structure is an associative array that database parameter per element.
Each database parameter element in the array is itself an array consisting of: Each database parameter element in the array is itself an array consisting of:
0: category code, used to group related db parameters 0: category code, used to group related db parameters
1: either 1: either
a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'", a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'",
b. array holding sql string and field to look for, e.g. array('show variables','table_cache'), b. array holding sql string and field to look for, e.g. array('show variables','table_cache'),
c. a string prefixed by =, then a PHP method of the class is invoked, c. a string prefixed by =, then a PHP method of the class is invoked,
e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue', e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue',
2: description of the database parameter 2: description of the database parameter
*/ */
class adodb_perf { class adodb_perf {
var $conn; var $conn;
@@ -224,7 +226,7 @@ class adodb_perf {
var $cliFormat = "%32s => %s \r\n"; var $cliFormat = "%32s => %s \r\n";
var $sql1 = 'sql1'; // used for casting sql1 to text for mssql var $sql1 = 'sql1'; // used for casting sql1 to text for mssql
var $explain = true; var $explain = true;
var $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>"; var $helpurl = '<a href="http://adodb.sourceforge.net/docs-adodb.htm#logsql">LogSQL help</a>';
var $createTableSQL = false; var $createTableSQL = false;
var $maxLength = 2000; var $maxLength = 2000;
@@ -241,20 +243,20 @@ class adodb_perf {
// returns array with info to calculate CPU Load // returns array with info to calculate CPU Load
function _CPULoad() function _CPULoad()
{ {
/* /*
cpu 524152 2662 2515228 336057010 cpu 524152 2662 2515228 336057010
cpu0 264339 1408 1257951 168025827 cpu0 264339 1408 1257951 168025827
cpu1 259813 1254 1257277 168031181 cpu1 259813 1254 1257277 168031181
page 622307 25475680 page 622307 25475680
swap 24 1891 swap 24 1891
intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320) disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320)
ctxt 66155838 ctxt 66155838
btime 1062315585 btime 1062315585
processes 69293 processes 69293
*/ */
// Algorithm is taken from // Algorithm is taken from
// http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/414b0e1b-499c-411e-8a02-6a12e339c0f1/ // http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/414b0e1b-499c-411e-8a02-6a12e339c0f1/
if (strncmp(PHP_OS,'WIN',3)==0) { if (strncmp(PHP_OS,'WIN',3)==0) {
@@ -322,25 +324,25 @@ class adodb_perf {
/* /*
total: used: free: shared: buffers: cached: total: used: free: shared: buffers: cached:
Mem: 1055289344 917299200 137990144 0 165437440 599773184 Mem: 1055289344 917299200 137990144 0 165437440 599773184
Swap: 2146775040 11055104 2135719936 Swap: 2146775040 11055104 2135719936
MemTotal: 1030556 kB MemTotal: 1030556 kB
MemFree: 134756 kB MemFree: 134756 kB
MemShared: 0 kB MemShared: 0 kB
Buffers: 161560 kB Buffers: 161560 kB
Cached: 581384 kB Cached: 581384 kB
SwapCached: 4332 kB SwapCached: 4332 kB
Active: 494468 kB Active: 494468 kB
Inact_dirty: 322856 kB Inact_dirty: 322856 kB
Inact_clean: 24256 kB Inact_clean: 24256 kB
Inact_target: 168316 kB Inact_target: 168316 kB
HighTotal: 131064 kB HighTotal: 131064 kB
HighFree: 1024 kB HighFree: 1024 kB
LowTotal: 899492 kB LowTotal: 899492 kB
LowFree: 133732 kB LowFree: 133732 kB
SwapTotal: 2096460 kB SwapTotal: 2096460 kB
SwapFree: 2085664 kB SwapFree: 2085664 kB
Committed_AS: 348732 kB Committed_AS: 348732 kB
*/ */
} }
@@ -932,24 +934,23 @@ class adodb_perf {
$_SESSION['phplens_sqlrows'] = $rows; $_SESSION['phplens_sqlrows'] = $rows;
} }
?> ?>
<form method="POST" action="<?php echo $PHP_SELF ?>"> <form method="POST" action="<?php echo $PHP_SELF ?>">
<table> <table><tr>
<td> Form size: <input type="submit" value=" &lt; " name="SMALLER"><input type="submit" value=" &gt; &gt; " name="BIGGER">
</td>
<td align=right>
<input type="submit" value=" Run SQL Below " name="RUN"><input type=hidden name=do value=dosql>
</td></tr>
<tr> <tr>
<td>Form size: <input type="submit" value=" &lt; " name="SMALLER"><input <td colspan=2><textarea rows=<?php print $rows; ?> name="sql" cols="80"><?php print htmlspecialchars($sql) ?></textarea>
type="submit" value=" &gt; &gt; " name="BIGGER"></td> </td>
<td align=right><input type="submit" value=" Run SQL Below "
name="RUN"><input type=hidden name=do value=dosql></td>
</tr> </tr>
<tr> </table>
<td colspan=2><textarea rows=<?php print $rows; ?> name="sql"
cols="80"><?php print htmlspecialchars($sql) ?></textarea></td>
</tr>
</table>
</form> </form>
<?php <?php
if (!isset($_REQUEST['sql'])) return; if (!isset($_REQUEST['sql'])) return;
$sql = $this->undomq(trim($sql)); $sql = $this->undomq(trim($sql));
@@ -1005,7 +1006,7 @@ class adodb_perf {
$m = str_replace('\\\'','\'',$m); $m = str_replace('\\\'','\'',$m);
} }
return $m; return $m;
} }
/************************************************************************/ /************************************************************************/
@@ -1096,5 +1097,3 @@ class adodb_perf {
} }
// end hack // end hack
} }
?>

View File

@@ -1,16 +1,16 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4. Set tabs to 4.
*/ */
class ADODB_BASE_RS { class ADODB_BASE_RS {
} }
?>

View File

@@ -1,24 +1,28 @@
<?php <?php
/** /*
ADOdb Date Library, part of the ADOdb abstraction library ADOdb Date Library, part of the ADOdb abstraction library
Download: http://phplens.com/phpeverywhere/ Download: http://adodb.sourceforge.net/#download
PHP native date functions use integer timestamps for computations. @version v5.20.4 30-Mar-2016
Because of this, dates are restricted to the years 1901-2038 on Unix @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
and 1970-2038 on Windows due to integer overflow for dates beyond @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
those years. This library overcomes these limitations by replacing the
native function's signed integers (normally 32-bits) with PHP floating
point numbers (normally 64-bits).
Dates from 100 A.D. to 3000 A.D. and later PHP native date functions use integer timestamps for computations.
have been tested. The minimum is 100 A.D. as <100 will invoke the Because of this, dates are restricted to the years 1901-2038 on Unix
2 => 4 digit year conversion. The maximum is billions of years in the and 1970-2038 on Windows due to integer overflow for dates beyond
future, but this is a theoretical limit as the computation of that year those years. This library overcomes these limitations by replacing the
would take too long with the current implementation of adodb_mktime(). native function's signed integers (normally 32-bits) with PHP floating
point numbers (normally 64-bits).
This library replaces native functions as follows: Dates from 100 A.D. to 3000 A.D. and later
have been tested. The minimum is 100 A.D. as <100 will invoke the
2 => 4 digit year conversion. The maximum is billions of years in the
future, but this is a theoretical limit as the computation of that year
would take too long with the current implementation of adodb_mktime().
<pre> This library replaces native functions as follows:
<pre>
getdate() with adodb_getdate() getdate() with adodb_getdate()
date() with adodb_date() date() with adodb_date()
gmdate() with adodb_gmdate() gmdate() with adodb_gmdate()
@@ -26,70 +30,73 @@
gmmktime() with adodb_gmmktime() gmmktime() with adodb_gmmktime()
strftime() with adodb_strftime() strftime() with adodb_strftime()
strftime() with adodb_gmstrftime() strftime() with adodb_gmstrftime()
</pre> </pre>
The parameters are identical, except that adodb_date() accepts a subset The parameters are identical, except that adodb_date() accepts a subset
of date()'s field formats. Mktime() will convert from local time to GMT, of date()'s field formats. Mktime() will convert from local time to GMT,
and date() will convert from GMT to local time, but daylight savings is and date() will convert from GMT to local time, but daylight savings is
not handled currently. not handled currently.
This library is independant of the rest of ADOdb, and can be used This library is independant of the rest of ADOdb, and can be used
as standalone code. as standalone code.
PERFORMANCE PERFORMANCE
For high speed, this library uses the native date functions where For high speed, this library uses the native date functions where
possible, and only switches to PHP code when the dates fall outside possible, and only switches to PHP code when the dates fall outside
the 32-bit signed integer range. the 32-bit signed integer range.
GREGORIAN CORRECTION GREGORIAN CORRECTION
Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, Pope Gregory shortened October of A.D. 1582 by ten days. Thursday,
October 4, 1582 (Julian) was followed immediately by Friday, October 15, October 4, 1582 (Julian) was followed immediately by Friday, October 15,
1582 (Gregorian). 1582 (Gregorian).
Since 0.06, we handle this correctly, so: Since 0.06, we handle this correctly, so:
adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)
== 24 * 3600 (1 day) == 24 * 3600 (1 day)
============================================================================= =============================================================================
COPYRIGHT COPYRIGHT
(c) 2003-2005 John Lim and released under BSD-style license except for code by (c) 2003-2014 John Lim and released under BSD-style license except for code by
jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year
and originally found at http://www.php.net/manual/en/function.mktime.php and originally found at http://www.php.net/manual/en/function.mktime.php
============================================================================= =============================================================================
BUG REPORTS BUG REPORTS
These should be posted to the ADOdb forums at These should be posted to the ADOdb forums at
http://phplens.com/lens/lensforum/topics.php?id=4 http://phplens.com/lens/lensforum/topics.php?id=4
============================================================================= =============================================================================
FUNCTION DESCRIPTIONS FUNCTION DESCRIPTIONS
** FUNCTION adodb_time()
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) as an unsigned integer.
** FUNCTION adodb_getdate($date=false)
Returns an array containing date information, as getdate(), but supports
dates greater than 1901 to 2038. The local date/time format is derived from a
heuristic the first time adodb_getdate is called.
** FUNCTION adodb_getdate($date=false) ** FUNCTION adodb_date($fmt, $timestamp = false)
Returns an array containing date information, as getdate(), but supports Convert a timestamp to a formatted local date. If $timestamp is not defined, the
dates greater than 1901 to 2038. The local date/time format is derived from a current timestamp is used. Unlike the function date(), it supports dates
heuristic the first time adodb_getdate is called. outside the 1901 to 2038 range.
The format fields that adodb_date supports:
** FUNCTION adodb_date($fmt, $timestamp = false) <pre>
Convert a timestamp to a formatted local date. If $timestamp is not defined, the
current timestamp is used. Unlike the function date(), it supports dates
outside the 1901 to 2038 range.
The format fields that adodb_date supports:
<pre>
a - "am" or "pm" a - "am" or "pm"
A - "AM" or "PM" A - "AM" or "PM"
d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
@@ -122,59 +129,59 @@
Z - timezone offset in seconds (i.e. "-43200" to "43200"). Z - timezone offset in seconds (i.e. "-43200" to "43200").
The offset for timezones west of UTC is always negative, The offset for timezones west of UTC is always negative,
and for those east of UTC is always positive. and for those east of UTC is always positive.
</pre> </pre>
Unsupported: Unsupported:
<pre> <pre>
B - Swatch Internet time B - Swatch Internet time
I (capital i) - "1" if Daylight Savings Time, "0" otherwise. I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
W - ISO-8601 week number of year, weeks starting on Monday W - ISO-8601 week number of year, weeks starting on Monday
</pre> </pre>
** FUNCTION adodb_date2($fmt, $isoDateString = false) ** FUNCTION adodb_date2($fmt, $isoDateString = false)
Same as adodb_date, but 2nd parameter accepts iso date, eg. Same as adodb_date, but 2nd parameter accepts iso date, eg.
adodb_date2('d-M-Y H:i','2003-12-25 13:01:34'); adodb_date2('d-M-Y H:i','2003-12-25 13:01:34');
** FUNCTION adodb_gmdate($fmt, $timestamp = false) ** FUNCTION adodb_gmdate($fmt, $timestamp = false)
Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the
current timestamp is used. Unlike the function date(), it supports dates current timestamp is used. Unlike the function date(), it supports dates
outside the 1901 to 2038 range. outside the 1901 to 2038 range.
** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year]) ** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
Converts a local date to a unix timestamp. Unlike the function mktime(), it supports Converts a local date to a unix timestamp. Unlike the function mktime(), it supports
dates outside the 1901 to 2038 range. All parameters are optional. dates outside the 1901 to 2038 range. All parameters are optional.
** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year]) ** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports
dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
are currently compulsory. are currently compulsory.
** FUNCTION adodb_gmstrftime($fmt, $timestamp = false) ** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
Convert a timestamp to a formatted GMT date. Convert a timestamp to a formatted GMT date.
** FUNCTION adodb_strftime($fmt, $timestamp = false) ** FUNCTION adodb_strftime($fmt, $timestamp = false)
Convert a timestamp to a formatted local date. Internally converts $fmt into Convert a timestamp to a formatted local date. Internally converts $fmt into
adodb_date format, then echo result. adodb_date format, then echo result.
For best results, you can define the local date format yourself. Define a global For best results, you can define the local date format yourself. Define a global
variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using
adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax. adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax.
eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s'); eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s');
Supported format codes: Supported format codes:
<pre> <pre>
%a - abbreviated weekday name according to the current locale %a - abbreviated weekday name according to the current locale
%A - full weekday name according to the current locale %A - full weekday name according to the current locale
%b - abbreviated month name according to the current locale %b - abbreviated month name according to the current locale
@@ -201,10 +208,10 @@
%Y - year as a decimal number including the century %Y - year as a decimal number including the century
%Z - time zone or name or abbreviation %Z - time zone or name or abbreviation
%% - a literal `%' character %% - a literal `%' character
</pre> </pre>
Unsupported codes: Unsupported codes:
<pre> <pre>
%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99) %C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
%g - like %G, but without the century. %g - like %G, but without the century.
%G - The 4-digit year corresponding to the ISO week number (see %V). %G - The 4-digit year corresponding to the ISO week number (see %V).
@@ -221,93 +228,101 @@
%w - day of the week as a decimal, Sunday being 0 %w - day of the week as a decimal, Sunday being 0
%W - week number of the current year as a decimal number, starting with the %W - week number of the current year as a decimal number, starting with the
first Monday as the first day of the first week first Monday as the first day of the first week
</pre> </pre>
============================================================================= =============================================================================
NOTES NOTES
Useful url for generating test timestamps: Useful url for generating test timestamps:
http://www.4webhelp.net/us/timestamp.php http://www.4webhelp.net/us/timestamp.php
Possible future optimizations include Possible future optimizations include
a. Using an algorithm similar to Plauger's in "The Standard C Library" a. Using an algorithm similar to Plauger's in "The Standard C Library"
(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not (page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not
work outside 32-bit signed range, so i decided not to implement it. work outside 32-bit signed range, so i decided not to implement it.
b. Implement daylight savings, which looks awfully complicated, see b. Implement daylight savings, which looks awfully complicated, see
http://webexhibits.org/daylightsaving/ http://webexhibits.org/daylightsaving/
CHANGELOG CHANGELOG
- 16 Jan 2011 0.36
Added adodb_time() which returns current time. If > 2038, will return as float
- 11 Feb 2008 0.33 - 7 Feb 2011 0.35
* Bug in 0.32 fix for hour handling. Fixed. Changed adodb_date to be symmetric with adodb_mktime. See $jan1_71. fix for bc.
- 1 Feb 2008 0.32 - 13 July 2010 0.34
* Now adodb_mktime(0,0,0,12+$m,20,2040) works properly. Changed adodb_get_gm_diff to use DateTimeZone().
- 10 Jan 2008 0.31 - 11 Feb 2008 0.33
* Now adodb_mktime(0,0,0,24,1,2037) works correctly. * Bug in 0.32 fix for hour handling. Fixed.
- 15 July 2007 0.30 - 1 Feb 2008 0.32
Added PHP 5.2.0 compatability fixes. * Now adodb_mktime(0,0,0,12+$m,20,2040) works properly.
- 10 Jan 2008 0.31
* Now adodb_mktime(0,0,0,24,1,2037) works correctly.
- 15 July 2007 0.30
Added PHP 5.2.0 compatability fixes.
* gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the
* timezone, otherwise we use the current year as the baseline to retrieve the timezone. * timezone, otherwise we use the current year as the baseline to retrieve the timezone.
* Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but
in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8. in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8.
* *
- 19 March 2006 0.24 - 19 March 2006 0.24
Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used.
- 10 Feb 2006 0.23 - 10 Feb 2006 0.23
PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000.
In PHP4, we will still use -0000 for 100% compat with PHP4. In PHP4, we will still use -0000 for 100% compat with PHP4.
- 08 Sept 2005 0.22 - 08 Sept 2005 0.22
In adodb_date2(), $is_gmt not supported properly. Fixed. In adodb_date2(), $is_gmt not supported properly. Fixed.
- 18 July 2005 0.21 - 18 July 2005 0.21
In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat. In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat.
Added support for negative months in adodb_mktime(). Added support for negative months in adodb_mktime().
- 24 Feb 2005 0.20 - 24 Feb 2005 0.20
Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date(). Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date().
- 21 Dec 2004 0.17 - 21 Dec 2004 0.17
In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false. In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false.
Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro. Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro.
- 17 Nov 2004 0.16 - 17 Nov 2004 0.16
Removed intval typecast in adodb_mktime() for secs, allowing: Removed intval typecast in adodb_mktime() for secs, allowing:
adodb_mktime(0,0,0 + 2236672153,1,1,1934); adodb_mktime(0,0,0 + 2236672153,1,1,1934);
Suggested by Ryan. Suggested by Ryan.
- 18 July 2004 0.15 - 18 July 2004 0.15
All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory.
This brings it more in line with mktime (still not identical). This brings it more in line with mktime (still not identical).
- 23 June 2004 0.14 - 23 June 2004 0.14
Allow you to define your own daylights savings function, adodb_daylight_sv. Allow you to define your own daylights savings function, adodb_daylight_sv.
If the function is defined (somewhere in an include), then you can correct for daylights savings. If the function is defined (somewhere in an include), then you can correct for daylights savings.
In this example, we apply daylights savings in June or July, adding one hour. This is extremely In this example, we apply daylights savings in June or July, adding one hour. This is extremely
unrealistic as it does not take into account time-zone, geographic location, current year. unrealistic as it does not take into account time-zone, geographic location, current year.
function adodb_daylight_sv(&$arr, $is_gmt) function adodb_daylight_sv(&$arr, $is_gmt)
{ {
if ($is_gmt) return; if ($is_gmt) return;
$m = $arr['mon']; $m = $arr['mon'];
if ($m == 6 || $m == 7) $arr['hours'] += 1; if ($m == 6 || $m == 7) $arr['hours'] += 1;
} }
This is only called by adodb_date() and not by adodb_mktime(). This is only called by adodb_date() and not by adodb_mktime().
The format of $arr is The format of $arr is
Array ( Array (
[seconds] => 0 [seconds] => 0
[minutes] => 0 [minutes] => 0
[hours] => 0 [hours] => 0
@@ -320,73 +335,73 @@
) )
- 28 Apr 2004 0.13 - 28 Apr 2004 0.13
Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov.
- 20 Mar 2004 0.12 - 20 Mar 2004 0.12
Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32.
- 26 Oct 2003 0.11 - 26 Oct 2003 0.11
Because of daylight savings problems (some systems apply daylight savings to Because of daylight savings problems (some systems apply daylight savings to
January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. January!!!), changed adodb_get_gmt_diff() to ignore daylight savings.
- 9 Aug 2003 0.10 - 9 Aug 2003 0.10
Fixed bug with dates after 2038. Fixed bug with dates after 2038.
See http://phplens.com/lens/lensforum/msgs.php?id=6980 See http://phplens.com/lens/lensforum/msgs.php?id=6980
- 1 July 2003 0.09 - 1 July 2003 0.09
Added support for Q (Quarter). Added support for Q (Quarter).
Added adodb_date2(), which accepts ISO date in 2nd param Added adodb_date2(), which accepts ISO date in 2nd param
- 3 March 2003 0.08 - 3 March 2003 0.08
Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS
if you want PHP to handle negative timestamps between 1901 to 1969. if you want PHP to handle negative timestamps between 1901 to 1969.
- 27 Feb 2003 0.07 - 27 Feb 2003 0.07
All negative numbers handled by adodb now because of RH 7.3+ problems. All negative numbers handled by adodb now because of RH 7.3+ problems.
See http://bugs.php.net/bug.php?id=20048&edit=2 See http://bugs.php.net/bug.php?id=20048&edit=2
- 4 Feb 2003 0.06 - 4 Feb 2003 0.06
Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates
are now correctly handled. are now correctly handled.
- 29 Jan 2003 0.05 - 29 Jan 2003 0.05
Leap year checking differs under Julian calendar (pre 1582). Also Leap year checking differs under Julian calendar (pre 1582). Also
leap year code optimized by checking for most common case first. leap year code optimized by checking for most common case first.
We also handle month overflow correctly in mktime (eg month set to 13). We also handle month overflow correctly in mktime (eg month set to 13).
Day overflow for less than one month's days is supported. Day overflow for less than one month's days is supported.
- 28 Jan 2003 0.04 - 28 Jan 2003 0.04
Gregorian correction handled. In PHP5, we might throw an error if Gregorian correction handled. In PHP5, we might throw an error if
mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10.
Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582.
- 27 Jan 2003 0.03 - 27 Jan 2003 0.03
Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION.
Fixed calculation of days since start of year for <1970. Fixed calculation of days since start of year for <1970.
- 27 Jan 2003 0.02 - 27 Jan 2003 0.02
Changed _adodb_getdate() to inline leap year checking for better performance. Changed _adodb_getdate() to inline leap year checking for better performance.
Fixed problem with time-zones west of GMT +0000. Fixed problem with time-zones west of GMT +0000.
- 24 Jan 2003 0.01 - 24 Jan 2003 0.01
First implementation. First implementation.
*/ */
/* Initialization */ /* Initialization */
/* /*
Version Number Version Number
*/ */
define('ADODB_DATE_VERSION',0.33); define('ADODB_DATE_VERSION',0.35);
$ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2); $ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2);
@@ -401,7 +416,7 @@ $ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2);
References: References:
http://bugs.php.net/bug.php?id=20048&edit=2 http://bugs.php.net/bug.php?id=20048&edit=2
http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html
*/ */
if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1); if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
@@ -432,7 +447,7 @@ function adodb_date_test_strftime($fmt)
/** /**
Test Suite Test Suite
*/ */
function adodb_date_test() function adodb_date_test()
{ {
@@ -601,19 +616,25 @@ function adodb_date_test()
else print "<p><b>Failed</b> :-(</p>"; else print "<p><b>Failed</b> :-(</p>";
} }
function adodb_time()
{
$d = new DateTime();
return $d->format('U');
}
/** /**
Returns day of week, 0 = Sunday,... 6=Saturday. Returns day of week, 0 = Sunday,... 6=Saturday.
Algorithm from PEAR::Date_Calc Algorithm from PEAR::Date_Calc
*/ */
function adodb_dow($year, $month, $day) function adodb_dow($year, $month, $day)
{ {
/* /*
Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and
proclaimed that from that time onwards 3 days would be dropped from the calendar proclaimed that from that time onwards 3 days would be dropped from the calendar
every 400 years. every 400 years.
Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian).
*/ */
if ($year <= 1582) { if ($year <= 1582) {
if ($year < 1582 || if ($year < 1582 ||
($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3;
@@ -642,7 +663,7 @@ function adodb_dow($year, $month, $day)
/** /**
Checks for leap year, returns true if it is. No 2-digit year check. Also Checks for leap year, returns true if it is. No 2-digit year check. Also
handles julian calendar correctly. handles julian calendar correctly.
*/ */
function _adodb_is_leap_year($year) function _adodb_is_leap_year($year)
{ {
if ($year % 4 != 0) return false; if ($year % 4 != 0) return false;
@@ -660,7 +681,7 @@ function _adodb_is_leap_year($year)
/** /**
checks for leap year, returns true if it is. Has 2-digit year check checks for leap year, returns true if it is. Has 2-digit year check
*/ */
function adodb_is_leap_year($year) function adodb_is_leap_year($year)
{ {
return _adodb_is_leap_year(adodb_year_digit_check($year)); return _adodb_is_leap_year(adodb_year_digit_check($year));
@@ -669,7 +690,7 @@ function adodb_is_leap_year($year)
/** /**
Fix 2-digit years. Works for any century. Fix 2-digit years. Works for any century.
Assumes that if 2-digit is more than 30 years in future, then previous century. Assumes that if 2-digit is more than 30 years in future, then previous century.
*/ */
function adodb_year_digit_check($y) function adodb_year_digit_check($y)
{ {
if ($y < 100) { if ($y < 100) {
@@ -709,11 +730,11 @@ function adodb_get_gmt_diff_ts($ts)
/** /**
get local time zone offset from GMT. Does not handle historical timezones before 1970. get local time zone offset from GMT. Does not handle historical timezones before 1970.
*/ */
function adodb_get_gmt_diff($y,$m,$d) function adodb_get_gmt_diff($y,$m,$d)
{ {
static $TZ,$tzo; static $TZ,$tzo;
global $ADODB_DATETIME_CLASS; global $ADODB_DATETIME_CLASS;
if (!defined('ADODB_TEST_DATES')) $y = false; if (!defined('ADODB_TEST_DATES')) $y = false;
else if ($y < 1970 || $y >= 2038) $y = false; else if ($y < 1970 || $y >= 2038) $y = false;
@@ -729,15 +750,23 @@ function adodb_get_gmt_diff($y,$m,$d)
} else { } else {
if (isset($TZ)) return $TZ; if (isset($TZ)) return $TZ;
$y = date('Y'); $y = date('Y');
$TZ = @mktime(0,0,0,12,2,$y,0) - @gmmktime(0,0,0,12,2,$y,0); /*
if (function_exists('date_default_timezone_get') && function_exists('timezone_offset_get')) {
$tzonename = date_default_timezone_get();
if ($tzonename) {
$tobj = new DateTimeZone($tzonename);
$TZ = -timezone_offset_get($tobj,new DateTime("now",$tzo));
}
}
*/
if (empty($TZ)) $TZ = mktime(0,0,0,12,2,$y) - gmmktime(0,0,0,12,2,$y);
} }
return $TZ; return $TZ;
} }
/** /**
Returns an array with date info. Returns an array with date info.
*/ */
function adodb_getdate($d=false,$fast=false) function adodb_getdate($d=false,$fast=false)
{ {
if ($d === false) return getdate(); if ($d === false) return getdate();
@@ -751,24 +780,24 @@ function adodb_getdate($d=false,$fast=false)
} }
/* /*
// generate $YRS table for _adodb_getdate() // generate $YRS table for _adodb_getdate()
function adodb_date_gentable($out=true) function adodb_date_gentable($out=true)
{ {
for ($i=1970; $i >= 1600; $i-=10) { for ($i=1970; $i >= 1600; $i-=10) {
$s = adodb_gmmktime(0,0,0,1,1,$i); $s = adodb_gmmktime(0,0,0,1,1,$i);
echo "$i => $s,<br>"; echo "$i => $s,<br>";
} }
} }
adodb_date_gentable(); adodb_date_gentable();
for ($i=1970; $i > 1500; $i--) { for ($i=1970; $i > 1500; $i--) {
echo "<hr />$i "; echo "<hr />$i ";
adodb_date_test_date($i,1,1); adodb_date_test_date($i,1,1);
} }
*/ */
$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
@@ -776,7 +805,7 @@ $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
function adodb_validdate($y,$m,$d) function adodb_validdate($y,$m,$d)
{ {
global $_month_table_normal,$_month_table_leaf; global $_month_table_normal,$_month_table_leaf;
if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf; if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf;
else $marr = $_month_table_normal; else $marr = $_month_table_normal;
@@ -796,11 +825,11 @@ function adodb_validdate($y,$m,$d)
Low-level function that returns the getdate() array. We have a special Low-level function that returns the getdate() array. We have a special
$fast flag, which if set to true, will return fewer array values, $fast flag, which if set to true, will return fewer array values,
and is much faster as it does not calculate dow, etc. and is much faster as it does not calculate dow, etc.
*/ */
function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
{ {
static $YRS; static $YRS;
global $_month_table_normal,$_month_table_leaf; global $_month_table_normal,$_month_table_leaf;
$d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd)); $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd));
$_day_power = 86400; $_day_power = 86400;
@@ -1035,16 +1064,24 @@ function adodb_date2($fmt, $d=false, $is_gmt=false)
/** /**
Return formatted date based on timestamp $d Return formatted date based on timestamp $d
*/ */
function adodb_date($fmt,$d=false,$is_gmt=false) function adodb_date($fmt,$d=false,$is_gmt=false)
{ {
static $daylight; static $daylight;
global $ADODB_DATETIME_CLASS; global $ADODB_DATETIME_CLASS;
static $jan1_1971;
if (!isset($daylight)) {
$daylight = function_exists('adodb_daylight_sv');
if (empty($jan1_1971)) $jan1_1971 = mktime(0,0,0,1,1,1971); // we only use date() when > 1970 as adodb_mktime() only uses mktime() when > 1970
}
if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt); if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
if (!defined('ADODB_TEST_DATES')) { if (!defined('ADODB_TEST_DATES')) {
if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= $jan1_1971) // if windows, must be +ve integer
return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d); return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
} }
@@ -1053,7 +1090,6 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
$arr = _adodb_getdate($d,true,$is_gmt); $arr = _adodb_getdate($d,true,$is_gmt);
if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
if ($daylight) adodb_daylight_sv($arr, $is_gmt); if ($daylight) adodb_daylight_sv($arr, $is_gmt);
$year = $arr['year']; $year = $arr['year'];
@@ -1074,6 +1110,9 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
*/ */
for ($i=0; $i < $max; $i++) { for ($i=0; $i < $max; $i++) {
switch($fmt[$i]) { switch($fmt[$i]) {
case 'e':
$dates .= date('e');
break;
case 'T': case 'T':
if ($ADODB_DATETIME_CLASS) { if ($ADODB_DATETIME_CLASS) {
$dt = new DateTime(); $dt = new DateTime();
@@ -1192,7 +1231,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false)
/** /**
Returns a timestamp given a GMT/UTC time. Returns a timestamp given a GMT/UTC time.
Note that $is_dst is not implemented and is ignored. Note that $is_dst is not implemented and is ignored.
*/ */
function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false) function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)
{ {
return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true); return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
@@ -1203,7 +1242,7 @@ function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=
Note that $is_dst is not implemented and is ignored. Note that $is_dst is not implemented and is ignored.
Not a very fast algorithm - O(n) operation. Could be optimized to O(1). Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
*/ */
function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
{ {
if (!defined('ADODB_TEST_DATES')) { if (!defined('ADODB_TEST_DATES')) {
@@ -1320,7 +1359,7 @@ function adodb_gmstrftime($fmt, $ts=false)
// hack - convert to adodb_date // hack - convert to adodb_date
function adodb_strftime($fmt, $ts=false,$is_gmt=false) function adodb_strftime($fmt, $ts=false,$is_gmt=false)
{ {
global $ADODB_DATE_LOCALE; global $ADODB_DATE_LOCALE;
if (!defined('ADODB_TEST_DATES')) { if (!defined('ADODB_TEST_DATES')) {
if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
@@ -1421,6 +1460,3 @@ function adodb_strftime($fmt, $ts=false,$is_gmt=false)
$ret = adodb_date($fmtdate, $ts, $is_gmt); $ret = adodb_date($fmtdate, $ts, $is_gmt);
return $ret; return $ret;
} }
?>

View File

@@ -4,7 +4,7 @@
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
*******************************************************************************/ *******************************************************************************/
/** /**
* xmlschema is a class that allows the user to quickly and easily * xmlschema is a class that allows the user to quickly and easily
* build a database on any ADOdb-supported platform using a simple * build a database on any ADOdb-supported platform using a simple
@@ -33,76 +33,76 @@ function _file_get_contents($file)
/** /**
* Debug on or off * Debug on or off
*/ */
if( !defined( 'XMLS_DEBUG' ) ) { if( !defined( 'XMLS_DEBUG' ) ) {
define( 'XMLS_DEBUG', FALSE ); define( 'XMLS_DEBUG', FALSE );
} }
/** /**
* Default prefix key * Default prefix key
*/ */
if( !defined( 'XMLS_PREFIX' ) ) { if( !defined( 'XMLS_PREFIX' ) ) {
define( 'XMLS_PREFIX', '%%P' ); define( 'XMLS_PREFIX', '%%P' );
} }
/** /**
* Maximum length allowed for object prefix * Maximum length allowed for object prefix
*/ */
if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) { if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
define( 'XMLS_PREFIX_MAXLEN', 10 ); define( 'XMLS_PREFIX_MAXLEN', 10 );
} }
/** /**
* Execute SQL inline as it is generated * Execute SQL inline as it is generated
*/ */
if( !defined( 'XMLS_EXECUTE_INLINE' ) ) { if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
define( 'XMLS_EXECUTE_INLINE', FALSE ); define( 'XMLS_EXECUTE_INLINE', FALSE );
} }
/** /**
* Continue SQL Execution if an error occurs? * Continue SQL Execution if an error occurs?
*/ */
if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) { if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
define( 'XMLS_CONTINUE_ON_ERROR', FALSE ); define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
} }
/** /**
* Current Schema Version * Current Schema Version
*/ */
if( !defined( 'XMLS_SCHEMA_VERSION' ) ) { if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
define( 'XMLS_SCHEMA_VERSION', '0.2' ); define( 'XMLS_SCHEMA_VERSION', '0.2' );
} }
/** /**
* Default Schema Version. Used for Schemas without an explicit version set. * Default Schema Version. Used for Schemas without an explicit version set.
*/ */
if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) { if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' ); define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
} }
/** /**
* Default Schema Version. Used for Schemas without an explicit version set. * Default Schema Version. Used for Schemas without an explicit version set.
*/ */
if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) { if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' ); define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
} }
/** /**
* Include the main ADODB library * Include the main ADODB library
*/ */
if( !defined( '_ADODB_LAYER' ) ) { if( !defined( '_ADODB_LAYER' ) ) {
require( 'adodb.inc.php' ); require( 'adodb.inc.php' );
require( 'adodb-datadict.inc.php' ); require( 'adodb-datadict.inc.php' );
} }
/** /**
* Abstract DB Object. This class provides basic methods for database objects, such * Abstract DB Object. This class provides basic methods for database objects, such
* as tables and indexes. * as tables and indexes.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbObject { class dbObject {
/** /**
@@ -118,7 +118,7 @@ class dbObject {
/** /**
* NOP * NOP
*/ */
function dbObject( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
} }
@@ -149,7 +149,7 @@ class dbObject {
} }
function create() { function create(&$xmls) {
return array(); return array();
} }
@@ -193,16 +193,16 @@ class dbObject {
} }
/** /**
* Creates a table object in ADOdb's datadict format * Creates a table object in ADOdb's datadict format
* *
* This class stores information about a database table. As charactaristics * This class stores information about a database table. As charactaristics
* of the table are loaded from the external source, methods and properties * of the table are loaded from the external source, methods and properties
* of this class are used to build up the table description in ADOdb's * of this class are used to build up the table description in ADOdb's
* datadict format. * datadict format.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbTable extends dbObject { class dbTable extends dbObject {
/** /**
@@ -248,7 +248,7 @@ class dbTable extends dbObject {
* @param string $prefix DB Object prefix * @param string $prefix DB Object prefix
* @param array $attributes Array of table attributes. * @param array $attributes Array of table attributes.
*/ */
function dbTable( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
$this->name = $this->prefix($attributes['NAME']); $this->name = $this->prefix($attributes['NAME']);
} }
@@ -601,16 +601,16 @@ class dbTable extends dbObject {
} }
/** /**
* Creates an index object in ADOdb's datadict format * Creates an index object in ADOdb's datadict format
* *
* This class stores information about a database index. As charactaristics * This class stores information about a database index. As charactaristics
* of the index are loaded from the external source, methods and properties * of the index are loaded from the external source, methods and properties
* of this class are used to build up the index description in ADOdb's * of this class are used to build up the index description in ADOdb's
* datadict format. * datadict format.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbIndex extends dbObject { class dbIndex extends dbObject {
/** /**
@@ -642,7 +642,7 @@ class dbIndex extends dbObject {
* *
* @internal * @internal
*/ */
function dbIndex( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
$this->name = $this->prefix ($attributes['NAME']); $this->name = $this->prefix ($attributes['NAME']);
@@ -765,13 +765,13 @@ class dbIndex extends dbObject {
} }
/** /**
* Creates a data object in ADOdb's datadict format * Creates a data object in ADOdb's datadict format
* *
* This class stores information about table data. * This class stores information about table data.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbData extends dbObject { class dbData extends dbObject {
var $data = array(); var $data = array();
@@ -786,7 +786,7 @@ class dbData extends dbObject {
* *
* @internal * @internal
*/ */
function dbData( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
} }
@@ -952,11 +952,11 @@ class dbData extends dbObject {
} }
/** /**
* Creates the SQL to execute a list of provided SQL queries * Creates the SQL to execute a list of provided SQL queries
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbQuerySet extends dbObject { class dbQuerySet extends dbObject {
/** /**
@@ -985,7 +985,7 @@ class dbQuerySet extends dbObject {
* @param object $parent Parent object * @param object $parent Parent object
* @param array $attributes Attributes * @param array $attributes Attributes
*/ */
function dbQuerySet( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
// Overrides the manual prefix key // Overrides the manual prefix key
@@ -1203,18 +1203,18 @@ class dbQuerySet extends dbObject {
} }
/** /**
* Loads and parses an XML file, creating an array of "ready-to-run" SQL statements * Loads and parses an XML file, creating an array of "ready-to-run" SQL statements
* *
* This class is used to load and parse the XML file, to create an array of SQL statements * This class is used to load and parse the XML file, to create an array of SQL statements
* that can be used to build a database, and to build the database using the SQL array. * that can be used to build a database, and to build the database using the SQL array.
* *
* @tutorial getting_started.pkg * @tutorial getting_started.pkg
* *
* @author Richard Tango-Lowy & Dan Cech * @author Richard Tango-Lowy & Dan Cech
* @version $Revision: 1.12 $ * @version $Revision: 1.12 $
* *
* @package axmls * @package axmls
*/ */
class adoSchema { class adoSchema {
/** /**
@@ -1301,10 +1301,11 @@ class adoSchema {
* *
* @param object $db ADOdb database connection object. * @param object $db ADOdb database connection object.
*/ */
function adoSchema( &$db ) { function __construct( $db ) {
// Initialize the environment // Initialize the environment
$this->mgq = get_magic_quotes_runtime(); $this->mgq = get_magic_quotes_runtime();
@set_magic_quotes_runtime(0); ini_set("magic_quotes_runtime", 0);
#set_magic_quotes_runtime(0);
$this->db = $db; $this->db = $db;
$this->debug = $this->db->debug; $this->debug = $this->db->debug;
@@ -2193,16 +2194,17 @@ class adoSchema {
* @deprecated adoSchema now cleans up automatically. * @deprecated adoSchema now cleans up automatically.
*/ */
function Destroy() { function Destroy() {
@set_magic_quotes_runtime( $this->mgq ); ini_set("magic_quotes_runtime", $this->mgq );
#set_magic_quotes_runtime( $this->mgq );
unset( $this ); unset( $this );
} }
} }
/** /**
* Message logging function * Message logging function
* *
* @access private * @access private
*/ */
function logMsg( $msg, $title = NULL, $force = FALSE ) { function logMsg( $msg, $title = NULL, $force = FALSE ) {
if( XMLS_DEBUG or $force ) { if( XMLS_DEBUG or $force ) {
echo '<pre>'; echo '<pre>';
@@ -2220,4 +2222,3 @@ function logMsg( $msg, $title = NULL, $force = FALSE ) {
echo '</pre>'; echo '</pre>';
} }
} }
?>

View File

@@ -4,7 +4,7 @@
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
*******************************************************************************/ *******************************************************************************/
/** /**
* xmlschema is a class that allows the user to quickly and easily * xmlschema is a class that allows the user to quickly and easily
* build a database on any ADOdb-supported platform using a simple * build a database on any ADOdb-supported platform using a simple
@@ -33,59 +33,59 @@ function _file_get_contents($file)
/** /**
* Debug on or off * Debug on or off
*/ */
if( !defined( 'XMLS_DEBUG' ) ) { if( !defined( 'XMLS_DEBUG' ) ) {
define( 'XMLS_DEBUG', FALSE ); define( 'XMLS_DEBUG', FALSE );
} }
/** /**
* Default prefix key * Default prefix key
*/ */
if( !defined( 'XMLS_PREFIX' ) ) { if( !defined( 'XMLS_PREFIX' ) ) {
define( 'XMLS_PREFIX', '%%P' ); define( 'XMLS_PREFIX', '%%P' );
} }
/** /**
* Maximum length allowed for object prefix * Maximum length allowed for object prefix
*/ */
if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) { if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
define( 'XMLS_PREFIX_MAXLEN', 10 ); define( 'XMLS_PREFIX_MAXLEN', 10 );
} }
/** /**
* Execute SQL inline as it is generated * Execute SQL inline as it is generated
*/ */
if( !defined( 'XMLS_EXECUTE_INLINE' ) ) { if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
define( 'XMLS_EXECUTE_INLINE', FALSE ); define( 'XMLS_EXECUTE_INLINE', FALSE );
} }
/** /**
* Continue SQL Execution if an error occurs? * Continue SQL Execution if an error occurs?
*/ */
if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) { if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
define( 'XMLS_CONTINUE_ON_ERROR', FALSE ); define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
} }
/** /**
* Current Schema Version * Current Schema Version
*/ */
if( !defined( 'XMLS_SCHEMA_VERSION' ) ) { if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
define( 'XMLS_SCHEMA_VERSION', '0.3' ); define( 'XMLS_SCHEMA_VERSION', '0.3' );
} }
/** /**
* Default Schema Version. Used for Schemas without an explicit version set. * Default Schema Version. Used for Schemas without an explicit version set.
*/ */
if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) { if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' ); define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
} }
/** /**
* How to handle data rows that already exist in a database during and upgrade. * How to handle data rows that already exist in a database during and upgrade.
* Options are INSERT (attempts to insert duplicate rows), UPDATE (updates existing * Options are INSERT (attempts to insert duplicate rows), UPDATE (updates existing
* rows) and IGNORE (ignores existing rows). * rows) and IGNORE (ignores existing rows).
*/ */
if( !defined( 'XMLS_MODE_INSERT' ) ) { if( !defined( 'XMLS_MODE_INSERT' ) ) {
define( 'XMLS_MODE_INSERT', 0 ); define( 'XMLS_MODE_INSERT', 0 );
} }
@@ -100,27 +100,27 @@ if( !defined( 'XMLS_EXISTING_DATA' ) ) {
} }
/** /**
* Default Schema Version. Used for Schemas without an explicit version set. * Default Schema Version. Used for Schemas without an explicit version set.
*/ */
if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) { if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' ); define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
} }
/** /**
* Include the main ADODB library * Include the main ADODB library
*/ */
if( !defined( '_ADODB_LAYER' ) ) { if( !defined( '_ADODB_LAYER' ) ) {
require( 'adodb.inc.php' ); require( 'adodb.inc.php' );
require( 'adodb-datadict.inc.php' ); require( 'adodb-datadict.inc.php' );
} }
/** /**
* Abstract DB Object. This class provides basic methods for database objects, such * Abstract DB Object. This class provides basic methods for database objects, such
* as tables and indexes. * as tables and indexes.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbObject { class dbObject {
/** /**
@@ -136,7 +136,7 @@ class dbObject {
/** /**
* NOP * NOP
*/ */
function dbObject( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
} }
@@ -167,7 +167,7 @@ class dbObject {
} }
function create() { function create(&$xmls) {
return array(); return array();
} }
@@ -211,16 +211,16 @@ class dbObject {
} }
/** /**
* Creates a table object in ADOdb's datadict format * Creates a table object in ADOdb's datadict format
* *
* This class stores information about a database table. As charactaristics * This class stores information about a database table. As charactaristics
* of the table are loaded from the external source, methods and properties * of the table are loaded from the external source, methods and properties
* of this class are used to build up the table description in ADOdb's * of this class are used to build up the table description in ADOdb's
* datadict format. * datadict format.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbTable extends dbObject { class dbTable extends dbObject {
/** /**
@@ -273,7 +273,7 @@ class dbTable extends dbObject {
* @param string $prefix DB Object prefix * @param string $prefix DB Object prefix
* @param array $attributes Array of table attributes. * @param array $attributes Array of table attributes.
*/ */
function dbTable( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
$this->name = $this->prefix($attributes['NAME']); $this->name = $this->prefix($attributes['NAME']);
} }
@@ -642,16 +642,16 @@ class dbTable extends dbObject {
} }
/** /**
* Creates an index object in ADOdb's datadict format * Creates an index object in ADOdb's datadict format
* *
* This class stores information about a database index. As charactaristics * This class stores information about a database index. As charactaristics
* of the index are loaded from the external source, methods and properties * of the index are loaded from the external source, methods and properties
* of this class are used to build up the index description in ADOdb's * of this class are used to build up the index description in ADOdb's
* datadict format. * datadict format.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbIndex extends dbObject { class dbIndex extends dbObject {
/** /**
@@ -683,7 +683,7 @@ class dbIndex extends dbObject {
* *
* @internal * @internal
*/ */
function dbIndex( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
$this->name = $this->prefix ($attributes['NAME']); $this->name = $this->prefix ($attributes['NAME']);
@@ -806,14 +806,14 @@ class dbIndex extends dbObject {
} }
/** /**
* Creates a data object in ADOdb's datadict format * Creates a data object in ADOdb's datadict format
* *
* This class stores information about table data, and is called * This class stores information about table data, and is called
* when we need to load field data into a table. * when we need to load field data into a table.
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbData extends dbObject { class dbData extends dbObject {
var $data = array(); var $data = array();
@@ -828,7 +828,7 @@ class dbData extends dbObject {
* *
* @internal * @internal
*/ */
function dbData( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
} }
@@ -1051,11 +1051,11 @@ class dbData extends dbObject {
} }
/** /**
* Creates the SQL to execute a list of provided SQL queries * Creates the SQL to execute a list of provided SQL queries
* *
* @package axmls * @package axmls
* @access private * @access private
*/ */
class dbQuerySet extends dbObject { class dbQuerySet extends dbObject {
/** /**
@@ -1084,7 +1084,7 @@ class dbQuerySet extends dbObject {
* @param object $parent Parent object * @param object $parent Parent object
* @param array $attributes Attributes * @param array $attributes Attributes
*/ */
function dbQuerySet( &$parent, $attributes = NULL ) { function __construct( &$parent, $attributes = NULL ) {
$this->parent = $parent; $this->parent = $parent;
// Overrides the manual prefix key // Overrides the manual prefix key
@@ -1302,18 +1302,18 @@ class dbQuerySet extends dbObject {
} }
/** /**
* Loads and parses an XML file, creating an array of "ready-to-run" SQL statements * Loads and parses an XML file, creating an array of "ready-to-run" SQL statements
* *
* This class is used to load and parse the XML file, to create an array of SQL statements * This class is used to load and parse the XML file, to create an array of SQL statements
* that can be used to build a database, and to build the database using the SQL array. * that can be used to build a database, and to build the database using the SQL array.
* *
* @tutorial getting_started.pkg * @tutorial getting_started.pkg
* *
* @author Richard Tango-Lowy & Dan Cech * @author Richard Tango-Lowy & Dan Cech
* @version $Revision: 1.62 $ * @version $Revision: 1.62 $
* *
* @package axmls * @package axmls
*/ */
class adoSchema { class adoSchema {
/** /**
@@ -1405,10 +1405,11 @@ class adoSchema {
* *
* @param object $db ADOdb database connection object. * @param object $db ADOdb database connection object.
*/ */
function adoSchema( &$db ) { function __construct( $db ) {
// Initialize the environment // Initialize the environment
$this->mgq = get_magic_quotes_runtime(); $this->mgq = get_magic_quotes_runtime();
@set_magic_quotes_runtime(0); #set_magic_quotes_runtime(0);
ini_set("magic_quotes_runtime", 0);
$this->db = $db; $this->db = $db;
$this->debug = $this->db->debug; $this->debug = $this->db->debug;
@@ -2103,11 +2104,12 @@ class adoSchema {
$schema = '<?xml version="1.0"?>' . "\n" $schema = '<?xml version="1.0"?>' . "\n"
. '<schema version="' . $this->schemaVersion . '">' . "\n"; . '<schema version="' . $this->schemaVersion . '">' . "\n";
if( is_array( $tables = $this->db->MetaTables( 'TABLES' ,false ,($prefix) ? str_replace('_','\_',$prefix).'%' : '') ) ) {
if( is_array( $tables = $this->db->MetaTables( 'TABLES' , ($prefix) ? $prefix.'%' : '') ) ) {
foreach( $tables as $table ) { foreach( $tables as $table ) {
if ($stripprefix) $table = str_replace(str_replace('\\_', '_', $pfx ), '', $table); $schema .= $indent
$schema .= $indent . '<table name="' . htmlentities( $table ) . '">' . "\n"; . '<table name="'
. htmlentities( $stripprefix ? str_replace($prefix, '', $table) : $table )
. '">' . "\n";
// grab details from database // grab details from database
$rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE -1' ); $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE -1' );
@@ -2374,16 +2376,17 @@ class adoSchema {
* @deprecated adoSchema now cleans up automatically. * @deprecated adoSchema now cleans up automatically.
*/ */
function Destroy() { function Destroy() {
@set_magic_quotes_runtime( $this->mgq ); ini_set("magic_quotes_runtime", $this->mgq );
#set_magic_quotes_runtime( $this->mgq );
unset( $this ); unset( $this );
} }
} }
/** /**
* Message logging function * Message logging function
* *
* @access private * @access private
*/ */
function logMsg( $msg, $title = NULL, $force = FALSE ) { function logMsg( $msg, $title = NULL, $force = FALSE ) {
if( XMLS_DEBUG or $force ) { if( XMLS_DEBUG or $force ) {
echo '<pre>'; echo '<pre>';
@@ -2401,4 +2404,3 @@ function logMsg( $msg, $title = NULL, $force = FALSE ) {
echo '</pre>'; echo '</pre>';
} }
} }
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
{
"name" : "adodb/adodb-php",
"description" : "ADOdb is a PHP database abstraction layer library",
"license" : [ "BSD-3-Clause", "LGPL-2.1" ],
"authors" : [
{
"name": "John Lim",
"email" : "jlim@natsoft.com",
"role": "Author"
},
{
"name": "Damien Regad",
"role": "Current maintainer"
},
{
"name": "Mark Newnham",
"role": "Developer"
}
],
"keywords" : [ "database", "abstraction", "layer", "library", "php" ],
"homepage": "http://adodb.sourceforge.net/",
"support" : {
"issues" : "https://github.com/ADOdb/ADOdb/issues",
"source" : "https://github.com/ADOdb/ADOdb"
},
"require" : {
"php" : ">=5.3.2"
},
"autoload" : {
"files" : ["adodb.inc.php"]
}
}

View File

@@ -1,5 +1,5 @@
<?php <?php
/** /**
* Helper functions to convert between ADODB recordset objects and XMLRPC values. * Helper functions to convert between ADODB recordset objects and XMLRPC values.
* Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs * Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs
* *
@@ -14,16 +14,16 @@
* - null values * - null values
*/ */
/** /**
* Include the main libraries * Include the main libraries
*/ */
@require_once('xmlrpc.inc') OR die(); require_once('xmlrpc.inc');
if (!defined('ADODB_DIR')) require_once('adodb.inc.php'); if (!defined('ADODB_DIR')) require_once('adodb.inc.php');
/** /**
* Builds an xmlrpc struct value out of an AdoDB recordset * Builds an xmlrpc struct value out of an AdoDB recordset
*/ */
function rs2xmlrpcval(&$adodbrs) { function rs2xmlrpcval(&$adodbrs) {
$header = rs2xmlrpcval_header($adodbrs); $header = rs2xmlrpcval_header($adodbrs);
$body = rs2xmlrpcval_body($adodbrs); $body = rs2xmlrpcval_body($adodbrs);
@@ -36,13 +36,13 @@ function rs2xmlrpcval(&$adodbrs) {
return $xmlrpcrs; return $xmlrpcrs;
} }
/** /**
* Builds an xmlrpc struct value describing an AdoDB recordset * Builds an xmlrpc struct value describing an AdoDB recordset
*/ */
function rs2xmlrpcval_header($adodbrs) function rs2xmlrpcval_header($adodbrs)
{ {
$numfields = $adodbrs->FieldCount(); $numfields = $adodbrs->FieldCount();
$numrecords = $adodbrs->RecordCount(); $numrecords = $adodbrs->RecordCount();
@@ -78,14 +78,14 @@ function rs2xmlrpcval_header($adodbrs)
), "struct"); ), "struct");
return $header; return $header;
} }
/** /**
* Builds an xmlrpc struct value out of an AdoDB recordset * Builds an xmlrpc struct value out of an AdoDB recordset
* (data values only, no data definition) * (data values only, no data definition)
*/ */
function rs2xmlrpcval_body($adodbrs) function rs2xmlrpcval_body($adodbrs)
{ {
$numfields = $adodbrs->FieldCount(); $numfields = $adodbrs->FieldCount();
// build structure containing recordset data // build structure containing recordset data
@@ -114,25 +114,25 @@ function rs2xmlrpcval_body($adodbrs)
$body = new xmlrpcval ($rows, "array"); $body = new xmlrpcval ($rows, "array");
return $body; return $body;
} }
/** /**
* Returns an xmlrpc struct value as string out of an AdoDB recordset * Returns an xmlrpc struct value as string out of an AdoDB recordset
*/ */
function rs2xmlrpcstring (&$adodbrs) { function rs2xmlrpcstring (&$adodbrs) {
$xmlrpc = rs2xmlrpcval ($adodbrs); $xmlrpc = rs2xmlrpcval ($adodbrs);
if ($xmlrpc) if ($xmlrpc)
return $xmlrpc->serialize(); return $xmlrpc->serialize();
else else
return null; return null;
} }
/** /**
* Given a well-formed xmlrpc struct object returns an AdoDB object * Given a well-formed xmlrpc struct object returns an AdoDB object
* *
* @todo add some error checking on the input value * @todo add some error checking on the input value
*/ */
function xmlrpcval2rs (&$xmlrpcval) { function xmlrpcval2rs (&$xmlrpcval) {
$fields_array = array(); $fields_array = array();
$data_array = array(); $data_array = array();
@@ -178,6 +178,4 @@ function xmlrpcval2rs (&$xmlrpcval) {
$rs->InitArrayFields($data_array,$fields_array); $rs->InitArrayFields($data_array,$fields_array);
return $rs; return $rs;
} }
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -77,20 +79,17 @@ class ADODB2_access extends ADODB_DataDict {
{ {
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
return array(); return array();
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -58,14 +60,14 @@ class ADODB2_db2 extends ADODB_DataDict {
return $suffix; return $suffix;
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
return array(); return array();
@@ -139,6 +141,3 @@ class ADODB2_db2 extends ADODB_DataDict {
} }
} }
?>

View File

@@ -1,17 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_firebird extends ADODB_DataDict { class ADODB2_firebird extends ADODB_DataDict {
@@ -109,15 +108,15 @@ class ADODB2_firebird extends ADODB_DataDict {
return $suffix; return $suffix;
} }
/* /*
CREATE or replace TRIGGER jaddress_insert CREATE or replace TRIGGER jaddress_insert
before insert on jaddress before insert on jaddress
for each row for each row
begin begin
IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN
NEW."seqField" = GEN_ID("GEN_tabname", 1); NEW."seqField" = GEN_ID("GEN_tabname", 1);
end; end;
*/ */
function _Triggers($tabname,$tableoptions) function _Triggers($tabname,$tableoptions)
{ {
if (!$this->seqField) return array(); if (!$this->seqField) return array();
@@ -150,6 +149,3 @@ class ADODB2_firebird extends ADODB_DataDict {
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -49,14 +51,14 @@ class ADODB2_generic extends ADODB_DataDict {
} }
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
return array(); return array();
@@ -65,7 +67,7 @@ class ADODB2_generic extends ADODB_DataDict {
} }
/* /*
//db2 //db2
function ActualType($meta) function ActualType($meta)
{ {
switch($meta) { switch($meta) {
@@ -94,8 +96,8 @@ class ADODB2_generic extends ADODB_DataDict {
} }
} }
// ifx // ifx
function ActualType($meta) function ActualType($meta)
{ {
switch($meta) { switch($meta) {
case 'C': return 'VARCHAR';// 255 case 'C': return 'VARCHAR';// 255
@@ -122,5 +124,4 @@ class ADODB2_generic extends ADODB_DataDict {
return $meta; return $meta;
} }
} }
*/ */
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -49,20 +51,17 @@ class ADODB2_ibase extends ADODB_DataDict {
} }
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
return array(); return array();
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -49,14 +51,14 @@ class ADODB2_informix extends ADODB_DataDict {
} }
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
return array(); return array();
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
return array(); return array();
@@ -77,5 +79,3 @@ class ADODB2_informix extends ADODB_DataDict {
} }
} }
?>

View File

@@ -1,17 +1,19 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
/* /*
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs: In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
Note Delimiters are for identifiers only. Delimiters cannot be used for keywords, Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
whether or not they are marked as reserved in SQL Server. whether or not they are marked as reserved in SQL Server.
@@ -36,7 +38,7 @@
SET QUOTED_IDENTIFIER { ON | OFF } SET QUOTED_IDENTIFIER { ON | OFF }
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -88,7 +90,7 @@ class ADODB2_mssql extends ADODB_DataDict {
case 'B': return 'IMAGE'; case 'B': return 'IMAGE';
case 'D': return 'DATE'; case 'D': return 'DATETIME';
case 'TS': case 'TS':
case 'T': return 'DATETIME'; case 'T': return 'DATETIME';
@@ -124,7 +126,7 @@ class ADODB2_mssql extends ADODB_DataDict {
} }
/* /*
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
@@ -137,7 +139,7 @@ class ADODB2_mssql extends ADODB_DataDict {
} }
*/ */
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='') function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
if (!is_array($flds)) if (!is_array($flds))
@@ -165,7 +167,7 @@ class ADODB2_mssql extends ADODB_DataDict {
} }
/* /*
CREATE TABLE CREATE TABLE
[ database_name.[ owner ] . | owner. ] table_name [ database_name.[ owner ] . | owner. ] table_name
( { < column_definition > ( { < column_definition >
| column_name AS computed_column_expression | column_name AS computed_column_expression
@@ -174,10 +176,10 @@ class ADODB2_mssql extends ADODB_DataDict {
| [ { PRIMARY KEY | UNIQUE } [ ,...n ] | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
) )
[ ON { filegroup | DEFAULT } ] [ ON { filegroup | DEFAULT } ]
[ TEXTIMAGE_ON { filegroup | DEFAULT } ] [ TEXTIMAGE_ON { filegroup | DEFAULT } ]
< column_definition > ::= { column_name data_type } < column_definition > ::= { column_name data_type }
[ COLLATE < collation_name > ] [ COLLATE < collation_name > ]
[ [ DEFAULT constant_expression ] [ [ DEFAULT constant_expression ]
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
@@ -185,7 +187,7 @@ class ADODB2_mssql extends ADODB_DataDict {
[ ROWGUIDCOL] [ ROWGUIDCOL]
[ < column_constraint > ] [ ...n ] [ < column_constraint > ] [ ...n ]
< column_constraint > ::= [ CONSTRAINT constraint_name ] < column_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ NULL | NOT NULL ] { [ NULL | NOT NULL ]
| [ { PRIMARY KEY | UNIQUE } | [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
@@ -202,7 +204,7 @@ class ADODB2_mssql extends ADODB_DataDict {
( logical_expression ) ( logical_expression )
} }
< table_constraint > ::= [ CONSTRAINT constraint_name ] < table_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ { PRIMARY KEY | UNIQUE } { [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
{ ( column [ ASC | DESC ] [ ,...n ] ) } { ( column [ ASC | DESC ] [ ,...n ] ) }
@@ -235,7 +237,7 @@ class ADODB2_mssql extends ADODB_DataDict {
STATISTICS_NORECOMPUTE | STATISTICS_NORECOMPUTE |
SORT_IN_TEMPDB SORT_IN_TEMPDB
} }
*/ */
function _IndexSQL($idxname, $tabname, $flds, $idxoptions) function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
{ {
$sql = array(); $sql = array();
@@ -281,4 +283,3 @@ class ADODB2_mssql extends ADODB_DataDict {
} }
} }
?>

View File

@@ -1,17 +1,19 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
/* /*
In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs: In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
Note Delimiters are for identifiers only. Delimiters cannot be used for keywords, Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
whether or not they are marked as reserved in SQL Server. whether or not they are marked as reserved in SQL Server.
@@ -36,17 +38,16 @@
SET QUOTED_IDENTIFIER { ON | OFF } SET QUOTED_IDENTIFIER { ON | OFF }
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
class ADODB2_mssqlnative extends ADODB_DataDict { class ADODB2_mssqlnative extends ADODB_DataDict {
var $databaseType = 'mssqlnative'; var $databaseType = 'mssqlnative';
var $dropIndex = 'DROP INDEX %2$s.%1$s'; var $dropIndex = 'DROP INDEX %1$s ON %2$s';
var $renameTable = "EXEC sp_rename '%s','%s'"; var $renameTable = "EXEC sp_rename '%s','%s'";
var $renameColumn = "EXEC sp_rename '%s.%s','%s'"; var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000) var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
var $typeXL = 'TEXT'; var $typeXL = 'TEXT';
@@ -60,24 +61,47 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
$len = $fieldobj->max_length; $len = $fieldobj->max_length;
} }
$len = -1; // mysql max_length is not accurate $_typeConversion = array(
switch (strtoupper($t)) { -155 => 'D',
case 'R': 93 => 'D',
case 'INT': -154 => 'D',
case 'INTEGER': return 'I'; -2 => 'D',
case 'BIT': 91 => 'D',
case 'TINYINT': return 'I1';
case 'SMALLINT': return 'I2'; 12 => 'C',
case 'BIGINT': return 'I8'; 1 => 'C',
-9 => 'C',
-8 => 'C',
-7 => 'L',
-6 => 'I2',
-5 => 'I8',
-11 => 'I',
4 => 'I',
5 => 'I4',
-1 => 'X',
-10 => 'X',
2 => 'N',
3 => 'N',
6 => 'N',
7 => 'N',
-152 => 'X',
-151 => 'X',
-4 => 'X',
-3 => 'X'
);
return $_typeConversion($t);
case 'REAL':
case 'FLOAT': return 'F';
default: return parent::MetaType($t,$len,$fieldobj);
}
} }
function ActualType($meta) function ActualType($meta)
{ {
$DATE_TYPE = 'DATETIME';
switch(strtoupper($meta)) { switch(strtoupper($meta)) {
case 'C': return 'VARCHAR'; case 'C': return 'VARCHAR';
@@ -88,8 +112,8 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
case 'B': return 'IMAGE'; case 'B': return 'IMAGE';
case 'D': return 'DATE'; case 'D': return $DATE_TYPE;
case 'T': return 'DATETIME'; case 'T': return 'TIME';
case 'L': return 'BIT'; case 'L': return 'BIT';
case 'R': case 'R':
@@ -102,6 +126,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
case 'F': return 'REAL'; case 'F': return 'REAL';
case 'N': return 'NUMERIC'; case 'N': return 'NUMERIC';
default: default:
print "RETURN $meta";
return $meta; return $meta;
} }
} }
@@ -122,7 +147,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
} }
/* /*
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
@@ -135,15 +160,26 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
} }
*/ */
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='') /**
* Drop a column, syntax is ALTER TABLE table DROP COLUMN column,column
*
* @param string $tabname Table Name
* @param string[] $flds One, or an array of Fields To Drop
* @param string $tableflds Throwaway value to make the function match the parent
* @param string $tableoptions Throway value to make the function match the parent
*
* @return string The SQL necessary to drop the column
*/
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
if (!is_array($flds)) if (!is_array($flds))
$flds = explode(',',$flds); $flds = explode(',',$flds);
$f = array(); $f = array();
$s = 'ALTER TABLE ' . $tabname; $s = 'ALTER TABLE ' . $tabname . ' DROP COLUMN ';
foreach($flds as $v) { foreach($flds as $v) {
$f[] = "\n$this->dropCol ".$this->NameQuote($v); //$f[] = "\n$this->dropCol ".$this->NameQuote($v);
$f[] = $this->NameQuote($v);
} }
$s .= implode(', ',$f); $s .= implode(', ',$f);
$sql[] = $s; $sql[] = $s;
@@ -163,7 +199,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
} }
/* /*
CREATE TABLE CREATE TABLE
[ database_name.[ owner ] . | owner. ] table_name [ database_name.[ owner ] . | owner. ] table_name
( { < column_definition > ( { < column_definition >
| column_name AS computed_column_expression | column_name AS computed_column_expression
@@ -172,10 +208,10 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
| [ { PRIMARY KEY | UNIQUE } [ ,...n ] | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
) )
[ ON { filegroup | DEFAULT } ] [ ON { filegroup | DEFAULT } ]
[ TEXTIMAGE_ON { filegroup | DEFAULT } ] [ TEXTIMAGE_ON { filegroup | DEFAULT } ]
< column_definition > ::= { column_name data_type } < column_definition > ::= { column_name data_type }
[ COLLATE < collation_name > ] [ COLLATE < collation_name > ]
[ [ DEFAULT constant_expression ] [ [ DEFAULT constant_expression ]
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
@@ -183,7 +219,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
[ ROWGUIDCOL] [ ROWGUIDCOL]
[ < column_constraint > ] [ ...n ] [ < column_constraint > ] [ ...n ]
< column_constraint > ::= [ CONSTRAINT constraint_name ] < column_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ NULL | NOT NULL ] { [ NULL | NOT NULL ]
| [ { PRIMARY KEY | UNIQUE } | [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
@@ -200,7 +236,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
( logical_expression ) ( logical_expression )
} }
< table_constraint > ::= [ CONSTRAINT constraint_name ] < table_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ { PRIMARY KEY | UNIQUE } { [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
{ ( column [ ASC | DESC ] [ ,...n ] ) } { ( column [ ASC | DESC ] [ ,...n ] ) }
@@ -233,7 +269,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
STATISTICS_NORECOMPUTE | STATISTICS_NORECOMPUTE |
SORT_IN_TEMPDB SORT_IN_TEMPDB
} }
*/ */
function _IndexSQL($idxname, $tabname, $flds, $idxoptions) function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
{ {
$sql = array(); $sql = array();
@@ -279,4 +315,3 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -179,4 +181,3 @@ class ADODB2_mysql extends ADODB_DataDict {
return $sql; return $sql;
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -24,7 +26,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
var $typeX = 'VARCHAR(4000)'; var $typeX = 'VARCHAR(4000)';
var $typeXL = 'CLOB'; var $typeXL = 'CLOB';
function MetaType($t,$len=-1) function MetaType($t, $len=-1, $fieldobj=false)
{ {
if (is_object($t)) { if (is_object($t)) {
$fieldobj = $t; $fieldobj = $t;
@@ -116,6 +118,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
function AddColumnSQL($tabname, $flds) function AddColumnSQL($tabname, $flds)
{ {
$tabname = $this->TableName($tabname);
$f = array(); $f = array();
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
$s = "ALTER TABLE $tabname ADD ("; $s = "ALTER TABLE $tabname ADD (";
@@ -128,8 +131,9 @@ class ADODB2_oci8 extends ADODB_DataDict {
return $sql; return $sql;
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName($tabname);
$f = array(); $f = array();
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
$s = "ALTER TABLE $tabname MODIFY("; $s = "ALTER TABLE $tabname MODIFY(";
@@ -141,7 +145,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
return $sql; return $sql;
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
if (!is_array($flds)) $flds = explode(',',$flds); if (!is_array($flds)) $flds = explode(',',$flds);
foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v); foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v);
@@ -181,14 +185,14 @@ class ADODB2_oci8 extends ADODB_DataDict {
return $suffix; return $suffix;
} }
/* /*
CREATE or replace TRIGGER jaddress_insert CREATE or replace TRIGGER jaddress_insert
before insert on jaddress before insert on jaddress
for each row for each row
begin begin
select seqaddress.nextval into :new.A_ID from dual; select seqaddress.nextval into :new.A_ID from dual;
end; end;
*/ */
function _Triggers($tabname,$tableoptions) function _Triggers($tabname,$tableoptions)
{ {
if (!$this->seqField) return array(); if (!$this->seqField) return array();
@@ -294,4 +298,3 @@ class ADODB2_oci8 extends ADODB_DataDict {
return "COMMENT ON COLUMN $table.$col IS $cmt"; return "COMMENT ON COLUMN $table.$col IS $cmt";
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -30,8 +32,8 @@ class ADODB2_postgres extends ADODB_DataDict {
$t = $fieldobj->type; $t = $fieldobj->type;
$len = $fieldobj->max_length; $len = $fieldobj->max_length;
} }
$is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique && $is_serial = is_object($fieldobj) && !empty($fieldobj->primary_key) && !empty($fieldobj->unique) &&
$fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval('; !empty($fieldobj->has_default) && substr($fieldobj->default_value,0,8) == 'nextval(';
switch (strtoupper($t)) { switch (strtoupper($t)) {
case 'INTERVAL': case 'INTERVAL':
@@ -130,13 +132,14 @@ class ADODB2_postgres extends ADODB_DataDict {
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
$not_null = false;
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
$alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
foreach($lines as $v) { foreach($lines as $v) {
if (($not_null = preg_match('/NOT NULL/i',$v))) { if (($not_null = preg_match('/NOT NULL/i',$v))) {
$v = preg_replace('/NOT NULL/i','',$v); $v = preg_replace('/NOT NULL/i','',$v);
} }
if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
list(,$colname,$default) = $matches; list(,$colname,$default) = $matches;
$sql[] = $alter . str_replace('DEFAULT '.$default,'',$v); $sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
$sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default; $sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
@@ -188,8 +191,9 @@ class ADODB2_postgres extends ADODB_DataDict {
$tabname = $this->TableName($tabname); $tabname = $this->TableName($tabname);
$sql = array(); $sql = array();
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; $set_null = false;
foreach($lines as $v) { foreach($lines as $v) {
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
if ($not_null = preg_match('/NOT NULL/i',$v)) { if ($not_null = preg_match('/NOT NULL/i',$v)) {
$v = preg_replace('/NOT NULL/i','',$v); $v = preg_replace('/NOT NULL/i','',$v);
} }
@@ -197,30 +201,63 @@ class ADODB2_postgres extends ADODB_DataDict {
// explicitly ask a column to be null using $flds // explicitly ask a column to be null using $flds
else if ($set_null = preg_match('/NULL/i',$v)) { else if ($set_null = preg_match('/NULL/i',$v)) {
// if they didn't specify not null, see if they explicitely asked for null // if they didn't specify not null, see if they explicitely asked for null
$v = preg_replace('/\sNULL/i','',$v); // Lookbehind pattern covers the case 'fieldname NULL datatype DEFAULT NULL'
// only the first NULL should be removed, not the one specifying
// the default value
$v = preg_replace('/(?<!DEFAULT)\sNULL/i','',$v);
} }
if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
$existing = $this->MetaColumns($tabname);
list(,$colname,$default) = $matches; list(,$colname,$default) = $matches;
$alter .= $colname;
if ($this->connection) {
$old_coltype = $this->connection->MetaType($existing[strtoupper($colname)]);
}
else {
$old_coltype = $t;
}
$v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v); $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
$sql[] = $alter . $colname . ' TYPE ' . str_replace('DEFAULT '.$default,'',$v); $t = trim(str_replace('DEFAULT '.$default,'',$v));
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
// Type change from bool to int
if ( $old_coltype == 'L' && $t == 'INTEGER' ) {
$sql[] = $alter . ' DROP DEFAULT';
$sql[] = $alter . " TYPE $t USING ($colname::BOOL)::INT";
$sql[] = $alter . " SET DEFAULT $default";
}
// Type change from int to bool
else if ( $old_coltype == 'I' && $t == 'BOOLEAN' ) {
if( strcasecmp('NULL', trim($default)) != 0 ) {
$default = $this->connection->qstr($default);
}
$sql[] = $alter . ' DROP DEFAULT';
$sql[] = $alter . " TYPE $t USING CASE WHEN $colname = 0 THEN false ELSE true END";
$sql[] = $alter . " SET DEFAULT $default";
}
// Any other column types conversion
else {
$sql[] = $alter . " TYPE $t";
$sql[] = $alter . " SET DEFAULT $default";
}
} }
else { else {
// drop default? // drop default?
preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches); preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches);
list (,$colname,$rest) = $matches; list (,$colname,$rest) = $matches;
$sql[] = $alter . $colname . ' TYPE ' . $rest; $alter .= $colname;
$sql[] = $alter . ' TYPE ' . $rest;
} }
list($colname) = explode(' ',$v); # list($colname) = explode(' ',$v);
if ($not_null) { if ($not_null) {
// this does not error out if the column is already not null // this does not error out if the column is already not null
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL'; $sql[] = $alter . ' SET NOT NULL';
} }
if ($set_null) { if ($set_null) {
// this does not error out if the column is already null // this does not error out if the column is already null
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' DROP NOT NULL'; $sql[] = $alter . ' DROP NOT NULL';
} }
} }
return $sql; return $sql;
@@ -397,11 +434,11 @@ class ADODB2_postgres extends ADODB_DataDict {
/* /*
CREATE [ UNIQUE ] INDEX index_name ON table CREATE [ UNIQUE ] INDEX index_name ON table
[ USING acc_method ] ( column [ ops_name ] [, ...] ) [ USING acc_method ] ( column [ ops_name ] [, ...] )
[ WHERE predicate ] [ WHERE predicate ]
CREATE [ UNIQUE ] INDEX index_name ON table CREATE [ UNIQUE ] INDEX index_name ON table
[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] ) [ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
[ WHERE predicate ] [ WHERE predicate ]
*/ */
function _IndexSQL($idxname, $tabname, $flds, $idxoptions) function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
{ {
@@ -445,4 +482,3 @@ class ADODB2_postgres extends ADODB_DataDict {
return $ftype; return $ftype;
} }
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/** /**
V4.50 6 July 2004 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -9,7 +11,7 @@
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -100,7 +102,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
@@ -108,7 +110,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
if (!is_array($flds)) $flds = explode(',',$flds); if (!is_array($flds)) $flds = explode(',',$flds);
@@ -118,5 +120,3 @@ class ADODB2_sapdb extends ADODB_DataDict {
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
} }
} }
?>

View File

@@ -0,0 +1,90 @@
<?php
/**
@version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
SQLite datadict Andrei Besleaga
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_sqlite extends ADODB_DataDict {
var $databaseType = 'sqlite';
var $seqField = false;
var $addCol=' ADD COLUMN';
var $dropTable = 'DROP TABLE IF EXISTS %s';
var $dropIndex = 'DROP INDEX IF EXISTS %s';
var $renameTable = 'ALTER TABLE %s RENAME TO %s';
function ActualType($meta)
{
switch(strtoupper($meta)) {
case 'C': return 'VARCHAR'; // TEXT , TEXT affinity
case 'XL':return 'LONGTEXT'; // TEXT , TEXT affinity
case 'X': return 'TEXT'; // TEXT , TEXT affinity
case 'C2': return 'VARCHAR'; // TEXT , TEXT affinity
case 'X2': return 'LONGTEXT'; // TEXT , TEXT affinity
case 'B': return 'LONGBLOB'; // TEXT , NONE affinity , BLOB
case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
case 'R':
case 'I4':
case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
default:
return $meta;
}
}
// return string must begin with space
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
{
$suffix = '';
if ($funsigned) $suffix .= ' UNSIGNED';
if ($fnotnull) $suffix .= ' NOT NULL';
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
if ($fautoinc) $suffix .= ' AUTOINCREMENT';
if ($fconstraint) $suffix .= ' '.$fconstraint;
return $suffix;
}
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
return array();
}
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
return array();
}
function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
{
if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
return array();
}
}

View File

@@ -1,14 +1,16 @@
<?php <?php
/** /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -87,7 +89,7 @@ class ADODB2_sybase extends ADODB_DataDict {
return $sql; return $sql;
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
@@ -99,7 +101,7 @@ class ADODB2_sybase extends ADODB_DataDict {
return $sql; return $sql;
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
{ {
$tabname = $this->TableName($tabname); $tabname = $this->TableName($tabname);
if (!is_array($flds)) $flds = explode(',',$flds); if (!is_array($flds)) $flds = explode(',',$flds);
@@ -126,7 +128,7 @@ class ADODB2_sybase extends ADODB_DataDict {
} }
/* /*
CREATE TABLE CREATE TABLE
[ database_name.[ owner ] . | owner. ] table_name [ database_name.[ owner ] . | owner. ] table_name
( { < column_definition > ( { < column_definition >
| column_name AS computed_column_expression | column_name AS computed_column_expression
@@ -135,10 +137,10 @@ class ADODB2_sybase extends ADODB_DataDict {
| [ { PRIMARY KEY | UNIQUE } [ ,...n ] | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
) )
[ ON { filegroup | DEFAULT } ] [ ON { filegroup | DEFAULT } ]
[ TEXTIMAGE_ON { filegroup | DEFAULT } ] [ TEXTIMAGE_ON { filegroup | DEFAULT } ]
< column_definition > ::= { column_name data_type } < column_definition > ::= { column_name data_type }
[ COLLATE < collation_name > ] [ COLLATE < collation_name > ]
[ [ DEFAULT constant_expression ] [ [ DEFAULT constant_expression ]
| [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
@@ -146,7 +148,7 @@ class ADODB2_sybase extends ADODB_DataDict {
[ ROWGUIDCOL] [ ROWGUIDCOL]
[ < column_constraint > ] [ ...n ] [ < column_constraint > ] [ ...n ]
< column_constraint > ::= [ CONSTRAINT constraint_name ] < column_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ NULL | NOT NULL ] { [ NULL | NOT NULL ]
| [ { PRIMARY KEY | UNIQUE } | [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
@@ -163,7 +165,7 @@ class ADODB2_sybase extends ADODB_DataDict {
( logical_expression ) ( logical_expression )
} }
< table_constraint > ::= [ CONSTRAINT constraint_name ] < table_constraint > ::= [ CONSTRAINT constraint_name ]
{ [ { PRIMARY KEY | UNIQUE } { [ { PRIMARY KEY | UNIQUE }
[ CLUSTERED | NONCLUSTERED ] [ CLUSTERED | NONCLUSTERED ]
{ ( column [ ASC | DESC ] [ ,...n ] ) } { ( column [ ASC | DESC ] [ ,...n ] ) }
@@ -196,7 +198,7 @@ class ADODB2_sybase extends ADODB_DataDict {
STATISTICS_NORECOMPUTE | STATISTICS_NORECOMPUTE |
SORT_IN_TEMPDB SORT_IN_TEMPDB
} }
*/ */
function _IndexSQL($idxname, $tabname, $flds, $idxoptions) function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
{ {
$sql = array(); $sql = array();
@@ -226,4 +228,3 @@ class ADODB2_sybase extends ADODB_DataDict {
return $sql; return $sql;
} }
} }
?>

View File

@@ -0,0 +1,17 @@
# ADOdb Documentation
ADOdb documentation is available in the following locations
- [Online](http://adodb.org/)
- [Download](https://sourceforge.net/projects/adodb/files/Documentation/) for offline use
## Legacy documentation
The old HTML files are available in
[GitHub](https://github.com/ADOdb/ADOdb/tree/8b8133771ecbe9c95e57abbe5dc3757f0226bfcd/docs),
or in the release zip/tarballs for version 5.20 and before on
[Sourceforge](https://sourceforge.net/projects/adodb/files/adodb-php5-only/).
## Changelog
The full historical [Changelog](changelog.md) is available on GitHub.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,453 @@
# ADOdb Changelog - v5.x
Older changelogs:
[v4.x](changelog_v4.x.md),
[v3.x](changelog_v3.x.md),
[v2.x](changelog_v2.x.md).
## 5.20.4 - 30-Mar-2016
- adodb: Fix BulkBind() param count validation. #199
- mysqli: fix PHP warning in recordset destructor. #217
- mysqli: cast port number to int when connecting (PHP7 compatibility). #218
## 5.20.3 - 01-Jan-2016
- mssql: PHP warning when closing recordset from destructor not fixed in v5.20.2. #180
## 5.20.2 - 27-Dec-2015
- adodb: Remove a couple leftover PHP 4.x constructors (PHP7 compatibility). #139
- mysql: MoveNext() now respects ADODB_ASSOC_CASE. #167
- mssql, mysql, informix: Avoid PHP warning when closing recordset from destructor. #170
## 5.20.1 - 06-Dec-2015
- adodb: Fix regression introduced in 5.20.0, causing a PHP Warning when
calling GetAssoc() on an empty recordset. See Github #162
- ADOConnection::Version() now handles SemVer. See Github #164
## 5.20.0 - 28-Nov-2015
- adodb: Fix regression introduced in v5.19, causing queries to return empty rows. See Github #20, #93, #95
- adodb: Fix regression introduced in v5.19 in GetAssoc() with ADODB_FETCH_ASSOC mode and '0' as data. See Github #102
- adodb: AutoExecute correctly handles empty result set in case of updates. See Github #13
- adodb: Fix regex in Version(). See Github #16
- adodb: Align method signatures to definition in parent class ADODB_DataDict. See Github #31
- adodb: Improve compatibility of ADORecordSet_empty, thanks to Sjan Evardsson. See Github #43
- adodb: fix ADODB_Session::open() failing after successful ADONewConnection() call, thanks to Sjan Evardsson. See Github #44
- adodb: Only include memcache library once for PHPUnit 4.x, thanks to Alan Farquharson. See Github #74
- adodb: Move() returns false when given row is < 0, thanks to Mike Benoit.
- adodb: Add support for pagination with complex queries, thanks to Mike Benoit. See Github #88
- adodb: Parse port out of hostname if specified in connection parameters, thanks to Andy Theuninck. See Github #63
- adodb: Fix inability to set values from 0 to null (and vice versa) with Active Record, thanks to Louis Johnson. See Github #71
- adodb: Fix PHP strict warning in ADODB_Active_Record::Reload(), thanks to Boštjan Žokš. See Github #75
- adodb: Add mssql's DATETIME2 type to ADOConnection::MetaType(), thanks to MarcelTO. See Github #80
- adodb: When flushing cache, initialize it if it is not set, thanks to Paul Haggart. See Github #57
- adodb: Define DB_AUTOQUERY_* constants in main include file. See Github #49
- adodb: Improve documentation of fetch mode and assoc case
- adodb: Improve logic to build the assoc case bind array
- adodb: Strict-standards compliance for function names. See Github #18, #142
- adodb: Remove old PHP 4.x constructors for compatibility with PHP 7. See Github #139
- adodb: Initialize charset in ADOConnection::SetCharSet. See Github #39
- adodb: Fix incorrect handling of input array in Execute(). See Github #146
- adodb: Release Recordset when raising exception. See Github #143
- adodb: Added new setConnectionParameter() method, currently implemented in mssqlnative driver only. See Github #158.
- adodb-lib: Optimize query pagination, thanks to Mike Benoit. See Github #110
- memcache: use include_once() to avoid issues with PHPUnit. See http://phplens.com/lens/lensforum/msgs.php?id=19489
- mssql_n: Allow use of prepared statements with driver. See Github #22
- mssqlnative: Use ADOConnection::outp instead of error_log. See Github #12
- mssqlnative: fix failure on Insert_ID() if the insert statement contains a semicolon in a value string, thanks to sketule. See Github #96
- mssqlnative: Fix "invalid parameter was passed to sqlsrv_configure" error, thanks to Ray Morris. See Github #103
- mssqlnative: Fix insert_ID() failing if server returns more than 1 row, thanks to gitjti. See Github #41
- mysql: prevent race conditions when creating/dropping sequences, thanks to MikeB. See Github #28
- mysql: Fix adodb_strip_order_by() bug causing SQL error for subqueries with order/limit clause, thanks to MikeB.
- mysql: workaround for HHVM behavior, thanks to Mike Benoit.
- mysqli: Fix qstr() when called without an active connection. See Github #11
- oci8: Fix broken quoting of table name in AddColumnSQL and AlterColumnSQL, thanks to Andreas Fernandez. see Github #67
- oci8: Allow oci8 driver to use lowercase field names in assoc mode. See Github #21
- oci8po: Prevent replacement of '?' within strings, thanks to Mark Newnham. See Github #132
- pdo: Added missing property (fixes PHP notices). see Github #56
- pdo: Align method signatures with parent class, thanks to Andy Theuninck. see Github #62
- pdo: new sqlsrv driver, thanks to MarcelTO. See Github #81
- pdo/mysql: New methods to make the driver behave more like mysql/mysqli, thanks to Andy Theuninck. see Github #40
- postgres: Stop using legacy function aliases
- postgres: Fix AlterColumnSQL when updating multiple columns, thanks to Jouni Ahto. See Github #72
- postgres: Fix support for HHVM 3.6, thanks to Mike Benoit. See Github #87
- postgres: Noblob optimization, thanks to Mike Benoit. See Github #112
- postgres7: fix system warning in MetaColumns() with schema. See http://phplens.com/lens/lensforum/msgs.php?id=19481
- sqlite3: ServerInfo() now returns driver's version
- sqlite3: Fix wrong connection parameter in _connect(), thanks to diogotoscano. See Github #51
- sqlite3: Fix FetchField, thanks to diogotoscano. See Github #53
- sqlite3: Fix result-less SQL statements executed twice. See Github #99
- sqlite3: use -1 for _numOfRows. See Github #151
- xmlschema: Fix ExtractSchema() when given $prefix and $stripprefix parameters, thanks to peterdd. See Github #92
- Convert languages files to UTF-8, thanks to Marc-Etienne Vargenau. See Github #32.
## 5.19 - 23-Apr-2014
**NOTE:**
This release suffers from a [known issue with Associative Fetch Mode](https://github.com/ADOdb/ADOdb/issues/20)
(i.e. when $ADODB_FETCH_MODE is set to ADODB_FETCH_ASSOC).
It causes recordsets to return empty strings (no data) when using some database drivers.
The problem has been reported on MSSQL, Interbase and Foxpro, but possibly affects
other database types as well; all drivers derived from the above are also impacted.
- adodb: GetRowAssoc will return null as required. See http://phplens.com/lens/lensforum/msgs.php?id=19289
- adodb: Fix GetRowAssoc bug introduced in 5.17, causing function to return data from previous fetch for NULL fields. See http://phplens.com/lens/lensforum/msgs.php?id=17539
- adodb: GetAssoc will return a zero-based array when 2nd column is null. See https://sourceforge.net/p/adodb/bugs/130/
- adodb: Execute no longer ignores single parameters evaluating to false. See https://sourceforge.net/p/adodb/patches/32/
- adodb: Fix LIMIT 1 clause in subquery gets stripped off. See http://phplens.com/lens/lensforum/msgs.php?id=17813
- adodb-lib: Fix columns quoting bug. See https://sourceforge.net/p/adodb/bugs/127/
- Added new ADODB_ASSOC_CASE_* constants. Thx to Damien Regad.
- sessions: changed lob handling to detect all variations of oci8 driver.
- ads: clear fields before fetching. See http://phplens.com/lens/lensforum/msgs.php?id=17539
- mssqlnative: fixed many FetchField compat issues. See http://phplens.com/lens/lensforum/msgs.php?id=18464. Also date format changed to remove timezone.
- mssqlnative: Numerous fixes and improvements by Mark Newnham
- Driver supports SQL Server 2005, 2008 and 2012
- Bigint data types mapped to I8 instead of I
- Reintroduced MetaColumns function
- On SQL Server 2012, makes use of new CREATE SEQUENCE statement
- FetchField caches metadata at initialization to improve performance
- etc.
- mssqlnative: Fix Insert ID on prepared statement, thanks to Mike Parks. See http://phplens.com/lens/lensforum/msgs.php?id=19079
- mssql: timestamp format changed to `Y-m-d\TH:i:s` (ISO 8601) to make them independent from DATEFORMAT setting, as recommended on
[Microsoft TechNet](http://technet.microsoft.com/en-us/library/ms180878%28v=sql.105%29.aspx#StringLiteralDateandTimeFormats).
- mysql/mysqli: Fix ability for MetaTables to filter by table name, broken since 5.15. See http://phplens.com/lens/lensforum/msgs.php?id=19359
- odbc: Fixed MetaTables and MetaPrimaryKeys definitions in odbc driver to match adoconnection class.
- odbc: clear fields before fetching. See http://phplens.com/lens/lensforum/msgs.php?id=17539
- oci8: GetRowAssoc now works in ADODB_FETCH_ASSOC fetch mode
- oci8: MetaType and MetaForeignKeys argument count are now strict-standards compliant
- oci8: Added trailing `;` on trigger creation for sequence fields, prevents occurence of ORA-24344
- oci8quercus: new oci8 driver with support for quercus jdbc data types.
- pdo: Fixed concat recursion bug in 5.3. See http://phplens.com/lens/lensforum/msgs.php?id=19285
- pgsql: Default driver (postgres/pgsql) is now postgres8
- pgsql: Fix output of BLOB (bytea) columns with PostgreSQL >= 9.0
- pgsql: Fix handling of DEFAULT NULL columns in AlterColumnSQL
- pgsql: Fix mapping of error message to ADOdb error codes
- pgsql: Reset parameter number in Param() method when $name == false
- postgres8: New class/type with correct behavior for _insertid(). See Github #8
- postgres9: Fixed assoc problem. See http://phplens.com/lens/lensforum/msgs.php?id=19296
- sybase: Removed redundant sybase_connect() call in _connect(). See Github #3
- sybase: Allow connection on custom port. See Github #9
- sybase: Fix null values returned with ASSOC fetch mode. See Github #10
- Added Composer support. See Github #7
## 5.18 - 3 Sep 2012
- datadict-postgres: Fixes bug in ALTER COL. See http://phplens.com/lens/lensforum/msgs.php?id=19202.
- datadict-postgres: fixed bugs in MetaType() checking $fieldobj properties.
- GetRowAssoc did not work with null values. Bug in 5.17.
- postgres9: New driver to better support PostgreSQL 9. Thx Glenn Herteg and Cacti team.
- sqlite3: Modified to support php 5.4. Thx Günter Weber [built.development#googlemail.com]
- adodb: When fetch mode is ADODB_FETCH_ASSOC, and we execute `$db->GetAssoc("select 'a','0'");` we get an error. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=19190
- adodb: Caching directory permissions now configurable using global variable $ADODB_CACHE_PERMS. Default value is 0771.
- mysqli: SetCharSet() did not return true (success) or false (fail) correctly. Fixed.
- mysqli: changed dataProvider to 'mysql' so that MetaError and other shared functions will work.
- mssqlnative: Prepare() did not work previously. Now calling Prepare() will work but the sql is not actually compiled. Unfortunately bind params are passed to sqlsrv_prepare and not to sqlsrv_execute. make Prepare() and empty function, and we still execute the unprepared stmt.
- mysql: FetchField(-1), turns it is is not possible to retrieve the max_length. Set to -1.
- mysql-perf: Fixed "SHOW INNODB STATUS". Change to "SHOW ENGINE INNODB STATUS"
## 5.17 - 18 May 2012
- Active Record: Removed trailing whitespace from adodb-active-record.inc.php.
- odbc: Added support for $database parameter in odbc Connect() function. E.g. $DB->Connect($dsn_without_db, $user, $pwd, $database).
Previously $database had to be left blank and the $dsn was used to pass in this parameter.
- oci8: Added better empty($rs) error handling to metaindexes().
- oci8: Changed to use newer oci API to support PHP 5.4.
- adodb.inc.php: Changed GetRowAssoc to more generic code that will work in all scenarios.
## 5.16 - 26 March 2012
- mysqli: extra mysqli_next_result() in close() removed. See http://phplens.com/lens/lensforum/msgs.php?id=19100
- datadict-oci8: minor typo in create sequence trigger fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18879.
- security: safe date parsing changes. Does not impact security, these are code optimisations. Thx Saithis.
- postgres, oci8, oci8po, db2oci: Param() function parameters inconsistent with base class. $type='C' missing. Fixed.
- active-record: locked bug fixed. http://phplens.com/lens/lensforum/msgs.php?phplens_forummsg=new&id=19073
- mysql, mysqli and informix: added MetaProcedures. Metaprocedures allows to retrieve an array list of all procedures in database. http://phplens.com/lens/lensforum/msgs.php?id=18414
- Postgres7: added support for serial data type in MetaColumns().
## 5.15 - 19 Jan 2012
- pdo: fix ErrorMsg() to detect errors correctly. Thx Jens.
- mssqlnative: added another check for $this->fields array exists.
- mssqlnative: bugs in FetchField() fixed. See http://phplens.com/lens/lensforum/msgs.php?id=19024
- DBDate and DBTimeStamp had sql injection bug. Fixed. Thx Saithis
- mysql and mysqli: MetaTables() now identifies views and tables correctly.
- Added function adodb_time() to adodb-time.inc.php. Generates current time in unsigned integer format.
## 5.14 - 8 Sep 2011
- mysqli: fix php compilation bug.
- postgres: bind variables did not work properly. Fixed.
- postgres: blob handling bug in _decode. Fixed.
- ActiveRecord: if a null field was never updated, activerecord would still update the record. Fixed.
- ActiveRecord: 1 char length string never quoted. Fixed.
- LDAP: Connection string ldap:// and ldaps:// did not work. Fixed.
## 5.13 - 15 Aug 2011
- Postgres: Fix in 5.12 was wrong. Uses pg_unescape_bytea() correctly now in _decode.
- GetInsertSQL/GetUpdateSQL: Now $ADODB_QUOTE_FIELDNAMES allows you to define 'NATIVE', 'UPPER', 'LOWER'. If set to true, will default to 'UPPER'.
- mysqli: added support for persistent connections 'p:'.
- mssqlnative: ADODB_FETCH_BOTH did not work properly. Fixed.
- mssqlnative: return values for stored procedures where not returned! Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18919
- mssqlnative: timestamp and fetchfield bugs fixed. http ://phplens.com/lens/lensforum/msgs.php?id=18453
## 5.12 - 30 June 2011
- Postgres: Added information_schema support for postgresql.
- Postgres: Use pg_unescape_bytea() in _decode.
- Fix bulk binding with oci8. http://phplens.com/lens/lensforum/msgs.php?id=18786
- oci8 perf: added wait evt monitoring. Also db cache advice now handles multiple buffer pools properly.
- sessions2: Fixed setFetchMode problem.
- sqlite: Some DSN connection settings were not parsed correctly.
- mysqli: now GetOne obeys $ADODB_GETONE_EOF;
- memcache: compress option did not work. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=18899
## 5.11 - 5 May 2010
- mysql: Fixed GetOne() to return null if no records returned.
- oci8 perf: added stats on sga, rman, memory usage, and flash in performance tab.
- odbtp: Now you can define password in $password field of Connect()/PConnect(), and it will add it to DSN.
- Datadict: altering columns did not consider the scale of the column. Now it does.
- mssql: Fixed problem with ADODB_CASE_ASSOC causing multiple versions of column name appearing in recordset fields.
- oci8: Added missing & to refLob.
- oci8: Added obj->scale to FetchField().
- oci8: Now you can get column info of a table in a different schema, e.g. MetaColumns("schema.table") is supported.
- odbc_mssql: Fixed missing $metaDatabasesSQL.
- xmlschema: Changed declaration of create() to create($xmls) to fix compat problems. Also changed constructor adoSchema() to pass in variable instead of variable reference.
- ado5: Fixed ado5 exceptions to only display errors when $this->debug=true;
- Added DSN support to sessions2.inc.php.
- adodb-lib.inc.php. Fixed issue with _adodb_getcount() not using $secs2cache parameter.
- adodb active record. Fixed caching bug. See http://phplens.com/lens/lensforum/msgs.php?id=18288.
- db2: fixed ServerInfo().
- adodb_date: Added support for format 'e' for TZ as in adodb_date('e')
- Active Record: If you have a field which is a string field (with numbers in) and you add preceding 0's to it the adodb library does not pick up the fact that the field has changed because of the way php's == works (dodgily). The end result is that it never gets updated into the database - fix by Matthew Forrester (MediaEquals). [matthew.forrester#mediaequals.com]
- Fixes RowLock() and MetaIndexes() inconsistencies. See http://phplens.com/lens/lensforum/msgs.php?id=18236
- Active record support for postgrseql boolean. See http://phplens.com/lens/lensforum/msgs.php?id=18246
- By default, Execute 2D array is disabled for security reasons. Set $conn->bulkBind = true to enable. See http://phplens.com/lens/lensforum/msgs.php?id=18270. Note this breaks backward compat.
- MSSQL: fixes for 5.2 compat. http://phplens.com/lens/lensforum/msgs.php?id=18325
- Changed Version() to return a string instead of a float so it correctly returns 5.10 instead of 5.1.
## 5.10 - 10 Nov 2009
- Fixed memcache to properly support $rs->timeCreated.
- adodb-ado.inc.php: Added BigInt support for PHP5. Will return float instead to support large numbers. Thx nasb#mail.goo.ne.jp.
- adodb-mysqli.inc.php: mysqli_multi_query is now turned off by default. To turn it on, use $conn->multiQuery = true; This is because of the risks of sql injection. See http://phplens.com/lens/lensforum/msgs.php?id=18144
- New db2oci driver for db2 9.7 when using PL/SQL mode. Allows oracle style :0, :1, :2 bind parameters which are remapped to ? ? ?.
- adodb-db2.inc.php: fixed bugs in MetaTables. SYS owner field not checked properly. Also in $conn->Connect($dsn, null, null, $schema) and PConnect($dsn, null, null, $schema), we do a SET SCHEMA=$schema if successful connection.
- adodb-mysqli.inc.php: Now $rs->Close() closes all pending next resultsets. Thx Clifton mesmackgod#gmail.com
- Moved _CreateCache() from PConnect()/Connect() to CacheExecute(). Suggested by Dumka.
- Many bug fixes to adodb-pdo_sqlite.inc.php and new datadict-sqlite.inc.php. Thx Andrei B. [andreutz#mymail.ro]
- Removed usage of split (deprecated in php 5.3). Thx david#horizon-nigh.org.
- Fixed RowLock() parameters to comply with PHP5 strict mode in multiple drivers.
## 5.09 - 25 June 2009
- Active Record: You can force column names to be quoted in INSERT and UPDATE statements, typically because you are using reserved words as column names by setting ADODB_Active_Record::$_quoteNames = true;
- Added memcache and cachesecs to DSN. e.g.
``` php
# we have a memcache servers mem1,mem2 on port 8888, compression=off and cachesecs=120
$dsn = 'mysql://user:pwd@localhost/mydb?memcache=mem1,mem2:8888:0&cachesecs=120';
```
- Fixed up MetaColumns and MetaPrimaryIndexes() for php 5.3 compat. Thx http://adodb.pastebin.com/m52082b16
- The postgresql driver's OffsetDate() apparently does not work with postgres 8.3. Fixed.
- Added support for magic_quotes_sybase in qstr() and addq(). Thanks Eloy and Sam Moffat.
- The oci8 driver did not handle LOBs properly when binding. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=17991.
- Datadict: In order to support TIMESTAMP with subsecond accuracy, added to datadict the new TS type. Supported by mssql, postgresql and oci8 (oracle). Also changed oci8 $conn->sysTimeStamp to use 'SYSTIMESTAMP' instead of 'SYSDATE'. Should be backwards compat.
- Added support for PHP 5.1+ DateTime objects in DBDate and DBTimeStamp. This means that dates and timestamps will be managed by DateTime objects if you are running PHP 5.1+.
- Added new property to postgres64 driver to support returning I if type is unique int called $db->uniqueIisR, defaulting to true. See http://phplens.com/lens/lensforum/msgs.php?id=17963
- Added support for bindarray in adodb_GetActiveRecordsClass with SelectLimit in adodb-active-record.inc.php.
- Transactions now allowed in ado_access driver. Thx to petar.petrov.georgiev#gmail.com.
- Sessions2 garbage collection is now much more robust. We perform ORDER BY to prevent deadlock in adodb-sessions2.inc.php.
- Fixed typo in pdo_sqlite driver.
## 5.08a - 17 Apr 2009
- Fixes wrong version number string.
- Incorrect + in adodb-datadict.inc.php removed.
- Fixes missing OffsetDate() function in pdo. Thx paul#mantisforge.org.
## 5.08 - 17 Apr 2009
- adodb-sybase.inc.php driver. Added $conn->charSet support. Thx Luis Henrique Mulinari (luis.mulinari#gmail.com)
- adodb-ado5.inc.php. Fixed some bind param issues. Thx Jirka Novak.
- adodb-ado5.inc.php. Now has improved error handling.
- Fixed typo in adodb-xmlschema03.inc.php. See XMLS_EXISTING_DATA, line 1501. Thx james johnson.
- Made $inputarr optional for _query() in all drivers.
- Fixed spelling mistake in flushall() in adodb.inc.ophp.
- Fixed handling of quotes in adodb_active_record::doquote. Thx Jonathan Hohle (jhohle#godaddy.com).
- Added new index parameter to adodb_active_record::setdatabaseadaptor. Thx Jonathan Hohle
- Fixed & readcache() reference compat problem with php 5.3 in adodb.Thx Jonathan Hohle.
- Some minor $ADODB_CACHE_CLASS definition issues in adodb.inc.php.
- Added Reset() function to adodb_active_record. Thx marcus.
- Minor dsn fix for pdo_sqlite in adodb.inc.php. Thx Sergey Chvalyuk.
- Fixed adodb-datadict _CreateSuffix() inconsistencies. Thx Chris Miller.
- Option to delete old fields $dropOldFlds in datadict ChangeTableSQL($table, $flds, $tableOptions, $dropOldFlds=false) added. Thx Philipp Niethammer.
- Memcache caching did not expire properly. Fixed.
- MetaForeignKeys for postgres7 driver changed from adodb_movenext to $rs->MoveNext (also in 4.99)
- Added support for ldap and ldaps url format in ldap driver. E.g. ldap://host:port/dn?attributes?scope?filter?extensions
## 5.07 - 26 Dec 2008
- BeginTrans/CommitTrans/RollbackTrans return true/false correctly on success/failure now for mssql, odbc, oci8, mysqlt, mysqli, postgres, pdo.
- Replace() now quotes all non-null values including numeric ones.
- Postgresql qstr() now returns booleans as *true* and *false* without quotes.
- MetaForeignKeys in mysql and mysqli drivers had this problem: A table can have two foreign keys pointing to the same column in the same table. The original code will incorrectly report only the last column. Fixed. https://sourceforge.net/tracker/index.php?func=detail&aid=2287278&group_id=42718&atid=433976
- Passing in full ado connection string in $argHostname with ado drivers was failing in adodb5 due to bug. Fixed.
- Fixed memcachelib flushcache and flushall bugs. Also fixed possible timeCreated = 0 problem in readcache. (Also in adodb 4.992). Thanks AlexB_UK (alexbarnes#hotmail.com).
- Fixed a notice in adodb-sessions2.inc.php, in _conn(). Thx bober m.derlukiewicz#rocktech.remove_me.pl;
- ADOdb Active Record: Fixed some issues with incompatible fetch modes (ADODB_FETCH_ASSOC) causing problems in UpdateActiveTable().
- ADOdb Active Record: Added support for functions that support predefining one-to-many relationships:
_ClassHasMany ClassBelongsTo TableHasMany TableBelongsTo TableKeyHasMany TableKeyBelongsTo_.
- You can also define your child/parent class in these functions, instead of the default ADODB_Active_Record. Thx Arialdo Martini & Chris R for idea.
- ADOdb Active Record: HasMany hardcoded primary key to "id". Fixed.
- Many pdo and pdo-sqlite fixes from Sid Dunayer [sdunayer#interserv.com].
- CacheSelectLimit not working for mssql. Fixed. Thx AlexB.
- The rs2html function did not display hours in timestamps correctly. Now 24hr clock used.
- Changed ereg* functions to use preg* functions as ereg* is deprecated in PHP 5.3. Modified sybase and postgresql drivers.
## 5.06 - 16 Oct 2008
- Added driver adodb-pdo_sqlite.inc.php. Thanks Diogo Toscano (diogo#scriptcase.net) for the code.
- Added support for [one-to-many relationships](docs-active-record.htm#onetomany) with BelongsTo() and HasMany() in adodb_active_record.
- Added BINARY type to mysql.inc.php (also in 4.991).
- Added support for SelectLimit($sql,-1,100) in oci8. (also in 4.991).
- New $conn->GetMedian($table, $field, $where='') to get median account no. (also in 4.991)
- The rs2html() function in tohtml.inc.php did not handle dates with ':' in it properly. Fixed. (also in 4.991)
- Added support for connecting to oci8 using `$DB->Connect($ip, $user, $pwd, "SID=$sid");` (also in 4.991)
- Added mysql type 'VAR_STRING' to MetaType(). (also in 4.991)
- The session and session2 code supports setfetchmode assoc properly now (also in 4.991).
- Added concat support to pdo. Thx Andrea Baron.
- Changed db2 driver to use format `Y-m-d H-i-s` for datetime instead of `Y-m-d-H-i-s` which was legacy from odbc_db2 conversion.
- Removed vestigal break on adodb_tz_offset in adodb-time.inc.php.
- MetaForeignKeys did not work for views in MySQL 5. Fixed.
- Changed error handling in GetActiveRecordsClass.
- Added better support for using existing driver when $ADODB_NEWCONNECTION function returns false.
- In _CreateSuffix in adodb-datadict.inc.php, adding unsigned variable for mysql.
- In adodb-xmlschema03.inc.php, changed addTableOpt to include db name.
- If bytea blob in postgresql is null, empty string was formerly returned. Now null is returned.
- Changed db2 driver CreateSequence to support $start parameter.
- rs2html() now does not add nbsp to end if length of string > 0
- The oci8po FetchField() now only lowercases field names if ADODB_ASSOC_CASE is set to 0.
- New mssqlnative drivers for php. TQ Garrett Serack of M'soft. [Download](http://www.microsoft.com/downloads/details.aspx?FamilyId=61BF87E0-D031-466B-B09A-6597C21A2E2A&displaylang=en) mssqlnative extension. Note that this is still in beta.
- Fixed bugs in memcache support.
- You can now change the return value of GetOne if no records are found using the global variable $ADODB_GETONE_EOF. The default is null. To change it back to the pre-4.99/5.00 behaviour of false, set $ADODB_GETONE_EOF = false;
- In Postgresql 8.2/8.3 MetaForeignkeys did not work. Fixed William Kolodny William.Kolodny#gt-t.net
## 5.05 - 11 Jul 2008
Released together with [v4.990](changelog_v4.x.md#4990---11-jul-2008)
- Added support for multiple recordsets in mysqli , thanks to Geisel Sierote geisel#4up.com.br. See http://phplens.com/lens/lensforum/msgs.php?id=15917
- Malcolm Cook added new Reload() function to Active Record. See http://phplens.com/lens/lensforum/msgs.php?id=17474
- Thanks Zoltan Monori (monzol#fotoprizma.hu) for bug fixes in iterator, SelectLimit, GetRandRow, etc.
- Under heavy loads, the performance monitor for oci8 disables Ixora views.
- Fixed sybase driver SQLDate to use str_replace(). Also for adodb5, changed sybase driver UnixDate and UnixTimeStamp calls to static.
- Changed oci8 lob handler to use & reference `$this->_refLOBs[$numlob]['VAR'] = &$var`.
- We now strtolower the get_class() function in PEAR::isError() for php5 compat.
- CacheExecute did not retrieve cache recordsets properly for 5.04 (worked in 4.98). Fixed.
- New ADODB_Cache_File class for file caching defined in adodb.inc.php.
- Farsi language file contribution by Peyman Hooshmandi Raad (phooshmand#gmail.com)
- New API for creating your custom caching class which is stored in $ADODB_CACHE:
``` php
include "/path/to/adodb.inc.php";
$ADODB_CACHE_CLASS = 'MyCacheClass';
class MyCacheClass extends ADODB_Cache_File
{
function writecache($filename, $contents,$debug=false) {...}
function &readcache($filename, &$err, $secs2cache, $rsClass) { ...}
:
}
$DB = NewADOConnection($driver);
$DB->Connect(...); ## MyCacheClass created here and stored in $ADODB_CACHE global variable.
$data = $rs->CacheGetOne($sql); ## MyCacheClass is used here for caching...
```
- Memcache supports multiple pooled hosts now. Only if none of the pooled servers
can be contacted will a connect error be generated. Usage example below:
``` php
$db = NewADOConnection($driver);
$db->memCache = true; /// should we use memCache instead of caching in files
$db->memCacheHost = array($ip1, $ip2, $ip3); /// $db->memCacheHost = $ip1; still works
$db->memCachePort = 11211; /// this is default memCache port
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
$db->Connect(...);
$db->CacheExecute($sql);
```
## 5.04 - 13 Feb 2008
Released together with [v4.98](changelog_v4.x.md#498---13-feb-2008)
- Fixed adodb_mktime problem which causes a performance bottleneck in $hrs.
- Added mysqli support to adodb_getcount().
- Removed MYSQLI_TYPE_CHAR from MetaType().
## 5.03 - 22 Jan 2008
Released together with [v4.97](changelog_v4.x.md#497---22-jan-2008)
- Active Record: $ADODB_ASSOC_CASE=1 did not work properly. Fixed.
- Modified Fields() in recordset class to support display null fields in FetchNextObject().
- In ADOdb5, active record implementation, we now support column names with spaces in them - we autoconvert the spaces to _ using __set(). Thx Daniel Cook. http://phplens.com/lens/lensforum/msgs.php?id=17200
- Removed $arg3 from mysqli SelectLimit. See http://phplens.com/lens/lensforum/msgs.php?id=16243. Thx Zsolt Szeberenyi.
- Changed oci8 FetchField, which returns the max_length of BLOB/CLOB/NCLOB as 4000 (incorrectly) to -1.
- CacheExecute would sometimes return an error on Windows if it was unable to lock the cache file. This is harmless and has been changed to a warning that can be ignored. Also adodb_write_file() code revised.
- ADOdb perf code changed to only log sql if execution time >= 0.05 seconds. New $ADODB_PERF_MIN variable holds min sql timing. Any SQL with timing value below this and is not causing an error is not logged.
- Also adodb_backtrace() now traces 1 level deeper as sometimes actual culprit function is not displayed.
- Fixed a group by problem with adodb_getcount() for db's which are not postgres/oci8 based.
- Changed mssql driver Parameter() from SQLCHAR to SQLVARCHAR: case 'string': $type = SQLVARCHAR; break.
- Problem with mssql driver in php5 (for adodb 5.03) because some functions are not static. Fixed.
## 5.02 - 24 Sept 2007
Released together with [v4.96](changelog_v4.x.md#496---24-sept-2007)
- ADOdb perf for oci8 now has non-table-locking code when clearing the sql. Slower but better transparency. Added in 4.96a and 5.02a.
- Fix adodb count optimisation. Preg_match did not work properly. Also rewrote the ORDER BY stripping code in _adodb_getcount(), adodb-lib.inc.php.
- SelectLimit for oci8 not optimal for large recordsets when offset=0. Changed $nrows check.
- Active record optimizations. Added support for assoc arrays in Set().
- Now GetOne returns null if EOF (no records found), and false if error occurs. Use ErrorMsg()/ErrorNo() to get the error.
- Also CacheGetRow and CacheGetCol will return false if error occurs, or empty array() if EOF, just like GetRow and GetCol.
- Datadict now allows changing of types which are not resizable, eg. VARCHAR to TEXT in ChangeTableSQL. -- Mateo Tibaquirá
- Added BIT data type support to adodb-ado.inc.php and adodb-ado5.inc.php.
- Ldap driver did not return actual ldap error messages. Fixed.
- Implemented GetRandRow($sql, $inputarr). Optimized for Oci8.
- Changed adodb5 active record to use static SetDatabaseAdapter() and removed php4 constructor. Bas van Beek bas.vanbeek#gmail.com.
- Also in adodb5, changed adodb-session2 to use static function declarations in class. Thx Daniel Berlin.
- Added "Clear SQL Log" to bottom of Performance screen.
- Sessions2 code echo'ed directly to the screen in debug mode. Now uses ADOConnection::outp().
- In mysql/mysqli, qstr(null) will return the string `null` instead of empty quoted string `''`.
- postgresql optimizeTable in perf-postgres.inc.php added by Daniel Berlin (mail#daniel-berlin.de)
- Added 5.2.1 compat code for oci8.
- Changed @@identity to SCOPE_IDENTITY() for multiple mssql drivers. Thx Stefano Nari.
- Code sanitization introduced in 4.95 caused problems in European locales (as float 3.2 was typecast to 3,2). Now we only sanitize if is_numeric fails.
- Added support for customizing ADORecordset_empty using $this->rsPrefix.'empty'. By Josh Truwin.
- Added proper support for ALterColumnSQL for Postgresql in datadict code. Thx. Josh Truwin.
- Added better support for MetaType() in mysqli when using an array recordset.
- Changed parser for pgsql error messages in adodb-error.inc.php to case-insensitive regex.
## 5.01 - 17 May 2007
Released together with [v4.95](changelog_v4.x.md#495---17-may-2007)
- CacheFlush debug outp() passed in invalid parameters. Fixed.
- Added Thai language file for adodb. Thx Trirat Petchsingh rosskouk#gmail.com and Marcos Pont
- Added zerofill checking support to MetaColumns for mysql and mysqli.
- CacheFlush no longer deletes all files/directories. Only *.cache files deleted.
- DB2 timestamp format changed to `var $fmtTimeStamp = "'Y-m-d-H:i:s'";`
- Added some code sanitization to AutoExecute in adodb-lib.inc.php.
- Due to typo, all connections in adodb-oracle.inc.php would become persistent, even non-persistent ones. Fixed.
- Oci8 DBTimeStamp uses 24 hour time for input now, so you can perform string comparisons between 2 DBTimeStamp values.
- Some PHP4.4 compat issues fixed in adodb-session2.inc.php
- For ADOdb 5.01, fixed some adodb-datadict.inc.php MetaType compat issues with PHP5.
- The $argHostname was wiped out in adodb-ado5.inc.php. Fixed.
- Adodb5 version, added iterator support for adodb_recordset_empty.
- Adodb5 version,more error checking code now will use exceptions if available.

View File

@@ -0,0 +1,531 @@
# ADOdb old Changelog - v2.x and older
See the [Current Changelog](changelog.md).
## 2.91 - 3 Jan 2003
- Revised PHP version checking to use $ADODB_PHPVER with legal values 0x4000, 0x4050, 0x4200, 0x4300.
- Added support for bytea fields and oid blobs in postgres by allowing BlobDecode() to detect and convert non-oid fields. Also added BlobEncode to postgres when you want to encode oid blobs.
- Added blobEncodeType property for connections to inform phpLens what encoding method to use for blobs.
- Added BlobDecode() and BlobEncode() to base ADOConnection class.
- Added umask() to _gencachename() when creating directories.
- Added charPage for ado drivers, so you can set the code page.
```
$conn->charPage = CP_UTF8;
$conn->Connect($dsn);
```
- Modified _seek in mysql to check for num rows=0.
- Added to metatypes new informix types for IDS 9.30\. Thx Fernando Ortiz.
- _maxrecordcount returned in CachePageExecute $rsreturn
- Fixed sybase cacheselectlimit( ) problems
- MetaColumns() max_length should use precision for types X and C for ms access. Fixed.
- Speedup of odbc non-SELECT sql statements.
- Added support in MetaColumns for Wide Char types for ODBC. We halve max_length if unicode/wide char.
- Added 'B' to types handled by GetUpdateSQL/GetInsertSQL.
- Fixed warning message in oci8 driver with $persist variable when using PConnect.
## 2.90 - 11 Dec 2002
- Mssql and mssqlpo and oci8po now support ADODB_ASSOC_CASE.
- Now MetaType() can accept a field object as the first parameter.
- New $arr = $db->ServerInfo( ) function. Returns $arr['description'] which is the string description, and $arr['version'].
- PostgreSQL and MSSQL speedups for insert/updates.
- Implemented new SetFetchMode() that removes the need to use $ADODB_FETCH_MODE. Each connection has independant fetchMode.
- ADODB_ASSOC_CASE now defaults to 2, use native defaults. This is because we would break backward compat for too many applications otherwise.
- Patched encrypted sessions to use replace()
- The qstr function supports quoting of nulls when escape character is \
- Rewrote bits and pieces of session code to check for time synch and improve reliability.
- Added property ADOConnection::hasTransactions = true/false;
- Added CreateSequence and DropSequence functions
- Found misplaced MoveNext() in adodb-postgres.inc.php. Fixed.
- Sybase SelectLimit not reliable because 'set rowcount' not cached - fixed.
- Moved ADOConnection to adodb-connection.inc.php and ADORecordSet to adodb-recordset.inc.php. This allows us to use doxygen to generate documentation. Doxygen doesn't like the classes in the main adodb.inc.php file for some mysterious reason.
## 2.50 - 14 Nov 2002
- Added transOff and transCnt properties for disabling (transOff = true) and tracking transaction status (transCnt>0).
- Added inputarray handling into _adodb_pageexecute_all_rows - "Ross Smith" RossSmith#bnw.com.
- Fixed postgresql inconsistencies in date handling.
- Added support for mssql_fetch_assoc.
- Fixed $ADODB_FETCH_MODE bug in odbc MetaTables() and MetaPrimaryKeys().
- Accidentally declared UnixDate() twice, making adodb incompatible with php 4.3.0\. Fixed.
- Fixed pager problems with some databases that returned -1 for _currentRow on MoveLast() by switching to MoveNext() in adodb-lib.inc.php.
- Also fixed uninited $discard in adodb-lib.inc.php.
## 2.43 - 25 Oct 2002
- Added ADODB_ASSOC_CASE constant to better support ibase and odbc field names.
- Added support for NConnect() for oracle OCINLogin.
- Fixed NumCols() bug.
- Changed session handler to use Replace() on write.
- Fixed oci8 SelectLimit aggregate function bug again.
- Rewrote pivoting code.
## 2.42 - 4 Oct 2002
- Fixed ibase_fetch() problem with nulls. Also interbase now does automatic blob decoding, and is backward compatible. Suggested by Heinz Hombergs heinz#hhombergs.de.
- Fixed postgresql MoveNext() problems when called repeatedly after EOF. Also suggested by Heinz Hombergs.
- PageExecute() does not rewrite queries if SELECT DISTINCT is used. Requested by hans#velum.net
- Added additional fixes to oci8 SelectLimit handling with aggregate functions - thx to Christian Bugge for reporting the problem.
## 2.41 - 2 Oct 2002
- Fixed ADODB_COUNTRECS bug in odbc. Thx to Joshua Zoshi jzoshi#hotmail.com.
- Increased buffers for adodb-csvlib.inc.php for extremely long sql from 8192 to 32000.
- Revised pivottable.inc.php code. Added better support for aggregate fields.
- Fixed mysql text/blob types problem in MetaTypes base class - thx to horacio degiorgi.
- Added SQLDate($fmt,$date) function, which allows an sql date format string to be generated - useful for group by's.
- Fixed bug in oci8 SelectLimit when offset>100.
## 2.40 - 4 Sept 2002
- Added new NLS_DATE_FORMAT property to oci8\. Suggested by Laurent NAVARRO ln#altidev.com
- Now use bind parameters in oci8 selectlimit for better performance.
- Fixed interbase replaceQuote for dialect != 1\. Thx to "BEGUIN Pierre-Henri - INFOCOB" phb#infocob.com.
- Added white-space check to QA.
- Changed unixtimestamp to support fractional seconds (we always round down/floor the seconds). Thanks to beezly#beezly.org.uk.
- Now you can set the trigger_error type your own user-defined type in adodb-errorhandler.inc.php. Suggested by Claudio Bustos clbustos#entelchile.net.
- Added recordset filters with rsfilter.inc.php.
$conn->_rs2rs does not create a new recordset when it detects it is of type array. Some trickery there as there seems to be a bug in Zend Engine
- Added render_pagelinks to adodb-pager.inc.php. Code by "Pablo Costa" pablo#cbsp.com.br.
- MetaType() speedup in adodb.inc.php by using hashing instead of switch. Best performance if constant arrays are supported, as they are in PHP5.
- adodb-session.php now updates only the expiry date if the crc32 check indicates that the data has not been modified.
## 2.31 - 20 Aug 2002
- Made changes to pivottable.inc.php due to daniel lucuzaeu's suggestions (we sum the pivottable column if desired).
- Fixed ErrorNo() in postgres so it does not depend on _errorMsg property.
- Robert Tuttle added support for oracle cursors. See ExecuteCursor().
- Fixed Replace() so it works with mysql when updating record where data has not changed. Reported by Cal Evans (cal#calevans.com).
## 2.30 - 1 Aug 2002
- Added pivottable.inc.php. Thanks to daniel.lucazeau#ajornet.com for the original concept.
- Added ADOConnection::outp($msg,$newline) to output error and debugging messages. Now you can override this using the ADODB_OUTP constant and use your own output handler.
- Changed == to === for 'null' comparison. Reported by ericquil#yahoo.com
- Fixed mssql SelectLimit( ) bug when distinct used.
## 2.30 - 1 Aug 2002
- New GetCol() and CacheGetCol() from ross#bnw.com that returns the first field as a 1 dim array.
- We have an empty recordset, but RecordCount() could return -1\. Fixed. Reported by "Jonathan Polansky" jonathan#polansky.com.
- We now check for session variable changes using strlen($sessval).crc32($sessval). Formerly we only used crc32().
- Informix SelectLimit() problem with $ADODB_COUNTRECS fixed.
- Fixed informix SELECT FIRST x DISTINCT, and not SELECT DISTINCT FIRST x - reported by F Riosa
- Now default adodb error handlers ignores error if @ used.
- If you set $conn->autoRollback=true, we auto-rollback persistent connections for odbc, mysql, oci8, mssql. Default for autoRollback is false. No need to do so for postgres. As interbase requires a transaction id (what a flawed api), we don't do it for interbase.
- Changed PageExecute() to use non-greedy preg_match when searching for "FROM" keyword.
## 2.20 - 9 July 2002
- Added CacheGetOne($secs2cache,$sql), CacheGetRow($secs2cache,$sql), CacheGetAll($secs2cache,$sql).
- Added $conn->OffsetDate($dayFraction,$date=false) to generate sql that calcs date offsets. Useful for scheduling appointments.
- Added connection properties: leftOuter, rightOuter that hold left and right outer join operators.
- Added connection property: ansiOuter to indicate whether ansi outer joins supported.
- New driver _mssqlpo_, the portable mssql driver, which converts string concat operator from || to +.
- Fixed ms access bug - SelectLimit() did not support ties - fixed.
- Karsten Kraus (Karsten.Kraus#web.de), contributed error-handling code to ADONewConnection. Unfortunately due to backward compat problems, had to rollback most of the changes.
- Added new parameter to GetAssoc() to allow returning an array of key-value pairs, ignoring any additional columns in the recordset. Off by default.
- Corrected mssql $conn->sysDate to return only date using convert().
- CacheExecute() improved debugging output.
- Changed rs2html() so newlines are converted to BR tags. Also optimized rs2html() based on feedback by "Jerry Workman" jerry#mtncad.com.
- Added support for Replace() with Interbase, using DELETE and INSERT.
- Some minor optimizations (mostly removing & references when passing arrays).
- Changed GenID() to allows id's larger than the size of an integer.
- Added force_session property to oci8 for better updateblob() support.
- Fixed PageExecute() which did not work properly with sql containing GROUP BY.
## 2.12 - 12 June 2002
- Added toexport.inc.php to export recordsets in CSV and tab-delimited format.
- CachePageExecute() does not work - fixed - thx John Huong.
- Interbase aliases not set properly in FetchField() - fixed. Thx Stefan Goethals.
- Added cache property to adodb pager class. The number of secs to cache recordsets.
- SQL rewriting bug in pageexecute() due to skipping of newlines due to missing /s modifier. Fixed.
- Max size of cached recordset due to a bug was 256000 bytes. Fixed.
- Speedup of 1st invocation of CacheExecute() by tuning code.
- We compare $rewritesql with $sql in pageexecute code in case of rewrite failure.
## 2.11 - 7 June 2002
- Fixed PageExecute() rewrite sql problem - COUNT(*) and ORDER BY don't go together with mssql, access and postgres. Thx to Alexander Zhukov alex#unipack.ru
- DB2 support for CHARACTER type added - thx John Huong huongch#bigfoot.com
- For ado, $argProvider not properly checked. Fixed - kalimero#ngi.it
- Added $conn->Replace() function for update with automatic insert if the record does not exist. Supported by all databases except interbase.
## 2.10 - 4 June 2002
- Added uniqueSort property to indicate mssql ORDER BY cols must be unique.
- Optimized session handler by crc32 the data. We only write if session data has changed.
- adodb_sess_read in adodb-session.php now returns ''correctly - thanks to Jorma Tuomainen, webmaster#wizactive.com
- Mssql driver did not throw EXECUTE errors correctly because ErrorMsg() and ErrorNo() called in wrong order. Pointed out by Alexios Fakos. Fixed.
- Changed ado to use client cursors. This fixes BeginTran() problems with ado.
- Added handling of timestamp type in ado.
- Added to ado_mssql support for insert_id() and affected_rows().
- Added support for mssql.datetimeconvert=0, available since php 4.2.0.
- Made UnixDate() less strict, so that the time is ignored if present.
- Changed quote() so that it checks for magic_quotes_gpc.
- Changed maxblobsize for odbc to default to 64000.
## 2.00 - 13 May 2002
- Added drivers _informix72_ for pre-7.3 versions, and _oci805_ for oracle 8.0.5, and postgres64 for postgresql 6.4 and earlier. The postgres and postgres7 drivers are now identical.
- Interbase now partially supports ADODB_FETCH_BOTH, by defaulting to ASSOC mode.
- Proper support for blobs in mssql. Also revised blob support code is base class. Now UpdateBlobFile() calls UpdateBlob() for consistency.
- Added support for changed odbc_fetch_into api in php 4.2.0 with $conn->_has_stupid_odbc_fetch_api_change.
- Fixed spelling of tablock locking hint in GenID( ) for mssql.
- Added RowLock( ) to several databases, including oci8, informix, sybase, etc. Fixed where error in mssql RowLock().
- Added sysDate and sysTimeStamp properties to most database drivers. These are the sql functions/constants for that database that return the current date and current timestamp, and are useful for portable inserts and updates.
- Support for RecordCount() caused date handling in sybase and mssql to break. Fixed, thanks to Toni Tunkkari, by creating derived classes for ADORecordSet_array for both databases. Generalized using arrayClass property. Also to support RecordCount(), changed metatype handling for ado drivers. Now the type returned in FetchField is no longer a number, but the 1-char data type returned by MetaType. At the same time, fixed a lot of date handling. Now mssql support dmy and mdy date formats. Also speedups in sybase and mssql with preg_match and ^ in date/timestamp handling. Added support in sybase and mssql for 24 hour clock in timestamps (no AM/PM).
- Extensive revisions to informix driver - thanks to Samuel CARRIERE samuel_carriere#hotmail.com
- Added $ok parameter to CommitTrans($ok) for easy rollbacks.
- Fixed odbc MetaColumns and MetaTables to save and restore $ADODB_FETCH_MODE.
- Some odbc drivers did not call the base connection class constructor. Fixed.
- Fixed regex for GetUpdateSQL() and GetInsertSQL() to support more legal character combinations.
## 1.99 - 21 April 2002
- Added emulated RecordCount() to all database drivers if $ADODB_COUNTRECS = true (which it is by default). Inspired by Cristiano Duarte (cunha17#uol.com.br).
- Unified stored procedure support for mssql and oci8\. Parameter() and PrepareSP() functions implemented.
- Added support for SELECT FIRST in informix, modified hasTop property to support this.
- Changed csv driver to handle updates/deletes/inserts properly (when Execute() returns true). Bind params also work now, and raiseErrorFn with csv driver. Added csv driver to QA process.
- Better error checking in oci8 UpdateBlob() and UpdateBlobFile().
- Added TIME type to MySQL - patch by Manfred h9125297#zechine.wu-wien.ac.at
- Prepare/Execute implemented for Interbase/Firebird
- Changed some regular expressions to be anchored by /^ $/ for speed.
- Added UnixTimeStamp() and UnixDate() to ADOConnection(). Now these functions are in both ADOConnection and ADORecordSet classes.
- Empty recordsets were not cached - fixed.
- Thanks to Gaetano Giunta (g.giunta#libero.it) for the oci8 code review. We didn't agree on everything, but i hoped we agreed to disagree!
## 1.90 - 6 April 2002
- Now all database drivers support fetch modes ADODB_FETCH_NUM and ADODB_FETCH_ASSOC, though still not fully tested. Eg. Frontbase, Sybase, Informix.
- NextRecordSet() support for mssql. Contributed by "Sven Axelsson" sven.axelsson#bokochwebb.se
- Added blob support for SQL Anywhere. Contributed by Wade Johnson wade#wadejohnson.de
- Fixed some security loopholes in server.php. Server.php also supports fetch mode.
- Generalized GenID() to support odbc and mssql drivers. Mssql no longer generates GUID's.
- Experimental RowLock($table,$where) for mssql.
- Properly implemented Prepare() in oci8 and ODBC.
- Added Bind() support to oci8 to support Prepare().
- Improved error handler. Catches CacheExecute() and GenID() errors now.
- Now if you are running php from the command line, debugging messages do not output html formating. Not 100% complete, but getting there.
## 1.81 - 22 March 2002
- Restored default $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT for backward compatibility.
- SelectLimit for oci8 improved - Our FIRST_ROWS optimization now does not overwrite existing hint.
- New Sybase SQL Anywhere driver. Contributed by Wade Johnson wade#wadejohnson.de
## 1.80 - 15 March 2002
- Redesigned directory structure of ADOdb files. Added new driver directory where all database drivers reside.
- Changed caching algorithm to create subdirectories. Now we scale better.
- Informix driver now supports insert_id(). Contribution by "Andrea Pinnisi" pinnisi#sysnet.it
- Added experimental ISO date and FetchField support for informix.
- Fixed a quoting bug in Execute() with bind parameters, causing problems with blobs.
- Mssql driver speedup by 10-15%.
- Now in CacheExecute($secs2cache,$sql,...), $secs2cache is optional. If missing, it will take the value defined in $connection->cacheSecs (default is 3600 seconds). Note that CacheSelectLimit(), the secs2cache is still compulsory - sigh.
- Sybase SQL Anywhere driver (using ODBC) contributed by Wade Johnson wade#wadejohnson.de
## 1.72 - 8 March 2002
- Added @ when returning Fields() to prevent spurious error - "Michael William Miller" mille562#pilot.msu.edu
- MetaDatabases() for postgres contributed by Phil pamelant#nerim.net
- Mitchell T. Young (mitch#youngfamily.org) contributed informix driver.
- Fixed rs2html() problem. I cannot reproduce, so probably a problem with pre PHP 4.1.0 versions, when supporting new ADODB_FETCH_MODEs.
- Mattia Rossi (mattia#technologist.com) contributed BlobDecode() and UpdateBlobFile() for postgresql using the postgres specific pg_lo_import()/pg_lo_open() - i don't use them but hopefully others will find this useful. See [this posting](http://phplens.com/lens/lensforum/msgs.php?id=1262) for an example of usage.
- Added UpdateBlobFile() for uploading files to a database.
- Made UpdateBlob() compatible with oci8po driver.
- Added noNullStrings support to oci8 driver. Oracle changes all ' ' strings to nulls, so you need to set strings to ' ' to prevent the nullifying of strings. $conn->noNullStrings = true; will do this for you automatically. This is useful when you define a char column as NOT NULL.
- Fixed UnixTimeStamp() bug - wasn't setting minutes and seconds properly. Patch from Agusti Fita i Borrell agusti#anglatecnic.com.
- Toni Tunkkari added patch for sybase dates. Problem with spaces in day part of date fixed.
## 1.71 - 18 Jan 2002
- Sequence start id support. Now $conn->Gen_ID('seqname', 50) to start sequence from 50.
- CSV driver fix for selectlimit, from Andreas - akaiser#vocote.de.
- Gam3r spotted that a global variable was undefined in the session handler.
- Mssql date regex had error. Fixed - reported by Minh Hoang vb_user#yahoo.com.
- DBTimeStamp() and DBDate() now accept iso dates and unix timestamps. This means that the PostgreSQL handling of dates in GetInsertSQL() and GetUpdateSQL() can be removed. Also if these functions are passed '' or null or false, we return a SQL null.
- GetInsertSQL() and GetUpdateSQL() now accept a new parameter, $magicq to indicate whether quotes should be inserted based on magic quote settings - suggested by dj#4ict.com.
- Reformated docs slightly based on suggestions by Chris Small.
## 1.65 - 28 Dec 2001
- Fixed borland_ibase class naming bug.
- Now instead of using $rs->fields[0] internally, we use reset($rs->fields) so that we are compatible with ADODB_FETCH_ASSOC mode. Reported by Nico S.
- Changed recordset constructor and _initrs() for oci8 so that it returns the field definitions even if no rows in the recordset. Reported by Rick Hickerson (rhickers#mv.mv.com).
- Improved support for postgresql in GetInsertSQL and GetUpdateSQL by "mike" mike#partner2partner.com and "Ryan Bailey" rebel#windriders.com
## 1.64 - 20 Dec 2001
- Danny Milosavljevic <danny.milo#gmx.net> added some patches for MySQL error handling and displaying default values.
- Fixed some ADODB_FETCH_BOTH inconsistencies in odbc and interbase.
- Added more tests to test suite to cover ADODB_FETCH_* and ADODB_ERROR_HANDLER.
- Added firebird (ibase) driver
- Added borland_ibase driver for interbase 6.5
## 1.63 - 13 Dec 2001
- Absolute to the adodb-lib.inc.php file not set properly. Fixed.
## 1.62 - 11 Dec 2001
- Major speedup of ADOdb for low-end web sites by reducing the php code loading and compiling cycle. We conditionally compile not so common functions. Moved csv code to adodb-csvlib.inc.php to reduce adodb.inc.php parsing. This file is loaded only when the csv/proxy driver is used, or CacheExecute() is run. Also moved PageExecute(), GetSelectSQL() and GetUpdateSQL() core code to adodb-lib.inc.php. This reduced the 70K main adodb.inc.php file to 55K, and since at least 20K of the file is comments, we have reduced 50K of code in adodb.inc.php to 35K. There should be 35% reduction in memory and thus 35% speedup in compiling the php code for the main adodb.inc.php file.
- Highly tuned SelectLimit() for oci8 for massive speed improvements on large files. Selecting 20 rows starting from the 20,000th row of a table is now 7 times faster. Thx to Tomas V V Cox.
- Allow . and # in table definitions in GetInsertSQL and GetUpdateSQL. See ADODB_TABLE_REGEX constant. Thx to Ari Kuorikoski.
- Added ADODB_PREFETCH_ROWS constant, defaulting to 10\. This determines the number of records to prefetch in a SELECT statement. Only used by oci8.
- Added high portability Oracle class called oci8po. This uses ? for bind variables, and lower cases column names.
- Now all database drivers support $ADODB_FETCH_MODE, including interbase, ado, and odbc: ADODB_FETCH_NUM and ADODB_FETCH_ASSOC. ADODB_FETCH_BOTH is not fully implemented for all database drivers.
## 1.61 - Nov 2001
- Added PO_RecordCount() and PO_Insert_ID(). PO stands for portable. Pablo Roca [pabloroca#mvps.org]
- GenID now returns 0 if not available. Safer is that you should check $conn->hasGenID for availability.
- M'soft ADO we now correctly close recordset in _close() peterd#telephonetics.co.uk
- MSSQL now supports GenID(). It generates a 16-byte GUID from mssql newid() function.
- Changed ereg_replace to preg_replace in SelectLimit. This is a fix for mssql. Ereg doesn't support t or n! Reported by marino Carlos xaplo#postnuke-espanol.org
- Added $recordset->connection. This is the ADOConnection object for the recordset. Works with cached and normal recordsets. Surprisingly, this had no affect on performance!
## 1.54 - 15 Nov 2001
- Fixed some more bugs in PageExecute(). I am getting sick of bug in this and will have to reconsider my QA here. The main issue is that I don't use PageExecute() and to check whether it is working requires a visual inspection of the html generated currently. It is possible to write a test script but it would be quite complicated :(
- More speedups of SelectLimit() for DB2, Oci8, access, vfp, mssql.
## 1.53 - 7 Nov 2001
- Added support for ADODB_FETCH_ASSOC for ado and odbc drivers.
- Tuned GetRowAssoc(false) in postgresql and mysql.
- Stephen Van Dyke contributed ADOdb icon, accepted with some minor mods.
- Enabled Affected_Rows() for postgresql
- Speedup for Concat() using implode() - Benjamin Curtis ben_curtis#yahoo.com
- Fixed some more bugs in PageExecute() to prevent infinite loops
## 1.52 - 5 Nov 2001
- Spelling error in CacheExecute() caused it to fail. $ql should be $sql in line 625!
- Added fixes for parsing [ and ] in GetUpdateSQL().
## 1.51 - 5 Nov 2001
- Oci8 SelectLimit() speedup by using OCIFetch().
- Oci8 was mistakenly reporting errors when $db->debug = true.
- If a connection failed with ODBC, it was not correctly reported - fixed.
- _connectionID was inited to -1, changed to false.
- Added $rs->FetchRow(), to simplify API, ala PEAR DB
- Added PEAR DB compat mode, which is still faster than PEAR! See adodb-pear.inc.php.
- Removed postgres pconnect debugging statement.
## 1.50 - 31 Oct 2001
- ADOdbConnection renamed to ADOConnection, and ADOdbFieldObject to ADOFieldObject.
- PageExecute() now checks for empty $rs correctly, and the errors in the docs on this subject have been fixed.
- odbc_error() does not return 6 digit error correctly at times. Implemented workaround.
- Added ADORecordSet_empty class. This will speedup INSERTS/DELETES/UPDATES because the return object created is much smaller.
- Added Prepare() to odbc, and oci8 (but doesn't work properly for oci8 still).
- Made pgsql a synonym for postgre7, and changed SELECT LIMIT to use OFFSET for compat with postgres 7.2.
- Revised adodb-cryptsession.php thanks to Ari.
- Set resources to false on _close, to force freeing of resources.
- Added adodb-errorhandler.inc.php, adodb-errorpear.inc.php and raiseErrorFn on Freek's urging.
- GetRowAssoc($toUpper=true): $toUpper added as default.
- Errors when connecting to a database were not captured formerly. Now we do it correctly.
## 1.40 - 19 September 2001
- PageExecute() to implement page scrolling added. Code and idea by Iván Oliva.
- Some minor postgresql fixes.
- Added sequence support using GenID() for postgresql, oci8, mysql, interbase.
- Added UpdateBlob support for interbase (untested).
- Added encrypted sessions (see adodb-cryptsession.php). By Ari Kuorikoski <kuoriari#finebyte.com>
## 1.31 - 21 August 2001
- Many bug fixes thanks to "GaM3R (Cameron)" <gamr#outworld.cx>. Some session changes due to Gam3r.
- Fixed qstr() to quote also.
- rs2html() now pretty printed.
- Jonathan Younger <jyounger#unilab.com> contributed the great idea GetUpdateSQL() and GetInsertSQL() which generates SQL to update and insert into a table from a recordset. Modify the recordset fields array, then can this function to generate the SQL (the SQL is not executed).
- Nicola Fankhauser <nicola.fankhauser#couniq.com> found some bugs in date handling for mssql.
- Added minimal Oracle support for LOBs. Still under development.
- Added $ADODB_FETCH_MODE so you can control whether recordsets return arrays which are numeric, associative or both. This is a global variable you set. Currently only MySQL, Oci8, Postgres drivers support this.
- PostgreSQL properly closes recordsets now. Reported by several people.
- Added UpdateBlob() for Oracle. A hack to make it easier to save blobs.
- Oracle timestamps did not display properly. Fixed.
## 1.20 - 6 June 2001
- Now Oracle can connect using tnsnames.ora or server and service name
- Extensive Oci8 speed optimizations. Oci8 code revised to support variable binding, and /*+ FIRST_ROWS */ hint.
- Worked around some 4.0.6 bugs in odbc_fetch_into().
- Paolo S. Asioli paolo.asioli#libero.it suggested GetRowAssoc().
- Escape quotes for oracle wrongly set to '. Now '' is used.
- Variable binding now works in ODBC also.
- Jumped to version 1.20 because I don't like 13 :-)
## 1.12 - 6 June 2001
- Changed $ADODB_DIR to ADODB_DIR constant to plug a security loophole.
- Changed _close() to close persistent connections also. Prevents connection leaks.
- Major revision of oracle and oci8 drivers. Added OCI_RETURN_NULLS and OCI_RETURN_LOBS to OCIFetchInto(). BLOB, CLOB and VARCHAR2 recognition in MetaType() improved. MetaColumns() returns columns in correct sort order.
- Interbase timestamp input format was wrong. Fixed.
## 1.11 - 20 May 2001
- Improved file locking for Windows.
- Probabilistic flushing of cache to avoid avalanche updates when cache timeouts.
- Cached recordset timestamp not saved in some scenarios. Fixed.
## 1.10 - 19 May 2001
- Added caching. CacheExecute() and CacheSelectLimit().
- Added csv driver. See [http://php.weblogs.com/ADODB_csv](http://php.weblogs.com/adodb_csv).
- Fixed SelectLimit(), SELECT TOP not working under certain circumstances.
- Added better Frontbase support of MetaTypes() by Frank M. Kromann.
## 1.01 - 24 April 2001
- Fixed SelectLimit bug. not quoted properly.
- SelectLimit: SELECT TOP -1 * FROM TABLE not support by Microsoft. Fixed.
- GetMenu improved by glen.davies#cce.ac.nz to support multiple hilited items
- FetchNextObject() did not work with only 1 record returned. Fixed bug reported by $tim#orotech.net
- Fixed mysql field max_length problem. Fix suggested by Jim Nicholson (jnich#att.com)
## 1.00 - 16 April 2001
- Given some brilliant suggestions on how to simplify ADOdb by akul. You no longer need to setup $ADODB_DIR yourself, and ADOLoadCode() is automatically called by ADONewConnection(), simplifying the startup code.
- FetchNextObject() added. Suggested by Jakub Marecek. This makes FetchObject() obsolete, as this is more flexible and powerful.
- Misc fixes to SelectLimit() to support Access (top must follow distinct) and Fields() in the array recordset. From Reinhard Balling.
## 0.96 - 27 Mar 2001
- ADOConnection Close() did not return a value correctly. Thanks to akul#otamedia.com.
- When the horrible magic_quotes is enabled, back-slash () is changed to double-backslash (\). This doesn't make sense for Microsoft/Sybase databases. We fix this in qstr().
- Fixed Sybase date problem in UnixDate() thanks to Toni Tunkkari. Also fixed MSSQL problem in UnixDate() - thanks to milhouse31#hotmail.com.
- MoveNext() moved to leaf classes for speed in MySQL/PostgreSQL. 10-15% speedup.
- Added null handling in bindInputArray in Execute() -- Ron Baldwin suggestion.
- Fixed some option tags. Thanks to john#jrmstudios.com.
## 0.95 - 13 Mar 2001
- Added postgres7 database driver which supports LIMIT and other version 7 stuff in the future.
- Added SelectLimit to ADOConnection to simulate PostgreSQL's "select * from table limit 10 offset 3". Added helper function GetArrayLimit() to ADORecordSet.
- Fixed mysql metacolumns bug. Thanks to Freek Dijkstra (phpeverywhere#macfreek.com).
- Also many PostgreSQL changes by Freek. He almost rewrote the whole PostgreSQL driver!
- Added fix to input parameters in Execute for non-strings by Ron Baldwin.
- Added new metatype, X for TeXt. Formerly, metatype B for Blob also included text fields. Now 'B' is for binary/image data. 'X' for textual data.
- Fixed $this->GetArray() in GetRows().
- Oracle and OCI8: 1st parameter is always blank -- now warns if it is filled.
- Now _hasLimit_ and _hasTop_ added to indicate whether SELECT * FROM TABLE LIMIT 10 or SELECT TOP 10 * FROM TABLE are supported.
## 0.94 - 04 Feb 2001
- Added ADORecordSet::GetRows() for compatibility with Microsoft ADO. Synonym for GetArray().
- Added new metatype 'R' to represent autoincrement numbers.
- Added ADORecordSet.FetchObject() to return a row as an object.
- Finally got a Linux box to test PostgreSql. Many fixes.
- Fixed copyright misspellings in 0.93.
- Fixed mssql MetaColumns type bug.
- Worked around odbc bug in PHP4 for sessions.
- Fixed many documentation bugs (affected_rows, metadatabases, qstr).
- Fixed MySQL timestamp format (removed comma).
- Interbase driver did not call ibase_pconnect(). Fixed.
## 0.93 - 18 Jan 2002
- Fixed GetMenu bug.
- Simplified Interbase commit and rollback.
- Default behaviour on closing a connection is now to rollback all active transactions.
- Added field object handling for array recordset for future XML compatibility.
- Added arr2html() to convert array to html table.
## 0.92 - 2 Jan 2002
- Interbase Commit and Rollback should be working again.
- Changed initialisation of ADORecordSet. This is internal and should not affect users. We are doing this to support cached recordsets in the future.
- Implemented ADORecordSet_array class. This allows you to simulate a database recordset with an array.
- Added UnixDate() and UnixTimeStamp() to ADORecordSet.
## 0.91 - 21 Dec 2000
- Fixed ODBC so ErrorMsg() is working.
- Worked around ADO unrecognised null (0x1) value problem in COM.
- Added Sybase support for FetchField() type
- Removed debugging code and unneeded html from various files
- Changed to javadoc style comments to adodb.inc.php.
- Added maxsql as synonym for mysqlt
- Now ODBC downloads first 8K of blob by default
## 0.90 - 15 Nov 2000
- Lots of testing of Microsoft ADO. Should be more stable now.
- Added $ADODB_COUNTREC. Set to false for high speed selects.
- Added Sybase support. Contributed by Toni Tunkkari (toni.tunkkari#finebyte.com). Bug in Sybase API: GetFields is unable to determine date types.
- Changed behaviour of RecordSet.GetMenu() to support size parameter (listbox) properly.
- Added emptyDate and emptyTimeStamp to RecordSet class that defines how to represent empty dates.
- Added MetaColumns($table) that returns an array of ADOFieldObject's listing the columns of a table.
- Added transaction support for PostgresSQL -- thanks to "Eric G. Werk" egw#netguide.dk.
- Added adodb-session.php for session support.
## 0.80 - 30 Nov 2000
- Added support for charSet for interbase. Implemented MetaTables for most databases. PostgreSQL more extensively tested.
## 0.71 - 22 Nov 2000
- Switched from using require_once to include/include_once for backward compatability with PHP 4.02 and earlier.
## 0.70 - 15 Nov 2000
- Calls by reference have been removed (call_time_pass_reference=Off) to ensure compatibility with future versions of PHP, except in Oracle 7 driver due to a bug in php_oracle.dll.
- PostgreSQL database driver contributed by Alberto Cerezal (acerezalp#dbnet.es).
- Oci8 driver for Oracle 8 contributed by George Fourlanos (fou#infomap.gr).
- Added _mysqlt_ database driver to support MySQL 3.23 which has transaction support.
- Oracle default date format (DD-MON-YY) did not match ADOdb default date format (which is YYYY-MM-DD). Use ALTER SESSION to force the default date.
- Error message checking is now included in test suite.
- MoveNext() did not check EOF properly -- fixed.
## 0.60 - 8 Nov 2000
- Fixed some constructor bugs in ODBC and ADO. Added ErrorNo function to ADOConnection class.
## 0.51 - 18 Oct 2000
- Fixed some interbase bugs.
## 0.50 - 16 Oct 2000
- Interbase commit/rollback changed to be compatible with PHP 4.03\.
- CommitTrans( ) will now return true if transactions not supported.
- Conversely RollbackTrans( ) will return false if transactions not supported.
## 0.46 - 12 Oct 2000
- Many Oracle compatibility issues fixed.
## 0.40 - 26 Sept 2000
- Many bug fixes
- Now Code for BeginTrans, CommitTrans and RollbackTrans is working. So is the Affected_Rows and Insert_ID. Added above functions to test.php.
- ADO type handling was busted in 0.30\. Fixed.
- Generalised Move( ) so it works will all databases, including ODBC.
## 0.30 - 18 Sept 2000
- Renamed ADOLoadDB to ADOLoadCode. This is clearer.
- Added BeginTrans, CommitTrans and RollbackTrans functions.
- Added Affected_Rows() and Insert_ID(), _affectedrows() and _insertID(), ListTables(), ListDatabases(), ListColumns().
- Need to add New_ID() and hasInsertID and hasAffectedRows, autoCommit
## 0.20 - 12 Sept 2000
- Added support for Microsoft's ADO.
- Added new field to ADORecordSet -- canSeek
- Added new parameter to _fetch($ignore_fields = false). Setting to true will not update fields array for faster performance.
- Added new field to ADORecordSet/ADOConnection -- dataProvider to indicate whether a class is derived from odbc or ado.
- Changed class ODBCFieldObject to ADOFieldObject -- not documented currently.
- Added benchmark.php and testdatabases.inc.php to the test suite.
- Added to ADORecordSet FastForward( ) for future high speed scrolling. Not documented.
- Realised that ADO's Move( ) uses relative positioning. ADOdb uses absolute.
## 0.10 - 9 Sept 2000
- First release

View File

@@ -0,0 +1,242 @@
# ADOdb old Changelog - v3.x
See the [Current Changelog](changelog.md).
Older changelogs:
[v2.x](changelog_v2.x.md).
## 3.94 - 11 Oct 2003
- Create trigger in datadict-oci8.inc.php did not work, because all cr/lf's must be removed.
- ErrorMsg()/ErrorNo() did not work for many databases when logging enabled. Fixed.
- Removed global variable $ADODB_LOGSQL as it does not work properly with multiple connections.
- Added SQLDate support for sybase. Thx to Chris Phillipson
- Postgresql checking of pgsql resultset resource was incorrect. Fix by Bharat Mediratta bharat#menalto.com. Same patch applied to _insertid and _affectedrows for adodb-postgres64.inc.php.
- Added support for NConnect for postgresql.
- Added Sybase data dict support. Thx to Chris Phillipson
- Extensive improvements in $perf->UI(), eg. Explain now opens in new window, we show scripts which call sql, etc.
- Perf Monitor UI works with magic quotes enabled.
- rsPrefix was declared twice. Removed.
- Oci8 stored procedure support, eg. "begin func(); end;" was incorrect in _query. Fixed.
- Tiraboschi Massimiliano contributed italian language file.
- Fernando Ortiz, fortiz#lacorona.com.mx, contributed informix performance monitor.
- Added _varchar (varchar arrays) support for postgresql. Reported by PREVOT Stéphane.
## 3.92 - 22 Sept 2003
- Added GetAssoc and CacheGetAssoc to connection object.
- Removed TextMax and CharMax functions from adodb.inc.php.
- HasFailedTrans() returned false when trans failed. Fixed.
- Moved perf driver classes into adodb/perf/*.php.
- Misc improvements to performance monitoring, including UI().
- RETVAL in mssql Parameter(), we do not append @ now.
- Added Param($name) to connection class, returns '?' or ":$name", for defining bind parameters portably.
- LogSQL traps affected_rows() and saves its value properly now. Also fixed oci8 _stmt and _affectedrows() bugs.
- Session code timestamp check for oci8 works now. Formerly default NLS_DATE_FORMAT stripped off time portion. Thx to Tony Blair (tonanbarbarian#hotmail.com). Also added new $conn->datetime field to oci8, controls whether MetaType() returns 'D' ($this->datetime==false) or 'T' ($this->datetime == true) for DATE type.
- Fixed bugs in adodb-cryptsession.inc.php and adodb-session-clob.inc.php.
- Fixed misc bugs in adodb_key_exists, GetInsertSQL() and GetUpdateSQL().
- Tuned include_once handling to reduce file-system checking overhead.
## 3.91 - 9 Sept 2003
- Only released to InterAkt
- Added LogSQL() for sql logging and $ADODB_NEWCONNECTION to override factory for driver instantiation.
- Added IfNull($field,$ifNull) function, thx to johnwilk#juno.com
- Added portable substr support.
- Now rs2html() has new parameter, $echo. Set to false to return $html instead of echoing it.
## 3.90 - 5 Sept 2003
- First beta of performance monitoring released.
- MySQL supports MetaTable() masking.
- Fixed key_exists() bug in adodb-lib.inc.php
- Added sp_executesql Prepare() support to mssql.
- Added bind support to db2.
- Added swedish language file - Christian Tiberg" christian#commsoft.nu
- Bug in drop index for mssql data dict fixed. Thx to Gert-Rainer Bitterlich.
- Left join setting for oci8 was wrong. Thx to johnwilk#juno.com
## 3.80 - 27 Aug 2003
- Patch for PHP 4.3.3 cached recordset csv2rs() fread loop incompatibility.
- Added matching mask for MetaTables. Only for oci8, mssql and postgres currently.
- Rewrite of "oracle" driver connection code, merging with "oci8", by Gaetano.
- Added better debugging for Smart Transactions.
- Postgres DBTimeStamp() was wrongly using TO_DATE. Changed to TO_TIMESTAMP.
- ADODB_FETCH_CASE check pushed to ADONewConnection to allow people to define it after including adodb.inc.php.
- Added portugese (brazilian) to languages. Thx to "Levi Fukumori".
- Removed arg3 parameter from Execute/SelectLimit/Cache* functions.
- Execute() now accepts 2-d array as $inputarray. Also changed docs of fnExecute() to note change in sql query counting with 2-d arrays.
- Added MONEY to MetaType in PostgreSQL.
- Added more debugging output to CacheFlush().
## 3.72 - 9 Aug 2003
- Added qmagic($str), which is a qstr($str) that auto-checks for magic quotes and does the right thing...
- Fixed CacheFlush() bug - Thx to martin#gmx.de
- Walt Boring contributed MetaForeignKeys for postgres7.
- _fetch() called _BlobDecode() wrongly in interbase. Fixed.
- adodb_time bug fixed with dates after 2038 fixed by Jason Pell. http://phplens.com/lens/lensforum/msgs.php?id=6980
## 3.71 - 4 Aug 2003
- The oci8 driver, MetaPrimaryKeys() did not check the owner correctly when $owner == false.
- Russian language file contributed by "Cyrill Malevanov" cyrill#malevanov.spb.ru.
- Spanish language file contributed by "Horacio Degiorgi" horaciod#codigophp.com.
- Error handling in oci8 bugfix - if there was an error in Execute(), then when calling ErrorNo() and/or ErrorMsg(), the 1st call would return the error, but the 2nd call would return no error.
- Error handling in odbc bugfix. ODBC would always return the last error, even if it happened 5 queries ago. Now we reset the errormsg to '' and errorno to 0 everytime before CacheExecute() and Execute().
## 3.70 - 29 July 2003
- Added new SQLite driver. Tested on PHP 4.3 and PHP 5.
- Added limited "sapdb" driver support - mainly date support.
- The oci8 driver did not identify NUMBER with no defined precision correctly.
- Added ADODB_FORCE_NULLS, if set, then PHP nulls are converted to SQL nulls in GetInsertSQL/GetUpdateSQL.
- DBDate() and DBTimeStamp() format for postgresql had problems. Fixed.
- Added tableoptions to ChangeTableSQL(). Thx to Mike Benoit.
- Added charset support to postgresql. Thx to Julian Tarkhanov.
- Changed OS check for MS-Windows to prevent confusion with darWIN (MacOS)
- Timestamp format for db2 was wrong. Changed to yyyy-mm-dd-hh.mm.ss.nnnnnn.
- adodb-cryptsession.php includes wrong. Fixed.
- Added MetaForeignKeys(). Supported by mssql, odbc_mssql and oci8.
- Fixed some oci8 MetaColumns/MetaPrimaryKeys bugs. Thx to Walt Boring.
- adodb_getcount() did not init qryRecs to 0\. Missing "WHERE" clause checking in GetUpdateSQL fixed. Thx to Sebastiaan van Stijn.
- Added support for only 'VIEWS' and "TABLES" in MetaTables. From Walt Boring.
- Upgraded to adodb-xmlschema.inc.php 0.0.2.
- NConnect for mysql now returns value. Thx to Dennis Verspuij.
- ADODB_FETCH_BOTH support added to interbase/firebird.
- Czech language file contributed by Kamil Jakubovic jake#host.sk.
- PostgreSQL BlobDecode did not use _connectionID properly. Thx to Juraj Chlebec.
- Added some new initialization stuff for Informix. Thx to "Andrea Pinnisi" pinnisi#sysnet.it
- ADODB_ASSOC_CASE constant wrong in sybase _fetch(). Fixed.
## 3.60 - 16 June 2003
- We now SET CONCAT_NULL_YIELDS_NULL OFF for odbc_mssql driver to be compat with mssql driver.
- The property $emptyDate missing from connection class. Also changed 1903 to constant (TIMESTAMP_FIRST_YEAR=100). Thx to Sebastiaan van Stijn.
- ADOdb speedup optimization - we now return all arrays by reference.
- Now DBDate() and DBTimeStamp() now accepts the string 'null' as a parameter. Suggested by vincent.
- Added GetArray() to connection class.
- Added not_null check in informix metacolumns().
- Connection parameters for postgresql did not work correctly when port was defined.
- DB2 is now a tested driver, making adodb 100% compatible. Extensive changes to odbc driver for DB2, including implementing serverinfo() and SQLDate(), switching to SQL_CUR_USE_ODBC as the cursor mode, and lastAffectedRows and SelectLimit() fixes.
- The odbc driver's FetchField() field names did not obey ADODB_ASSOC_CASE. Fixed.
- Some bugs in adodb_backtrace() fixed.
- Added "INT IDENTITY" type to adorecordset::MetaType() to support odbc_mssql properly.
- MetaColumns() for oci8, mssql, odbc revised to support scale. Also minor revisions to odbc MetaColumns() for vfp and db2 compat.
- Added unsigned support to mysql datadict class. Thx to iamsure.
- Infinite loop in mssql MoveNext() fixed when ADODB_FETCH_ASSOC used. Thx to Josh R, Night_Wulfe#hotmail.com.
- ChangeTableSQL contributed by Florian Buzin.
- The odbc_mssql driver now sets CONCAT_NULL_YIELDS_NULL OFF for compat with mssql driver.
## 3.50 - 19 May 2003
- Fixed mssql compat with FreeTDS. FreeTDS does not implement mssql_fetch_assoc().
- Merged back connection and recordset code into adodb.inc.php.
- ADOdb sessions using oracle clobs contributed by achim.gosse#ddd.de. See adodb-session-clob.php.
- Added /s modifier to preg_match everywhere, which ensures that regex does not stop at /n. Thx Pao-Hsi Huang.
- Fixed error in metacolumns() for mssql.
- Added time format support for SQLDate.
- Image => B added to metatype.
- MetaType now checks empty($this->blobSize) instead of empty($this).
- Datadict has beta support for informix, sybase (mapped to mssql), db2 and generic (which is a fudge).
- BlobEncode for postgresql uses pg_escape_bytea, if available. Needed for compat with 7.3.
- Added $ADODB_LANG, to support multiple languages in MetaErrorMsg().
- Datadict can now parse table definition as declarative text.
- For DataDict, oci8 autoincrement trigger missing semi-colon. Fixed.
- For DataDict, when REPLACE flag enabled, drop sequence in datadict for autoincrement field in postgres and oci8.s
- Postgresql defaults to template1 database if no database defined in connect/pconnect.
- We now clear _resultid in postgresql if query fails.
## 3.40 - 19 May 2003
- Added insert_id for odbc_mssql.
- Modified postgresql UpdateBlobFile() because it did not work in safe mode.
- Now connection object is passed to raiseErrorFn as last parameter. Needed by StartTrans().
- Added StartTrans() and CompleteTrans(). It is recommended that you do not modify transOff, but use the above functions.
- oci8po now obeys ADODB_ASSOC_CASE settings.
- Added virtualized error codes, using PEAR DB equivalents. Requires you to manually include adodb-error.inc.php yourself, with MetaError() and MetaErrorMsg($errno).
- GetRowAssoc for mysql and pgsql were flawed. Fix by Ross Smith.
- Added to datadict types I1, I2, I4 and I8\. Changed datadict type 'T' to map to timestamp instead of datetime for postgresql.
- Error handling in ExecuteSQLArray(), adodb-datadict.inc.php did not work.
- We now auto-quote postgresql connection parameters when building connection string.
- Added session expiry notification.
- We now test with odbc mysql - made some changes to odbc recordset constructor.
- MetaColumns now special cases access and other databases for odbc.
## 3.31 - 17 March 2003
- Added row checking for _fetch in postgres.
- Added Interval type to MetaType for postgres.
- Remapped postgres driver to call postgres7 driver internally.
- Adorecordset_array::getarray() did not return array when nRows >= 0.
- Postgresql: at times, no error message returned by pg_result_error() but error message returned in pg_last_error(). Recoded again.
- Interbase blob's now use chunking for updateblob.
- Move() did not set EOF correctly. Reported by Jorma T.
- We properly support mysql timestamp fields when we are creating mysql tables using the data-dict interface.
- Table regex includes backticks character now.
## 3.30 - 3 March 2003
- Added $ADODB_EXTENSION and $ADODB_COMPAT_FETCH constant.
- Made blank1stItem configurable using syntax "value:text" in GetMenu/GetMenu2. Thx to Gabriel Birke.
- Previously ADOdb differed from the Microsoft standard because it did not define what to set $this->fields when EOF was reached. Now at EOF, ADOdb sets $this->fields to false for all databases, which is consist with Microsoft's implementation. Postgresql and mysql have always worked this way (in 3.11 and earlier). If you are experiencing compatibility problems (and you are not using postgresql nor mysql) on upgrading to 3.30, try setting the global variables $ADODB_COUNTRECS = true (which is the default) and $ADODB_FETCH_COMPAT = true (this is a new global variable).
- We now check both pg_result_error and pg_last_error as sometimes pg_result_error does not display anything. Iman Mayes
- We no longer check for magic quotes gpc in Quote().
- Misc fixes for table creation in adodb-datadict.inc.php. Thx to iamsure.
- Time calculations use adodb_time library for all negative timestamps due to problems in Red Hat 7.3 or later. Formerly, only did this for Windows.
- In mssqlpo, we now check if $sql in _query is a string before we change || to +. This is to support prepared stmts.
- Move() and MoveLast() internals changed to support to support EOF and $this->fields change.
- Added ADODB_FETCH_BOTH support to mssql. Thx to Angel Fradejas afradejas#mediafusion.es
- We now check if link resource exists before we run mysql_escape_string in qstr().
- Before we flock in csv code, we check that it is not a http url.
## 3.20 - 17 Feb 2003
- Added new Data Dictionary classes for creating tables and indexes. Warning - this is very much alpha quality code. The API can still change. See adodb/tests/test-datadict.php for more info.
- We now ignore $ADODB_COUNTRECS for mysql, because PHP truncates incomplete recordsets when mysql_unbuffered_query() is called a second time.
- Now postgresql works correctly when $ADODB_COUNTRECS = false.
- Changed _adodb_getcount to properly support SELECT DISTINCT.
- Discovered that $ADODB_COUNTRECS=true has some problems with prepared queries - suspect PHP bug.
- Now GetOne and GetRow run in $ADODB_COUNTRECS=false mode for better performance.
- Added support for mysql_real_escape_string() and pg_escape_string() in qstr().
- Added an intermediate variable for mysql _fetch() and MoveNext() to store fields, to prevent overwriting field array with boolean when mysql_fetch_array() returns false.
- Made arrays for getinsertsql and getupdatesql case-insensitive. Suggested by Tim Uckun" tim#diligence.com
## 3.11 - 11 Feb 2003
- Added check for ADODB_NEVER_PERSIST constant in PConnect(). If defined, then PConnect() will actually call non-persistent Connect().
- Modified interbase to properly work with Prepare().
- Added $this->ibase_timefmt to allow you to change the date and time format.
- Added support for $input_array parameter in CacheFlush().
- Added experimental support for dbx, which was then removed when i found that it was slower than using native calls.
- Added MetaPrimaryKeys for mssql and ibase/firebird.
- Added new $trim parameter to GetCol and CacheGetCol
- Uses updated adodb-time.inc.php 0.06.
## 3.10 - 27 Jan 2003
- Added adodb_date(), adodb_getdate(), adodb_mktime() and adodb-time.inc.php.
- For interbase, added code to handle unlimited number of bind parameters. From Daniel Hasan daniel#hasan.cl.
- Added BlobDecode and UpdateBlob for informix. Thx to Fernando Ortiz.
- Added constant ADODB_WINDOWS. If defined, means that running on Windows.
- Added constant ADODB_PHPVER which stores php version as a hex num. Removed $ADODB_PHPVER variable.
- Felho Bacsi reported a minor white-space regular expression problem in GetInsertSQL.
- Modified ADO to use variant to store _affectedRows
- Changed ibase to use base class Replace(). Modified base class Replace() to support ibase.
- Changed odbc to auto-detect when 0 records returned is wrong due to bad odbc drivers.
- Changed mssql to use datetimeconvert ini setting only when 4.30 or later (does not work in 4.23).
- ExecuteCursor($stmt, $cursorname, $params) now accepts a new $params array of additional bind parameters -- William Lovaton walovaton#yahoo.com.mx.
- Added support for sybase_unbuffered_query if ADODB_COUNTRECS == false. Thx to chuck may.
- Fixed FetchNextObj() bug. Thx to Jorma Tuomainen.
- We now use SCOPE_IDENTITY() instead of @@IDENTITY for mssql - thx to marchesini#eside.it
- Changed postgresql movenext logic to prevent illegal row number from being passed to pg_fetch_array().
- Postgresql initrs bug found by "Bogdan RIPA" bripa#interakt.ro $f1 accidentally named $f
## 3.00 - 6 Jan 2003
- Fixed adodb-pear.inc.php syntax error.
- Improved _adodb_getcount() to use SELECT COUNT(*) FROM ($sql) for languages that accept it.
- Fixed _adodb_getcount() caching error.
- Added sql to retrive table and column info for odbc_mssql.

View File

@@ -0,0 +1,109 @@
## 4.990/5.05 - 11 Jul 2008
- Added support for multiple recordsets in mysqli Geisel Sierote <geisel#4up.com.br>. See http://phplens.com/lens/lensforum/msgs.php?id=15917
- Malcolm Cook added new Reload() function to Active Record. See http://phplens.com/lens/lensforum/msgs.php?id=17474
- Thanks Zoltan Monori [monzol#fotoprizma.hu] for bug fixes in iterator, SelectLimit, GetRandRow, etc.
- Under heavy loads, the performance monitor for oci8 disables Ixora views.
- Fixed sybase driver SQLDate to use str_replace(). Also for adodb5, changed sybase driver UnixDate and UnixTimeStamp calls to static.
- Changed oci8 lob handler to use &amp; reference $this-&gt;_refLOBs[$numlob]['VAR'] = &amp;$var.
- We now strtolower the get_class() function in PEAR::isError() for php5 compat.
- CacheExecute did not retrieve cache recordsets properly for 5.04 (worked in 4.98). Fixed.
- New ADODB_Cache_File class for file caching defined in adodb.inc.php.
- Farsi language file contribution by Peyman Hooshmandi Raad (phooshmand#gmail.com)
- New API for creating your custom caching class which is stored in $ADODB_CACHE:
```
include "/path/to/adodb.inc.php";
$ADODB_CACHE_CLASS = 'MyCacheClass';
class MyCacheClass extends ADODB_Cache_File
{
function writecache($filename, $contents,$debug=false){...}
function &readcache($filename, &$err, $secs2cache, $rsClass){ ...}
:
}
$DB = NewADOConnection($driver);
$DB->Connect(...); ## MyCacheClass created here and stored in $ADODB_CACHE global variable.
$data = $rs->CacheGetOne($sql); ## MyCacheClass is used here for caching...
```
- Memcache supports multiple pooled hosts now. Only if none of the pooled servers can be contacted will a connect error be generated. Usage example below:
```
$db = NewADOConnection($driver);
$db->memCache = true; /// should we use memCache instead of caching in files
$db->memCacheHost = array($ip1, $ip2, $ip3); /// $db->memCacheHost = $ip1; still works
$db->memCachePort = 11211; /// this is default memCache port
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
$db->Connect(...);
$db->CacheExecute($sql);
```
## 4.98/5.04 - 13 Feb 2008
- Fixed adodb_mktime problem which causes a performance bottleneck in $hrs.
- Added mysqli support to adodb_getcount().
- Removed MYSQLI_TYPE_CHAR from MetaType().
## 4.97/5.03 - 22 Jan 2008
- Active Record: $ADODB_ASSOC_CASE=1 did not work properly. Fixed.
- Modified Fields() in recordset class to support display null fields in FetchNextObject().
- In ADOdb5, active record implementation, we now support column names with spaces in them - we autoconvert the spaces to _ using __set(). Thx Daniel Cook. http://phplens.com/lens/lensforum/msgs.php?id=17200
- Removed $arg3 from mysqli SelectLimit. See http://phplens.com/lens/lensforum/msgs.php?id=16243. Thx Zsolt Szeberenyi.
- Changed oci8 FetchField, which returns the max_length of BLOB/CLOB/NCLOB as 4000 (incorrectly) to -1.
- CacheExecute would sometimes return an error on Windows if it was unable to lock the cache file. This is harmless and has been changed to a warning that can be ignored. Also adodb_write_file() code revised.
- ADOdb perf code changed to only log sql if execution time &gt;= 0.05 seconds. New $ADODB_PERF_MIN variable holds min sql timing. Any SQL with timing value below this and is not causing an error is not logged.
- Also adodb_backtrace() now traces 1 level deeper as sometimes actual culprit function is not displayed.
- Fixed a group by problem with adodb_getcount() for db's which are not postgres/oci8 based.
- Changed mssql driver Parameter() from SQLCHAR to SQLVARCHAR: case 'string': $type = SQLVARCHAR; break.
- Problem with mssql driver in php5 (for adodb 5.03) because some functions are not static. Fixed.
## 4.96/5.02 - 24 Sept 2007
ADOdb perf for oci8 now has non-table-locking code when clearing the sql. Slower but better transparency. Added in 4.96a and 5.02a.
Fix adodb count optimisation. Preg_match did not work properly. Also rewrote the ORDER BY stripping code in _adodb_getcount(), adodb-lib.inc.php.
SelectLimit for oci8 not optimal for large recordsets when offset=0. Changed $nrows check.
Active record optimizations. Added support for assoc arrays in Set().
Now GetOne returns null if EOF (no records found), and false if error occurs. Use ErrorMsg()/ErrorNo() to get the error.
Also CacheGetRow and CacheGetCol will return false if error occurs, or empty array() if EOF, just like GetRow and GetCol.
Datadict now allows changing of types which are not resizable, eg. VARCHAR to TEXT in ChangeTableSQL. -- Mateo Tibaquirá
Added BIT data type support to adodb-ado.inc.php and adodb-ado5.inc.php.
Ldap driver did not return actual ldap error messages. Fixed.
Implemented GetRandRow($sql, $inputarr). Optimized for Oci8.
Changed adodb5 active record to use static SetDatabaseAdapter() and removed php4 constructor. Bas van Beek bas.vanbeek#gmail.com.
Also in adodb5, changed adodb-session2 to use static function declarations in class. Thx Daniel Berlin.
Added "Clear SQL Log" to bottom of Performance screen.
Sessions2 code echo'ed directly to the screen in debug mode. Now uses ADOConnection::outp().
In mysql/mysqli, qstr(null) will return the string "null" instead of empty quoted string "''".
postgresql optimizeTable in perf-postgres.inc.php added by Daniel Berlin (mail#daniel-berlin.de)
Added 5.2.1 compat code for oci8.
Changed @@identity to SCOPE_IDENTITY() for multiple mssql drivers. Thx Stefano Nari.
Code sanitization introduced in 4.95 caused problems in European locales (as float 3.2 was typecast to 3,2). Now we only sanitize if is_numeric fails.
Added support for customizing ADORecordset_empty using $this-&gt;rsPrefix.'empty'. By Josh Truwin.
Added proper support for ALterColumnSQL for Postgresql in datadict code. Thx. Josh Truwin.
Added better support for MetaType() in mysqli when using an array recordset.
Changed parser for pgsql error messages in adodb-error.inc.php to case-insensitive regex.
## 4.95/5.01 - 17 May 2007
CacheFlush debug outp() passed in invalid parameters. Fixed.
Added Thai language file for adodb. Thx Trirat Petchsingh rosskouk#gmail.com
and Marcos Pont
Added zerofill checking support to MetaColumns for mysql and mysqli.
CacheFlush no longer deletes all files/directories. Only *.cache files
deleted.
DB2 timestamp format changed to var $fmtTimeStamp =
&quot;'Y-m-d-H:i:s'&quot;;
Added some code sanitization to AutoExecute in adodb-lib.inc.php.
Due to typo, all connections in adodb-oracle.inc.php would become
persistent, even non-persistent ones. Fixed.
Oci8 DBTimeStamp uses 24 hour time for input now, so you can perform string
comparisons between 2 DBTimeStamp values.
Some PHP4.4 compat issues fixed in adodb-session2.inc.php
For ADOdb 5.01, fixed some adodb-datadict.inc.php MetaType compat issues
with PHP5.
The $argHostname was wiped out in adodb-ado5.inc.php. Fixed.
Adodb5 version, added iterator support for adodb_recordset_empty.
Adodb5 version,more error checking code now will use exceptions if
available.

View File

@@ -0,0 +1,722 @@
# ADOdb old Changelog - v4.x
See the [Current Changelog](changelog.md).
Older changelogs:
[v3.x](changelog_v3.x.md),
[v2.x](changelog_v2.x.md).
## 4.990 - 11 Jul 2008
- Added support for multiple recordsets in mysqli Geisel Sierote <geisel#4up.com.br>. See http://phplens.com/lens/lensforum/msgs.php?id=15917
- Malcolm Cook added new Reload() function to Active Record. See http://phplens.com/lens/lensforum/msgs.php?id=17474
- Thanks Zoltan Monori [monzol#fotoprizma.hu] for bug fixes in iterator, SelectLimit, GetRandRow, etc.
- Under heavy loads, the performance monitor for oci8 disables Ixora views.
- Fixed sybase driver SQLDate to use str_replace(). Also for adodb5, changed sybase driver UnixDate and UnixTimeStamp calls to static.
- Changed oci8 lob handler to use &amp; reference $this-&gt;_refLOBs[$numlob]['VAR'] = &amp;$var.
- We now strtolower the get_class() function in PEAR::isError() for php5 compat.
- CacheExecute did not retrieve cache recordsets properly for 5.04 (worked in 4.98). Fixed.
- New ADODB_Cache_File class for file caching defined in adodb.inc.php.
- Farsi language file contribution by Peyman Hooshmandi Raad (phooshmand#gmail.com)
- New API for creating your custom caching class which is stored in $ADODB_CACHE:
```
include "/path/to/adodb.inc.php";
$ADODB_CACHE_CLASS = 'MyCacheClass';
class MyCacheClass extends ADODB_Cache_File
{
function writecache($filename, $contents,$debug=false){...}
function &readcache($filename, &$err, $secs2cache, $rsClass){ ...}
:
}
$DB = NewADOConnection($driver);
$DB->Connect(...); ## MyCacheClass created here and stored in $ADODB_CACHE global variable.
$data = $rs->CacheGetOne($sql); ## MyCacheClass is used here for caching...
```
- Memcache supports multiple pooled hosts now. Only if none of the pooled servers can be contacted will a connect error be generated. Usage example below:
```
$db = NewADOConnection($driver);
$db->memCache = true; /// should we use memCache instead of caching in files
$db->memCacheHost = array($ip1, $ip2, $ip3); /// $db->memCacheHost = $ip1; still works
$db->memCachePort = 11211; /// this is default memCache port
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
$db->Connect(...);
$db->CacheExecute($sql);
```
## 4.98 - 13 Feb 2008
- Fixed adodb_mktime problem which causes a performance bottleneck in $hrs.
- Added mysqli support to adodb_getcount().
- Removed MYSQLI_TYPE_CHAR from MetaType().
## 4.97 - 22 Jan 2008
- Active Record: $ADODB_ASSOC_CASE=1 did not work properly. Fixed.
- Modified Fields() in recordset class to support display null fields in FetchNextObject().
- In ADOdb5, active record implementation, we now support column names with spaces in them - we autoconvert the spaces to `_` using `__set()`. Thx Daniel Cook. http://phplens.com/lens/lensforum/msgs.php?id=17200
- Removed $arg3 from mysqli SelectLimit. See http://phplens.com/lens/lensforum/msgs.php?id=16243. Thx Zsolt Szeberenyi.
- Changed oci8 FetchField, which returns the max_length of BLOB/CLOB/NCLOB as 4000 (incorrectly) to -1.
- CacheExecute would sometimes return an error on Windows if it was unable to lock the cache file. This is harmless and has been changed to a warning that can be ignored. Also adodb_write_file() code revised.
- ADOdb perf code changed to only log sql if execution time &gt;= 0.05 seconds. New $ADODB_PERF_MIN variable holds min sql timing. Any SQL with timing value below this and is not causing an error is not logged.
- Also adodb_backtrace() now traces 1 level deeper as sometimes actual culprit function is not displayed.
- Fixed a group by problem with adodb_getcount() for db's which are not postgres/oci8 based.
- Changed mssql driver Parameter() from SQLCHAR to SQLVARCHAR: case 'string': $type = SQLVARCHAR; break.
- Problem with mssql driver in php5 (for adodb 5.03) because some functions are not static. Fixed.
## 4.96 - 24 Sept 2007
- ADOdb perf for oci8 now has non-table-locking code when clearing the sql. Slower but better transparency. Added in 4.96a and 5.02a.
- Fix adodb count optimisation. Preg_match did not work properly. Also rewrote the ORDER BY stripping code in _adodb_getcount(), adodb-lib.inc.php.
- SelectLimit for oci8 not optimal for large recordsets when offset=0. Changed $nrows check.
- Active record optimizations. Added support for assoc arrays in Set().
- Now GetOne returns null if EOF (no records found), and false if error occurs. Use ErrorMsg()/ErrorNo() to get the error.
- Also CacheGetRow and CacheGetCol will return false if error occurs, or empty array() if EOF, just like GetRow and GetCol.
- Datadict now allows changing of types which are not resizable, eg. VARCHAR to TEXT in ChangeTableSQL. -- Mateo Tibaquirá
- Added BIT data type support to adodb-ado.inc.php and adodb-ado5.inc.php.
- Ldap driver did not return actual ldap error messages. Fixed.
- Implemented GetRandRow($sql, $inputarr). Optimized for Oci8.
- Changed adodb5 active record to use static SetDatabaseAdapter() and removed php4 constructor. Bas van Beek bas.vanbeek#gmail.com.
- Also in adodb5, changed adodb-session2 to use static function declarations in class. Thx Daniel Berlin.
- Added "Clear SQL Log" to bottom of Performance screen.
- Sessions2 code echo'ed directly to the screen in debug mode. Now uses ADOConnection::outp().
- In mysql/mysqli, qstr(null) will return the string "null" instead of empty quoted string "''".
- postgresql optimizeTable in perf-postgres.inc.php added by Daniel Berlin (mail#daniel-berlin.de)
- Added 5.2.1 compat code for oci8.
- Changed @@identity to SCOPE_IDENTITY() for multiple mssql drivers. Thx Stefano Nari.
- Code sanitization introduced in 4.95 caused problems in European locales (as float 3.2 was typecast to 3,2). Now we only sanitize if is_numeric fails.
- Added support for customizing ADORecordset_empty using $this-&gt;rsPrefix.'empty'. By Josh Truwin.
- Added proper support for ALterColumnSQL for Postgresql in datadict code. Thx. Josh Truwin.
- Added better support for MetaType() in mysqli when using an array recordset.
- Changed parser for pgsql error messages in adodb-error.inc.php to case-insensitive regex.
## 4.95 - 17 May 2007
- CacheFlush debug outp() passed in invalid parameters. Fixed.
- Added Thai language file for adodb. Thx Trirat Petchsingh rosskouk#gmail.com and Marcos Pont
- Added zerofill checking support to MetaColumns for mysql and mysqli.
- CacheFlush no longer deletes all files directories. Only `*.cache` files deleted.
- DB2 timestamp format changed to var $fmtTimeStamp = 'Y-m-d-H:i:s';
- Added some code sanitization to AutoExecute in adodb-lib.inc.php.
- Due to typo, all connections in adodb-oracle.inc.php would become persistent, even non-persistent ones. Fixed.
- Oci8 DBTimeStamp uses 24 hour time for input now, so you can perform string comparisons between 2 DBTimeStamp values.
- Some PHP4.4 compat issues fixed in adodb-session2.inc.php
- For ADOdb 5.01, fixed some adodb-datadict.inc.php MetaType compat issues with PHP5.
- The $argHostname was wiped out in adodb-ado5.inc.php. Fixed.
- Adodb5 version, added iterator support for adodb_recordset_empty.
- Adodb5 version,more error checking code now will use exceptions if available.
## 4.94 - 23 Jan 2007
- Active Record: $ADODB_ASSOC_CASE=2 did not work properly. Fixed. Thx gmane#auxbuss.com.
- mysqli had bugs in BeginTrans() and EndTrans(). Fixed.
- Improved error handling when no database is connected for oci8. Thx Andy Hassall.
- Names longer than 30 chars in oci8 datadict will be changed to random name. Thx Eugenio. http://phplens.com/lens/lensforum/msgs.php?id=16182
- Added var $upperCase = 'ucase' to access and ado_access drivers. Thx Renato De Giovanni renato#cria.org.br
- Postgres64 driver, if preparing plan failed in _query, did not handle error properly. Fixed. See http://phplens.com/lens/lensforum/msgs.php?id=16131.
- Fixed GetActiveRecordsClass() reference bug. See http://phplens.com/lens/lensforum/msgs.php?id=16120
- Added handling of nulls in adodb-ado_mssql.inc.php for qstr(). Thx to Felix Rabinovich.
- Adodb-dict contributions by Gaetano
- Support for INDEX in data-dict. Example: idx_ev1. The ability to define indexes using the INDEX keyword was added in ADOdb 4.94. The following example features mutiple indexes, including a compound index idx_ev1.
```
event_id I(11) NOTNULL AUTOINCREMENT PRIMARY,
event_type I(4) NOTNULL
event_start_date T DEFAULT NULL **INDEX id_esd**,
event_end_date T DEFAULT '0000-00-00 00:00:00' **INDEX id_eted**,
event_parent I(11) UNSIGNED NOTNULL DEFAULT 0 **INDEX id_evp**,
event_owner I(11) DEFAULT 0 **INDEX idx_ev1**,
event_project I(11) DEFAULT 0 **INDEX idx_ev1**,
event_times_recuring I(11) UNSIGNED NOTNULL DEFAULT 0,
event_icon C(20) DEFAULT 'obj/event',
event_description X
```
- Prevents the generated SQL from including double drop-sequence statements for REPLACE case of tables with autoincrement columns (on those dbs that emulate it via sequences)
- makes any date defined as DEFAULT value for D and T columns work cross-database, not just the "sysdate" value (as long as it is specified using adodb standard format). See above example.
- Fixed pdo's GetInsertID() support. Thx Ricky Su.
- oci8 Prepare() now sets error messages if an error occurs.
- Added 'PT_BR' to SetDateLocale() -- brazilian portugese.
- charset in oci8 was not set correctly on `*Connect()`
- ADOConnection::Transpose() now appends as first column the field names.
- Added $ADODB_QUOTE_FIELDNAMES. If set to true, will autoquote field names in AutoExecute(),GetInsertSQL(), GetUpdateSQL().
- Transpose now adds the field names as the first column after transposition.
- Added === check in ADODB_SetDatabaseAdapter for $db, adodb-active-record.inc.php. Thx Christian Affolter.
- Added ErrorNo() to adodb-active-record.inc.php. Thx ante#novisplet.com.
## 4.93 - 10 Oct 2006
- Added support for multiple database connections in performance monitoring code (adodb-perf.inc.php). Now all sql in multiple database connections can be saved into one database ($ADODB_LOG_CONN).
- Added MetaIndexes() to odbc_mssql.
- Added connection property $db->null2null = 'null'. In autoexecute/getinsertsql/getupdatesql, this value will be converted to a null. Set this to a funny invalid value if you do not want null conversion. See http://phplens.com/lens/lensforum/msgs.php?id=15902.
- Path disclosure problem in mysqli fixed. Thx Andy.
- Fixed typo in session_schema2.xml.
- Changed INT in oci8 to return correct precision in $fld->max_length, MetaColumns(). Thx Eloy Lafuente Plaza.
- Patched postgres64 _connect to handle serverinfo(). see http://phplens.com/lens/lensforum/msgs.php?id=15887.
- Added pdo fix for null columns. See http://phplens.com/lens/lensforum/msgs.php?id=15889
- For stored procedures, missing connection id now passed into mssql_query(). Thx Ecsy (ecsy#freemail.hu).
## 4.92a - 30 Aug 2006
- Syntax error in postgres7 driver. Thx Eloy Lafuente Plaza.
- Minor bug fixes - adodb informix 10 types added to adodb.inc.php. Thx Fernando Ortiz.
## 4.92 - 29 Aug 2006
- Better odbtp date support.
- Added IgnoreErrors() to bypass default error handling.
- The _adodb_getcount() function in adodb-lib.inc.php, some ORDER BY bug fixes.
- For ibase and firebird, set $sysTimeStamp = "CURRENT_TIMESTAMP".
- Fixed postgres connection bug: http://phplens.com/lens/lensforum/msgs.php?id=11057.
- Changed CacheSelectLimit() to flush cache when $secs2cache==-1 due to complaints from other users.
- Added support for using memcached with CacheExecute/CacheSelectLimit. Requires memcache module PECL extension. Usage:
```
$db = NewADOConnection($driver);
$db->memCache = true; /// should we use memCache instead of caching in files
$db->memCacheHost = "126.0.1.1"; /// memCache host
$db->memCachePort = 11211; /// this is default memCache port
$db->memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib)
$db->Connect(...);
$db->CacheExecute($sql);
```
- Implemented Transpose() for recordsets. Recordset must be retrieved using ADODB_FETCH_NUM. First column becomes the column name.
```
$db = NewADOConnection('mysql');
$db->Connect(...);
$db->SetFetchMode(ADODB_FETCH_NUM);
$rs = $db->Execute('select productname,productid,unitprice from products limit 10');
$rs2 = $db->Transpose($rs);
rs2html($rs2);
```
## 4.91 - 2 Aug 2006
- Major session code rewrite... See session docs.
- PDO bindinputarray() was not set properly for MySQL (changed from true to false).
- Changed CacheSelectLimit() to re-cache when $secs2cache==0. This is one way to flush the cache when SelectLimit is called.
- Added to quotes to mysql and mysqli: "SHOW COLUMNS FROM \`%s\`";
- Removed accidental optgroup handling in GetMenu(). Fixed ibase _BlobDecode for php5 compat, and also mem alloc issues for small blobs, thx salvatori#interia.pl
- Mysql driver OffsetDate() speedup, useful for adodb-sessions.
- Fix for GetAssoc() PHP5 compat. See http://phplens.com/lens/lensforum/msgs.php?id=15425
- Active Record - If inserting a record and the value of a primary key field is null, then we do not insert that field in as we assume it is an auto-increment field. Needed by mssql.
- Changed postgres7 MetaForeignKeys() see http://phplens.com/lens/lensforum/msgs.php?id=15531
- DB2 will now return db2_conn_errormsg() when it is a connection error.
## 4.90 - 8 June 2006
- Changed adodb_countrec() in adodb-lib.inc.php to allow LIMIT to be used as a speedup to reduce no of records counted.
- Added support for transaction modes for postgres and oci8 with SetTransactionMode(). These transaction modes affect all subsequent transactions of that connection.
- Thanks to Halmai Csongor for suggestion.
- Removed `$off = $fieldOffset - 1` line in db2 driver, FetchField(). Tx Larry Menard.
- Added support for PHP5 objects as Execute() bind parameters using `__toString` (eg. Simple-XML). Thx Carl-Christian Salvesen.
- Rounding in tohtml.inc.php did not work properly. Fixed.
- MetaIndexes in postgres fails when fields are deleted then added in again because the attnum has gaps in it. See http://sourceforge.net/tracker/index.php?func=detail&aid=1451245&group_id=42718&atid=433976. Fixed.
- MetaForeignkeys in mysql and mysqli did not work when fetchMode==ADODB_FETCH_ASSOC used. Fixed.
- Reference error in AutoExecute() fixed.
- Added macaddr postgres type to MetaType. Maps to 'C'.
- Added to `_connect()` in adodb-ado5.inc.php support for $database and $dataProvider parameters. Thx Larry Menard.
- Added support for sequences in adodb-ado_mssql.inc.php. Thx Larry Menard.
- Added ADODB_SESSION_READONLY.
- Added session expiryref support to crc32 mode, and in LOB code.
- Clear `_errorMsg` in postgres7 driver, so that ErrorMsg() displays properly when no error occurs.
- Added BindDate and BindTimeStamp
## 4.81 - 3 May 2006
- Fixed variable ref errors in adodb-ado5.inc.php in _query().
- Mysqli setcharset fix using method_exists().
- The adodb-perf.inc.php CreateLogTable() code now works for user-defined table names.
- Error in ibase_blob_open() fixed. See http://phplens.com/lens/lensforum/msgs.php?id=14997
## 4.80 - 8 Mar 2006
- Added activerecord support.
- Added mysql `$conn->compat323 = true` if you want MySQL 3.23 compat enabled. Fixes GetOne() Select-Limit problems.
- Added adodb-xmlschema03.inc.php to support XML Schema version 3 and updated adodb-datadict.htm docs.
- Better memory management in Execute. Thx Mike Fedyk.
## 4.72 - 21 Feb 2006
- Added 'new' DSN parameter for NConnect().
- Pager now sanitizes $PHP_SELF to protect against XSS. Thx to James Bercegay and others.
- ADOConnection::MetaType changed to setup $rs->connection correctly.
- New native DB2 driver contributed by Larry Menard, Dan Scott, Andy Staudacher, Bharat Mediratta.
- The mssql CreateSequence() did not BEGIN TRANSACTION correctly. Fixed. Thx Sean Lee.
- The _adodb_countrecs() function in adodb-lib.inc.php has been revised to handle more ORDER BY variations.
## 4.71 - 24 Jan 2006
- Fixes postgresql security issue related to binary strings. Thx to Andy Staudacher.
- Several DSN bugs found:
1. Fix bugs in DSN connections introduced in 4.70 when underscores are found in the DSN.
2. DSN with _ did not work properly in PHP5 (fine in PHP4). Fixed.
3. Added support for PDO DSN connections in NewADOConnection(), and database parameter in PDO::Connect().
- The oci8 datetime flag not correctly implemented in ADORecordSet_array. Fixed.
- Added BlobDelete() to postgres, as a counterpoint to UpdateBlobFile().
- Fixed GetInsertSQL() to support oci8po.
- Fixed qstr() issue with postgresql with \0 in strings.
- Fixed some datadict driver loading issues in _adodb_getdriver().
- Added register shutdown function session_write_close in adodb-session.inc.php for PHP 5 compat. See http://phplens.com/lens/lensforum/msgs.php?id=14200.
## 4.70 - 6 Jan 2006
- Many fixes from Danila Ulyanov to ibase, oci8, postgres, mssql, odbc_oracle, odbtp, etc drivers.
- Changed usage of binary hint in adodb-session.inc.php for mysql. See http://phplens.com/lens/lensforum/msgs.php?id=14160
- Fixed invalid variable reference problem in undomq(), adodb-perf.inc.php.
- Fixed http://phplens.com/lens/lensforum/msgs.php?id=14254 in adodb-perf.inc.php, `_DBParameter()` settings of fetchmode was wrong.
- Fixed security issues in server.php and tmssql.php discussed by Andreas Sandblad in a Secunia security advisory. Added `$ACCEPTIP = 127.0.0.1` and changed suggested root password to something more secure.
- Changed pager to close recordset after RenderLayout().
## 4.68 - 25 Nov 2005
- PHP 5 compat for mysqli. MetaForeignKeys repeated twice and MYSQLI_BINARY_FLAG missing.
- PHP 5.1 support for postgresql bind parameters using ? did not work if >= 10 parameters. Fixed. Thx to Stanislav Shramko.
- Lots of PDO improvements.
- Spelling error fixed in mysql MetaForeignKeys, $associative parameter.
## 4.67 - 16 Nov 2005
- Postgresql not_null flag not set to false correctly. Thx Cristian MARIN.
- We now check in Replace() if key is in fieldArray. Thx Sébastien Vanvelthem.
- `_file_get_contents()` function was missing in xmlschema. fixed.
- Added week in year support to SQLDate(), using 'W' flag. Thx Spider.
- In sqlite metacolumns was repeated twice, causing PHP 5 problems. Fixed.
- Made debug output XHTML compliant.
## 4.66 - 28 Sept 2005
- ExecuteCursor() in oci8 did not clean up properly on failure. Fixed.
- Updated xmlschema.dtd, by "Alec Smecher" asmecher#smecher.bc.ca
- Hardened SelectLimit, typecasting nrows and offset to integer.
- Fixed misc bugs in AutoExecute() and GetInsertSQL().
- Added $conn->database as the property holding the database name. The older $conn->databaseName is retained for backward compat.
- Changed _adodb_backtrace() compat check to use function_exists().
- Bug in postgresql MetaIndexes fixed. Thx Kevin Jamieson.
- Improved OffsetDate for MySQL, reducing rounding error.
- Metacolumns added to sqlite. Thx Mark Newnham.
- PHP 4.4 compat fixes for GetAssoc().
- Added postgresql bind support for php 5.1. Thx Cristiano da Cunha Duarte
- OffsetDate() fixes for postgresql, typecasting strings to date or timestamp.
- DBTimeStamp formats for mssql, odbc_mssql and postgresql made to conform with other db's.
- Changed PDO constants from PDO_ to PDO:: to support latest spec.
## 4.65 - 22 July 2005
- Reverted 'X' in mssql datadict to 'TEXT' to be compat with mssql driver. However now you can set $datadict->typeX = 'varchar(4000)' or 'TEXT' or 'CLOB' for mssql and oci8 drivers.
- Added charset support when using DSN for Oracle.
- _adodb_getmenu did not use fieldcount() to get number of fields. Fixed.
- MetaForeignKeys() for mysql/mysqli contributed by Juan Carlos Gonzalez.
- MetaDatabases() now correctly returns an array for mysqli driver. Thx Cristian MARIN.
- CompleteTrans(false) did not return false. Fixed. Thx to JMF.
- AutoExecute() did not work with Oracle. Fixed. Thx José Moreira.
- MetaType() added to connection object.
- More PHP 4.4 reference return fixes. Thx Ryan C Bonham and others.
## 4.64 - 20 June 2005
- In datadict, if the default field value is set to '', then it is not applied when the field is created. Fixed by Eugenio.
- MetaPrimaryKeys for postgres did not work because of true/false change in 4.63. Fixed.
- Tested ocifetchstatement in oci8. Rejected at the end.
- Added port to dsn handling. Supported in postgres, mysql, mysqli,ldap.
- Added 'w' and 'l' to mysqli SQLDate().
- Fixed error handling in ldap _connect() to be more consistent. Also added ErrorMsg() handling to ldap.
- Added support for union in _adodb_getcount, adodb-lib.inc.php for postgres and oci8.
- rs2html() did not work with null dates properly.
- PHP 4.4 reference return fixes.
## 4.63 - 18 May 2005
- Added $nrows<0 check to mysqli's SelectLimit().
- Added OptimizeTable() and OptimizeTables() in adodb-perf.inc.php. By Markus Staab.
- PostgreSQL inconsistencies fixed. true and false set to TRUE and FALSE, and boolean type in datadict-postgres.inc.php set to 'L' => 'BOOLEAN'. Thx Kevin Jamieson.
- New adodb_session_create_table() function in adodb-session.inc.php. By Markus Staab.
- Added null check to UserTimeStamp().
- Fixed typo in mysqlt driver in adorecordset. Thx to Andy Staudacher.
- GenID() had a bug in the raiseErrorFn handling. Fixed. Thx Marcos Pont.
- Datadict name quoting now handles ( ) in index fields correctly - they aren't part of the index field.
- Performance monitoring:
1. oci8 Ixora checks moved down;
2. expensive sql changed so that only those sql with count(*)>1 are shown;
3. changed sql1 field to a length+crc32 checksum - this breaks backward compat.
- We remap firebird15 to firebird in data dictionary.
## 4.62 - 2 Apr 2005
- Added 'w' (dow as 0-6 or 1-7) and 'l' (dow as string) for SQLDate for oci8, postgres and mysql.
- Rolled back MetaType() changes for mysqli done in prev version.
- Datadict change by chris, cblin#tennaxia.com data mappings from:
```
oci8: X->varchar(4000) XL->CLOB
mssql: X->XL->TEXT
mysql: X->XL->LONGTEXT
fbird: X->XL->varchar(4000)
```
to:
```
oci8: X->varchar(4000) XL->CLOB
mssql: X->VARCHAR(4000) XL->TEXT
mysql: X->TEXT XL->LONGTEXT
fbird: X->VARCHAR(4000) XL->VARCHAR(32000)
```
- Added $connection->disableBlobs to postgresql to improve performance when no bytea is used (2-5% improvement).
- Removed all HTTP_* vars.
- Added $rs->tableName to be set before calling AutoExecute().
- Alex Rootoff rootoff#pisem.net contributed ukrainian language file.
- Added new mysql_option() support using $conn->optionFlags array.
- Added support for ldap_set_option() using the $LDAP_CONNECT_OPTIONS global variable. Contributed by Josh Eldridge.
- Added LDAP_* constant definitions to ldap.
- Added support for boolean bind variables. We use $conn->false and $conn->true to hold values to set false/true to.
- We now do not close the session connection in adodb-session.inc.php as other objects could be using this connection.
- We now strip off `\0` at end of Ixora SQL strings in $perf->tohtml() for oci8.
## 4.61 - 23 Feb 2005
- MySQLi added support for mysqli_connect_errno() and mysqli_connect_error().
- Massive improvements to alpha PDO driver.
- Quote string bind parameters logged by performance monitor for easy type checking. Thx Jason Judge.
- Added support for $role when connecting with Interbase/firebird.
- Added support for enum recognition in MetaColumns() mysql and mysqli. Thx Amedeo Petrella.
- The sybase_ase driver contributed by Interakt Online. Thx Cristian Marin cristic#interaktonline.com.
- Removed not_null, has_default, and default_value from ADOFieldObject.
- Sessions code, fixed quoting of keys when handling LOBs in session write() function.
- Sessions code, added adodb_session_regenerate_id(), to reduce risk of session hijacking by changing session cookie dynamically. Thx Joe Li.
- Perf monitor, polling for CPU did not work for PHP 4.3.10 and 5.0.0-5.0.3 due to PHP bugs, so we special case these versions.
- Postgresql, UpdateBlob() added code to handle type==CLOB.
## 4.60 - 24 Jan 2005
- Implemented PEAR DB's autoExecute(). Simplified design because I don't like using constants when strings work fine.
- _rs2serialize will now update $rs->sql and $rs->oldProvider.
- Added autoExecute().
- Added support for postgres8 driver. Currently just remapped to postgres7 driver.
- Changed oci8 _query(), so that OCIBindByName() sets the length to -1 if element size is > 4000. This provides better support for LONGs.
- Added SetDateLocale() support for netherlands (Nl).
- Spelling error in pivot code ($iff should be $iif).
- mysql insert_id() did not work with mysql 3.x. Fixed.
- `\r\n` not converted to spaces correctly in exporting data. Fixed.
- _nconnect() in mysqli did not return value correctly. Fixed.
- Arne Eckmann contributed danish language file.
- Added clone() support to FetchObject() for PHP5.
- Removed SQL_CUR_USE_ODBC from odbc_mssql.
## 4.55 - 5 Jan 2005
- Found bug in Execute() with bind params for db's that do not support binding natively.
- DropSequence() now correctly uses default parameter.
- Now Execute() ignores locale for floats, so 1.23 is NEVER converted to 1,23.
- SetFetchMode() not properly saved in adodb-perf, suspicious sql and expensive sql. Fixed.
- Added INET to postgresql metatypes. Thx motzel.
- Allow oracle hints to work when counting with _adodb_getcount in adodb-lib.inc.php. Thx Chris Wrye.
- Changed mysql insert_id() to use SELECT LAST_INSERT_ID().
- If alter col in datadict does not modify col type/size of actual col, then it is removed from alter col code. By Mark Newham. Not perfect as MetaType() !== ActualType().
- Added handling of view fields in metacolumns() for postgresql. Thx Renato De Giovanni.
- Added to informix MetaPrimaryKeys and MetaColumns fixes for null bit. Thx to Cecilio Albero.
- Removed obsolete connection_timeout() from perf code.
- Added support for arrayClass in adodb-csv.inc.php.
- RSFilter now accepts methods of the form $array($obj, 'methodname'). Thx to blake#near-time.com.
- Changed CacheFlush to `$cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/';`
- For better cursor concurrency, added code to free ref cursors in oci8 when $rs->Close() is called. Note that CLose() is called internally by the Get* functions too.
- Added IIF support for access when pivoting. Thx Volodia Krupach.
- Added mssql datadict support for timestamp. Thx Alexios.
- Informix pager fix. By Mario Ramirez.
- ADODB_TABLE_REGEX now includes ':'. By Mario Ramirez.
- Mark Newnham contributed MetaIndexes for oci8 and db2.
## 4.54 - 5 Nov 2004
- Now you can set $db->charSet = ?? before doing a Connect() in oci8.
- Added adodbFetchMode to sqlite.
- Perf code, added a string typecast to substr in adodb_log_sql().
- Postgres: Changed BlobDecode() to use po_loread, added new $maxblobsize parameter, and now it returns the blob instead of sending it to stdout - make sure to mention that as a compat warning. Also added $db->IsOID($oid) function; uses a heuristic, not guaranteed to work 100%.
- Contributed arabic language file by "El-Shamaa, Khaled" k.el-shamaa#cgiar.org
- PHP5 exceptions did not handle @ protocol properly. Fixed.
- Added ifnull handling for postgresql (using coalesce).
- Added metatables() support for Postgresql 8.0 (no longer uses pg_% dictionary tables).
- Improved Sybase ErrorMsg() function. By Gaetano Giunta.
- Improved oci8 SelectLimit() to use Prepare(). By Cristiano Duarte.
- Type-cast $row parameter in ifx_fetch_row() to int. Thx stefan bodgan.
- Ralf becker contributed improvements in postgresql, sapdb, mysql data dictionary handling:
- MySql and Postgres MetaType was reporting every int column which was part of a primary key and unique as serial
- Postgres was not reporting the scale of decimal types
- MaxDB was padding the defaults of none-string types with spaces
- MySql now correctly converts enum columns to varchar
- Ralf also changed Postgresql datadict:
- you cant add NOT NULL columns in postgres in one go, they need to be added as NULL and then altered to NOT NULL
- AlterColumnSQL could not change a varchar column with numbers into an integer column, postgres need an explicit conversation
- a re-created sequence was not set to the correct value, if the name was the old name (no implicit sequence), now always the new name of the implicit sequence is used
- Sergio Strampelli added extra $intoken check to Lens_ParseArgs() in datadict code.
## 4.53 - 28 Sept 2004
- FetchMode cached in recordset is sometimes mapped to native db fetchMode. Normally this does not matter, but when using cached recordsets, we need to switch back to using adodb fetchmode. So we cache this in $rs->adodbFetchMode if it differs from the db's fetchMode.
- For informix we now set canSeek = false driver because stefan bodgan tells me that seeking doesn't work.
- SetDateLocale() never worked till now ;-) Thx david#tomato.it
- Set $_bindInputArray = true in sapdb driver. Required for clob support.
- Fixed some PEAR::DB emulation issues with isError() and isWarning. Thx to Gert-Rainer Bitterlich.
- Empty() used in getupdatesql without strlen() check. Fixed.
- Added unsigned detection to mysql and mysqli drivers. Thx to dan cech.
- Added hungarian language file. Thx to Halászvári Gábor.
- Improved fieldname-type formatting of datadict SQL generated (adding $widespacing parameter to _GenField).
- Datadict oci8 DROP CONSTRAINTS misspelt. Fixed. Thx Mark Newnham.
- Changed odbtp to dynamically change databaseType based on connection, eg. from 'odbtp' to 'odbtp_mssql' when connecting to mssql database.
- In datadict, MySQL I4 was wrongly mapped to MEDIUMINT, which is actually I3. Fixed.
- Fixed mysqli MetaType() recognition. Mysqli returns numeric types unlike mysql extension. Thx Francesco Riosa.
- VFP odbc driver curmode set wrongly, causing problems with memo fields. Fixed.
- Odbc driver did not recognize odbc version 2 driver date types properly. Fixed. Thx Bostjan.
- ChangeTableSQL() fixes to datadict-db2.inc.php by Mark Newnham.
- Perf monitoring with odbc improved. Now we try in perf code to manually set the sysTimeStamp using date() if sysTimeStamp is empty.
- All ADO errors are thrown as exceptions in PHP5. So we added exception handling to ado in PHP5 by creating new adodb-ado5.inc.php driver.
- Added IsConnected(). Returns true if connection object connected. By Luca.Gioppo.
- "Ralf Becker" RalfBecker#digitalROCK.de contributed new sapdb data-dictionary driver and a large patch that implements field and table renaming for oracle, mssql, postgresql, mysql and sapdb. See the new RenameTableSQL() and RenameColumnSQL() functions.
- We now check ExecuteCursor to see if PrepareSP was initially called.
- Changed oci8 datadict to use MODIFY for $dd->alterCol. Thx Mark Newnham.
## 4.52 - 10 Aug 2004
- Bug found in Replace() when performance logging enabled, introduced in ADOdb 4.50. Fixed.
- Replace() checks update stmt. If update stmt fails, we now return immediately. Thx to alex.
- Added support for $ADODB_FORCE_TYPE in GetUpdateSQL/GetInsertSQL. Thx to niko.
- Added ADODB_ASSOC_CASE support to postgres/postgres7 driver.
- Support for DECLARE stmt in oci8. Thx Lochbrunner.
## 4.51 - 29 July 2004
- Added adodb-xmlschema 1.0.2. Thx dan and richard.
- Added new adorecordset_ext_* classes. If ADOdb extension installed for mysql, mysqlt and oci8 (but not oci8po), we use the superfast ADOdb extension code for movenext.
- Added schema support to mssql and odbc_mssql MetaPrimaryKeys().
- Patched MSSQL driver to support PHP NULL and Boolean values while binding the input array parameters in the _query() function. By Stephen Farmer.
- Added support for clob's for mssql, UpdateBlob(). Thx to gfran#directa.com.br
- Added normalize support for postgresql (true=lowercase table name, or false=case-sensitive table names) to MetaColumns($table, $normalize=true).
- PHP5 variant dates in ADO not working. Fixed in adodb-ado.inc.php.
- Constant ADODB_FORCE_NULLS was not working properly for many releases (for GetUpdateSQL). Fixed. Also GetUpdateSQL strips off ORDER BY now - thx Elieser Leão.
- Perf Monitor for oci8 now dynamically highlights optimizer_* params if too high/low.
- Added dsn support to NewADOConnection/ADONewConnection.
- Fixed out of page bounds bug in _adodb_pageexecute_all_rows() Thx to "Sergio Strampelli" sergio#rir.it
- Speedup of movenext for mysql and oci8 drivers.
- Moved debugging code _adodb_debug_execute() to adodb-lib.inc.php.
- Fixed postgresql bytea detection bug. See http://phplens.com/lens/lensforum/msgs.php?id=9849.
- Fixed ibase datetimestamp typo in PHP5. Thx stefan.
- Removed whitespace at end of odbtp drivers.
- Added db2 metaprimarykeys fix.
- Optimizations to MoveNext() for mysql and oci8. Misc speedups to Get* functions.
## 4.50 - 6 July 2004
- Bumped it to 4.50 to avoid confusion with PHP 4.3.x series.
- Added db2 metatables and metacolumns extensions.
- Added alpha PDO driver. Very buggy, only works with odbc.
- Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and _fetch().
- PageExecute does not work properly with php5 (return val not a variable). Reported Dmytro Sychevsky sych#php.com.ua. Fixed.
- MetaTables() for mysql, $showschema parameter was not backward compatible with older versions of adodb. Fixed.
- Changed mysql GetOne() to work with mysql 3.23 when using with non-select stmts (e.g. SHOW TABLES).
- Changed TRIG_ prefix to a variable in datadict-oci8.inc.php. Thx to Luca.Gioppo#csi.it.
- New to adodb-time code. We allow you to define your own daylights savings function, adodb_daylight_sv for pre-1970 dates. If the function is defined (somewhere in an include), then you can correct for daylights savings. See http://phplens.com/phpeverywhere/node/view/16#daylightsavings for more info.
- New sqlitepo driver. This is because assoc mode does not work like other drivers in sqlite. Namely, when selecting (joining) multiple tables, in assoc mode the table names are included in the assoc keys in the "sqlite" driver. In "sqlitepo" driver, the table names are stripped from the returned column names. When this results in a conflict, the first field get preference. Contributed by Herman Kuiper herman#ozuzo.net
- Added $forcenull parameter to GetInsertSQL/GetUpdateSQL. Idea by Marco Aurelio Silva.
- More XHTML changes for GetMenu. By Jeremy Evans.
- Fixes some ibase date issues. Thx to stefan bogdan.
- Improvements to mysqli driver to support $ADODB_COUNTRECS.
- Fixed adodb-csvlib.inc.php problem when reading stream from socket. We need to poll stream continiously.
## 4.23 - 16 June 2004
- New interbase/firebird fixes thx to Lester Caine. Driver fixes a problem with getting field names in the result array, and corrects a couple of data conversions. Also we default to dialect3 for firebird. Also ibase sysDate property was wrong. Changed to cast as timestamp.
- The datadict driver is set up to give quoted tables and fields as this was the only way round reserved words being used as field names in TikiWiki. TikiPro is tidying that up, and I hope to be able to produce a build of THAT which uses what I consider proper UPPERCASE field and table names. The conversion of TikiWiki to ADOdb helped in that, but until the database is completely tidied up in TikiPro ...
- Modified _gencachename() to include fetchmode in name hash. This means you should clear your cache directory after installing this release as the cache name algorithm has changed.
- Now Cache* functions work in safe mode, because we do not create sub-directories in the $ADODB_CACHE_DIR in safe mode. In non-safe mode we still create sub-directories. Done by modifying _gencachename().
- Added $gmt parameter (true/false) to UserDate and UserTimeStamp in connection class, to force conversion of input (in local time) to be converted to UTC/GMT.
- Mssql datadict did not support INT types properly (no size param allowed). Added _GetSize() to datadict-mssql.inc.php.
- For borland_ibase, BeginTrans(), changed:
```
$this->_transactionID = $this->_connectionID;
```
to
```
$this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);
```
- Fixed typo in mysqi_field_seek(). Thx to Sh4dow (sh4dow#php.pl).
- LogSQL did not work with Firebird/Interbase. Fixed.
- Postgres: made errorno() handling more consistent. Thx to Michael Jahn, Michael.Jahn#mailbox.tu-dresden.de.
- Added informix patch to better support metatables, metacolumns by "Cecilio Albero" c-albero#eos-i.com
- Cyril Malevanov contributed patch to oci8 to support passing of LOB parameters:
```
$text = 'test test test';
$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
$stmt = $conn -> PrepareSP($sql);
$conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB);
$rs = '';
$conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
$conn -> Execute($stmt);
echo "return = ".$rs."<br>";</pre>
```
As he says, the LOBs limitations are:
- use OCINewDescriptor before binding
- if Param is IN, uses save() before each execute. This is done automatically for you.
- if Param is OUT, uses load() after each execute. This is done automatically for you.
- when we bind $var as LOB, we create new descriptor and return it as a Bind Result, so if we want to use OUT parameters, we have to store somewhere &$var to load() data from LOB to it.
- IN OUT params are not working now (should not be a big problem to fix it)
- now mass binding not working too (I've wrote about it before)</pre>
- Simplified Connect() and PConnect() error handling.
- When extension not loaded, Connect() and PConnect() will return null. On connect error, the fns will return false.
- CacheGetArray() added to code.
- Added Init() to adorecordset_empty().
- Changed postgres64 driver, MetaColumns() to not strip off quotes in default value if :: detected (type-casting of default).
- Added test: if (!defined('ADODB_DIR')) die(). Useful to prevent hackers from detecting file paths.
- Changed metaTablesSQL to ignore Postgres 7.4 information schemas (sql_*).
- New polish language file by Grzegorz Pacan
- Added support for UNION in _adodb_getcount().
- Added security check for ADODB_DIR to limit path disclosure issues. Requested by postnuke team.
- Added better error message support to oracle driver. Thx to Gaetano Giunta.
- Added showSchema support to mysql.
- Bind in oci8 did not handle $name=false properly. Fixed.
- If extension not loaded, Connect(), PConnect(), NConnect() will return null.
## 4.22 - 15 Apr 2004
- Moved docs to own adodb/docs folder.
- Fixed session bug when quoting compressed/encrypted data in Replace().
- Netezza Driver and LDAP drivers contributed by Josh Eldridge.
- GetMenu now uses rtrim() on values instead of trim().
- Changed MetaColumnNames to return an associative array, keys being the field names in uppercase.
- Suggested fix to adodb-ado.inc.php affected_rows to support PHP5 variants. Thx to Alexios Fakos.
- Contributed bulgarian language file by Valentin Sheiretsky valio#valio.eu.org.
- Contributed romanian language file by stefan bogdan.
- GetInsertSQL now checks for table name (string) in $rs, and will create a recordset for that table automatically. Contributed by Walt Boring. Also added OCI_B_BLOB in bind on Walt's request - hope it doesn't break anything :-)
- Some minor postgres speedups in `_initrs()`.
- ChangeTableSQL checks now if MetaColumns returns empty. Thx Jason Judge.
- Added ADOConnection::Time(), returns current database time in unix timestamp format, or false.
## 4.21 - 20 Mar 2004
- We no longer in SelectLimit for VFP driver add SELECT TOP X unless an ORDER BY exists.
- Pim Koeman contributed dutch language file adodb-nl.inc.php.
- Rick Hickerson added CLOB support to db2 datadict.
- Added odbtp driver. Thx to "stefan bogdan" sbogdan#rsb.ro.
- Changed PrepareSP() 2nd parameter, $cursor, to default to true (formerly false). Fixes oci8 backward compat problems with OUT params.
- Fixed month calculation error in adodb-time.inc.php. 2102-June-01 appeared as 2102-May-32.
- Updated PHP5 RC1 iterator support. API changed, hasMore() renamed to valid().
- Changed internal format of serialized cache recordsets. As we store a version number, this should be backward compatible.
- Error handling when driver file not found was flawed in ADOLoadCode(). Fixed.
## 4.20 - 27 Feb 2004
- Updated to AXMLS 1.01.
- MetaForeignKeys for postgres7 modified by Edward Jaramilla, works on pg 7.4.
- Now numbers accepts function calls or sequences for GetInsertSQL/GetUpdateSQL numeric fields.
- Changed quotes of 'delete from $perf_table' to "". Thx Kehui (webmaster#kehui.net)
- Added ServerInfo() for ifx, and putenv trim fix. Thx Fernando Ortiz.
- Added addq(), which is analogous to addslashes().
- Tested with php5b4. Fix some php5 compat problems with exceptions and sybase.
- Carl-Christian Salvesen added patch to mssql _query to support binds greater than 4000 chars.
- Mike suggested patch to PHP5 exception handler. $errno must be numeric.
- Added double quotes (") to ADODB_TABLE_REGEX.
- For oci8, Prepare(...,$cursor), $cursor's meaning was accidentally inverted in 4.11. This causes problems with ExecuteCursor() too, which calls Prepare() internally. Thx to William Lovaton.
- Now dateHasTime property in connection object renamed to datetime for consistency. This could break bc.
- Csongor Halmai reports that db2 SelectLimit with input array is not working. Fixed..
## 4.11 - 27 Jan 2004
- Csongor Halmai reports db2 binding not working. Reverted back to emulated binding.
- Dan Cech modifies datadict code. Adds support for DropIndex. Minor cleanups.
- Table misspelt in perf-oci8.inc.php. Changed v$conn_cache_advice to v$db_cache_advice. Reported by Steve W.
- UserTimeStamp and DBTimeStamp did not handle YYYYMMDDHHMMSS format properly. Reported by Mike Muir. Fixed.
- Changed oci8 Prepare(). Does not auto-allocate OCINewCursor automatically, unless 2nd param is set to true. This will break backward compat, if Prepare/Execute is used instead of ExecuteCursor. Reported by Chris Jones.
- Added InParameter() and OutParameter(). Wrapper functions to Parameter(), but nicer because they are self-documenting.
- Added 'R' handling in ActualType() to datadict-mysql.inc.php
- Added ADOConnection::SerializableRS($rs). Returns a recordset that can be serialized in a session.
- Added "Run SQL" to performance UI().
- Misc spelling corrections in adodb-mysqli.inc.php, adodb-oci8.inc.php and datadict-oci8.inc.php, from Heinz Hombergs.
- MetaIndexes() for ibase contributed by Heinz Hombergs.
## 4.10 - 12 Jan 2004
- Dan Cech contributed extensive changes to data dictionary to support name quoting (with `\``), and drop table/index.
- Informix added cursorType property. Default remains IFX_SCROLL, but you can change to 0 (non-scrollable cursor) for performance.
- Added ADODB_View_PrimaryKeys() for returning view primary keys to MetaPrimaryKeys().
- Simplified chinese file, adodb-cn.inc.php from cysoft.
- Added check for ctype_alnum in adodb-datadict.inc.php. Thx to Jason Judge.
- Added connection parameter to ibase Prepare(). Fix by Daniel Hassan.
- Added nameQuote for quoting identifiers and names to connection obj. Requested by Jason Judge. Also the data dictionary parser now detects `field name` and generates column names with spaces correctly.
- BOOL type not recognised correctly as L. Fixed.
- Fixed paths in ADODB_DIR for session files, and back-ported it to 4.05 (15 Dec 2003)
- Added Schema to postgresql MetaTables. Thx to col#gear.hu
- Empty postgresql recordsets that had blob fields did not set EOF properly. Fixed.
- CacheSelectLimit internal parameters to SelectLimit were wrong. Thx to Nio.
- Modified adodb_pr() and adodb_backtrace() to support command-line usage (eg. no html).
- Fixed some fr and it lang errors. Thx to Gaetano G.
- Added contrib directory, with adodb rs to xmlrpc convertor by Gaetano G.
- Fixed array recordset bugs when `_skiprow1` is true. Thx to Gaetano G.
- Fixed pivot table code when count is false.
## 4.05 - 13 Dec 2003
- Added MetaIndexes to data-dict code - thx to Dan Cech.
- Rewritten session code by Ross Smith. Moved code to adodb/session directory.
- Added function exists check on connecting to most drivers, so we don't crash with the unknown function error.
- Smart Transactions failed with GenID() when it no seq table has been created because the sql statement fails. Fix by Mark Newnham.
- Added $db->length, which holds name of function that returns strlen.
- Fixed error handling for bad driver in ADONewConnection - passed too few params to error-handler.
- Datadict did not handle types like 16.0 properly in _GetSize. Fixed.
- Oci8 driver SelectLimit() bug &= instead of =& used. Thx to Swen Thümmler.
- Jesse Mullan suggested not flushing outp when output buffering enabled. Due to Apache 2.0 bug. Added.
- MetaTables/MetaColumns return ref bug with PHP5 fixed in adodb-datadict.inc.php.
- New mysqli driver contributed by Arjen de Rijke. Based on adodb 3.40 driver. Then jlim added BeginTrans, CommitTrans, RollbackTrans, IfNull, SQLDate. Also fixed return ref bug.
- $ADODB_FLUSH added, if true then force flush in debugging outp. Default is false. In earlier versions, outp defaulted to flush, which is not compat with apache 2.0.
- Mysql driver's GenID() function did not work when when sql logging is on. Fixed.
- $ADODB_SESSION_TBL not declared as global var. Not available if adodb-session.inc.php included in function. Fixed.
- The input array not passed to Execute() in _adodb_getcount(). Fixed.
## 4.04 - 13 Nov 2003
- Switched back to foreach - faster than list-each.
- Fixed bug in ado driver - wiping out $this->fields with date fields.
- Performance Monitor, View SQL, Explain Plan did not work if strlen($SQL)>max($_GET length). Fixed.
- Performance monitor, oci8 driver added memory sort ratio.
- Added random property, returns SQL to generate a floating point number between 0 and 1;
## 4.03 - 6 Nov 2003
- The path to adodb-php4.inc.php and adodb-iterators.inc.php was not setup properly.
- Patched SQLDate in interbase to support hours/mins/secs. Thx to ari kuorikoski.
- Force autorollback for pgsql persistent connections - apparently pgsql did not autorollback properly before 4.3.4. See http://bugs.php.net/bug.php?id=25404
## 4.02 - 5 Nov 2003
- Some errors in adodb_error_pg() fixed. Thx to Styve.
- Spurious Insert_ID() error was generated by LogSQL(). Fixed.
- Insert_ID was interfering with Affected_Rows() and Replace() when LogSQL() enabled. Fixed.
- More foreach loops optimized with list/each.
- Null dates not handled properly in ADO driver (it becomes 31 Dec 1969!).
- Heinz Hombergs contributed patches for mysql MetaColumns - adding scale, made interbase MetaColumns work with firebird/interbase, and added lang/adodb-de.inc.php.
- Added INFORMIXSERVER environment variable.
- Added $ADODB_ANSI_PADDING_OFF for interbase/firebird.
- PHP 5 beta 2 compat check. Foreach (Iterator) support. Exceptions support.
## 4.01 - 23 Oct 2003
- Fixed bug in rs2html(), tohtml.inc.php, that generated blank table cells.
- Fixed insert_id() incorrectly generated when logsql() enabled.
- Modified PostgreSQL _fixblobs to use list/each instead of foreach.
- Informix ErrorNo() implemented correctly.
- Modified several places to use list/each, including GetRowAssoc().
- Added UserTimeStamp() to connection class.
- Added $ADODB_ANSI_PADDING_OFF for oci8po.
## 4.00 - 20 Oct 2003
- Upgraded adodb-xmlschema to 1 Oct 2003 snapshot.
- Fix to rs2html warning message. Thx to Filo.
- Fix for odbc_mssql/mssql SQLDate(), hours was wrong.
- Added MetaColumns and MetaPrimaryKeys for sybase. Thx to Chris Phillipson.
- Added autoquoting to datadict for MySQL and PostgreSQL. Suggestion by Karsten Dambekalns

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
@@ -9,16 +11,16 @@
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Microsoft Access data driver. Requires ODBC. Works only on MS Windows. Microsoft Access data driver. Requires ODBC. Works only on MS Windows.
*/ */
if (!defined('_ADODB_ODBC_LAYER')) { if (!defined('_ADODB_ODBC_LAYER')) {
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
} }
if (!defined('_ADODB_ACCESS')) { if (!defined('_ADODB_ACCESS')) {
define('_ADODB_ACCESS',1); define('_ADODB_ACCESS',1);
class ADODB_access extends ADODB_odbc { class ADODB_access extends ADODB_odbc {
var $databaseType = 'access'; var $databaseType = 'access';
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $fmtDate = "#Y-m-d#"; var $fmtDate = "#Y-m-d#";
@@ -29,12 +31,12 @@ if (!defined('_ADODB_ACCESS')) {
var $hasTransactions = false; var $hasTransactions = false;
var $upperCase = 'ucase'; var $upperCase = 'ucase';
function ADODB_access() function __construct()
{ {
global $ADODB_EXTENSION; global $ADODB_EXTENSION;
$ADODB_EXTENSION = false; $ADODB_EXTENSION = false;
$this->ADODB_odbc(); parent::__construct();
} }
function Time() function Time()
@@ -48,7 +50,7 @@ if (!defined('_ADODB_ACCESS')) {
{ {
return " IIF(IsNull($field), $ifNull, $field) "; // if Access return " IIF(IsNull($field), $ifNull, $field) "; // if Access
} }
/* /*
function MetaTables() function MetaTables()
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -71,17 +73,16 @@ if (!defined('_ADODB_ACCESS')) {
} }
return $arr2; return $arr2;
}*/ }*/
} }
class ADORecordSet_access extends ADORecordSet_odbc { class ADORecordSet_access extends ADORecordSet_odbc {
var $databaseType = "access"; var $databaseType = "access";
function ADORecordSet_access($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbc($id,$mode); return parent::__construct($id,$mode);
} }
}// class }// class
} }
?>

View File

@@ -1,22 +1,24 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Microsoft ADO data driver. Requires ADO. Works only on MS Windows. Microsoft ADO data driver. Requires ADO. Works only on MS Windows.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
define("_ADODB_ADO_LAYER", 1 ); define("_ADODB_ADO_LAYER", 1 );
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADODB_ado extends ADOConnection { class ADODB_ado extends ADOConnection {
@@ -37,7 +39,7 @@ class ADODB_ado extends ADOConnection {
var $poorAffectedRows = true; var $poorAffectedRows = true;
var $charPage; var $charPage;
function ADODB_ado() function __construct()
{ {
$this->_affectedRows = new VARIANT; $this->_affectedRows = new VARIANT;
} }
@@ -105,7 +107,7 @@ class ADODB_ado extends ADOConnection {
return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
} }
/* /*
adSchemaCatalogs = 1, adSchemaCatalogs = 1,
adSchemaCharacterSets = 2, adSchemaCharacterSets = 2,
adSchemaCollations = 3, adSchemaCollations = 3,
@@ -145,9 +147,9 @@ class ADODB_ado extends ADOConnection {
adSchemaProperties = 37, adSchemaProperties = 37,
adSchemaMembers = 38 adSchemaMembers = 38
*/ */
function MetaTables() function MetaTables($ttype = false, $showSchema = false, $mask = false)
{ {
$arr= array(); $arr= array();
$dbc = $this->_connectionID; $dbc = $this->_connectionID;
@@ -329,7 +331,7 @@ class ADODB_ado extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_ado extends ADORecordSet { class ADORecordSet_ado extends ADORecordSet {
@@ -341,14 +343,14 @@ class ADORecordSet_ado extends ADORecordSet {
var $canSeek = true; var $canSeek = true;
var $hideErrors = true; var $hideErrors = true;
function ADORecordSet_ado($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE;
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
return $this->ADORecordSet($id,$mode); return parent::__construct($id,$mode);
} }
@@ -407,7 +409,7 @@ class ADORecordSet_ado extends ADORecordSet {
return true; return true;
} }
/* /*
OLEDB types OLEDB types
enum DBTYPEENUM enum DBTYPEENUM
@@ -488,7 +490,7 @@ class ADORecordSet_ado extends ADORecordSet {
adDBFileTime = 137, adDBFileTime = 137,
adPropVariant = 138, adPropVariant = 138,
adVarNumeric = 139 adVarNumeric = 139
*/ */
function MetaType($t,$len=-1,$fieldobj=false) function MetaType($t,$len=-1,$fieldobj=false)
{ {
if (is_object($t)) { if (is_object($t)) {
@@ -625,7 +627,7 @@ class ADORecordSet_ado extends ADORecordSet {
@$rs->MoveNext(); // @ needed for some versions of PHP! @$rs->MoveNext(); // @ needed for some versions of PHP!
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
return true; return true;
} }
@@ -656,5 +658,3 @@ class ADORecordSet_ado extends ADORecordSet {
} }
} }
?>

View File

@@ -1,22 +1,24 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Microsoft ADO data driver. Requires ADO. Works only on MS Windows. PHP5 compat version. Microsoft ADO data driver. Requires ADO. Works only on MS Windows. PHP5 compat version.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
define("_ADODB_ADO_LAYER", 1 ); define("_ADODB_ADO_LAYER", 1 );
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADODB_ado extends ADOConnection { class ADODB_ado extends ADOConnection {
@@ -37,7 +39,7 @@ class ADODB_ado extends ADOConnection {
var $poorAffectedRows = true; var $poorAffectedRows = true;
var $charPage; var $charPage;
function ADODB_ado() function __construct()
{ {
$this->_affectedRows = new VARIANT; $this->_affectedRows = new VARIANT;
} }
@@ -118,7 +120,7 @@ class ADODB_ado extends ADOConnection {
$dbc->CursorLocation = $this->_cursor_location; $dbc->CursorLocation = $this->_cursor_location;
return $dbc->State > 0; return $dbc->State > 0;
} catch (exception $e) { } catch (exception $e) {
if ($this->debug);echo "<pre>",$argHostname,"\n",$e,"</pre>\n"; if ($this->debug) echo "<pre>",$argHostname,"\n",$e,"</pre>\n";
} }
return false; return false;
@@ -130,7 +132,7 @@ class ADODB_ado extends ADOConnection {
return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
} }
/* /*
adSchemaCatalogs = 1, adSchemaCatalogs = 1,
adSchemaCharacterSets = 2, adSchemaCharacterSets = 2,
adSchemaCollations = 3, adSchemaCollations = 3,
@@ -170,9 +172,9 @@ class ADODB_ado extends ADOConnection {
adSchemaProperties = 37, adSchemaProperties = 37,
adSchemaMembers = 38 adSchemaMembers = 38
*/ */
function MetaTables() function MetaTables($ttype = false, $showSchema = false, $mask = false)
{ {
$arr= array(); $arr= array();
$dbc = $this->_connectionID; $dbc = $this->_connectionID;
@@ -363,7 +365,7 @@ class ADODB_ado extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_ado extends ADORecordSet { class ADORecordSet_ado extends ADORecordSet {
@@ -375,14 +377,14 @@ class ADORecordSet_ado extends ADORecordSet {
var $canSeek = true; var $canSeek = true;
var $hideErrors = true; var $hideErrors = true;
function ADORecordSet_ado($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE;
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
return $this->ADORecordSet($id,$mode); return parent::__construct($id,$mode);
} }
@@ -448,7 +450,7 @@ class ADORecordSet_ado extends ADORecordSet {
return true; return true;
} }
/* /*
OLEDB types OLEDB types
enum DBTYPEENUM enum DBTYPEENUM
@@ -529,7 +531,7 @@ class ADORecordSet_ado extends ADORecordSet {
adDBFileTime = 137, adDBFileTime = 137,
adPropVariant = 138, adPropVariant = 138,
adVarNumeric = 139 adVarNumeric = 139
*/ */
function MetaType($t,$len=-1,$fieldobj=false) function MetaType($t,$len=-1,$fieldobj=false)
{ {
if (is_object($t)) { if (is_object($t)) {
@@ -670,7 +672,7 @@ class ADORecordSet_ado extends ADORecordSet {
@$rs->MoveNext(); // @ needed for some versions of PHP! @$rs->MoveNext(); // @ needed for some versions of PHP!
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
return true; return true;
} }
@@ -704,5 +706,3 @@ class ADORecordSet_ado extends ADORecordSet {
} }
} }
?>

View File

@@ -1,15 +1,17 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
Released under both BSD license and Lesser GPL library license. @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
Whenever there is any discrepancy between the two licenses, @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
the BSD license will take precedence. See License.txt. Released under both BSD license and Lesser GPL library license.
Set tabs to 4 for best viewing. Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Microsoft Access ADO data driver. Requires ADO and ODBC. Works only on MS Windows. Microsoft Access ADO data driver. Requires ADO and ODBC. Works only on MS Windows.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -28,11 +30,6 @@ class ADODB_ado_access extends ADODB_ado {
var $sysTimeStamp = 'NOW'; var $sysTimeStamp = 'NOW';
var $upperCase = 'ucase'; var $upperCase = 'ucase';
function ADODB_ado_access()
{
$this->ADODB_ado();
}
/*function BeginTrans() { return false;} /*function BeginTrans() { return false;}
function CommitTrans() { return false;} function CommitTrans() { return false;}
@@ -46,9 +43,8 @@ class ADORecordSet_ado_access extends ADORecordSet_ado {
var $databaseType = "ado_access"; var $databaseType = "ado_access";
function ADORecordSet_ado_access($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_ado($id,$mode); return parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,10 +1,12 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
@@ -13,7 +15,7 @@
Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used. Warning: Some versions of PHP (esp PHP4) leak memory when ADO/COM is used.
Please check http://bugs.php.net/ for more info. Please check http://bugs.php.net/ for more info.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -39,11 +41,6 @@ class ADODB_ado_mssql extends ADODB_ado {
//var $_inTransaction = 1; // always open recordsets, so no transaction problems. //var $_inTransaction = 1; // always open recordsets, so no transaction problems.
function ADODB_ado_mssql()
{
$this->ADODB_ado();
}
function _insertid() function _insertid()
{ {
return $this->GetOne('select SCOPE_IDENTITY()'); return $this->GetOne('select SCOPE_IDENTITY()');
@@ -140,15 +137,14 @@ class ADODB_ado_mssql extends ADODB_ado {
//return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
} }
} // end class } // end class
class ADORecordSet_ado_mssql extends ADORecordSet_ado { class ADORecordSet_ado_mssql extends ADORecordSet_ado {
var $databaseType = 'ado_mssql'; var $databaseType = 'ado_mssql';
function ADORecordSet_ado_mssql($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_ado($id,$mode); return parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,6 +1,6 @@
<?php <?php
/* /*
(c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. (c) 2000-2014 John Lim (jlim#natsoft.com.my). All rights reserved.
Portions Copyright (c) 2007-2009, iAnywhere Solutions, Inc. Portions Copyright (c) 2007-2009, iAnywhere Solutions, Inc.
All rights reserved. All unpublished rights reserved. All rights reserved. All unpublished rights reserved.
@@ -8,14 +8,14 @@
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
NOTE: This driver requires the Advantage PHP client libraries, which NOTE: This driver requires the Advantage PHP client libraries, which
can be downloaded for free via: can be downloaded for free via:
http://devzone.advantagedatabase.com/dz/content.aspx?key=20 http://devzone.advantagedatabase.com/dz/content.aspx?key=20
DELPHI FOR PHP USERS: DELPHI FOR PHP USERS:
The following steps can be taken to utilize this driver from the The following steps can be taken to utilize this driver from the
CodeGear Delphi for PHP product: CodeGear Delphi for PHP product:
1 - See note above, download and install the Advantage PHP client. 1 - See note above, download and install the Advantage PHP client.
@@ -34,14 +34,14 @@
file and add ads to the list of strings returned when registering the file and add ads to the list of strings returned when registering the
Database object's DriverName property. Database object's DriverName property.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
define("_ADODB_ADS_LAYER", 2 ); define("_ADODB_ADS_LAYER", 2 );
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADODB_ads extends ADOConnection { class ADODB_ads extends ADOConnection {
@@ -66,7 +66,7 @@ class ADODB_ads extends ADOConnection {
var $uCaseTables = true; // for meta* functions, uppercase table names var $uCaseTables = true; // for meta* functions, uppercase table names
function ADODB_ads() function __construct()
{ {
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050; $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
@@ -136,7 +136,7 @@ class ADODB_ads extends ADOConnection {
// returns true or false // returns true or false
function CreateSequence( $seqname,$start=1) function CreateSequence($seqname = 'adodbseq', $start = 1)
{ {
$res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE"); $res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
if(!$res){ if(!$res){
@@ -149,7 +149,7 @@ class ADODB_ads extends ADOConnection {
} }
// returns true or false // returns true or false
function DropSequence($seqname) function DropSequence($seqname = 'adodbseq')
{ {
$res = $this->Execute("DROP TABLE $seqname"); $res = $this->Execute("DROP TABLE $seqname");
if(!$res){ if(!$res){
@@ -164,7 +164,7 @@ class ADODB_ads extends ADOConnection {
// returns the generated ID or false // returns the generated ID or false
// checks if the table already exists, else creates the table and inserts a record into the table // checks if the table already exists, else creates the table and inserts a record into the table
// and gets the ID number of the last inserted record. // and gets the ID number of the last inserted record.
function GenID($seqname,$start=1) function GenID($seqname = 'adodbseq', $start = 1)
{ {
$go = $this->Execute("select * from $seqname"); $go = $this->Execute("select * from $seqname");
if (!$go){ if (!$go){
@@ -254,7 +254,7 @@ class ADODB_ads extends ADOConnection {
// Returns tables,Views or both on succesfull execution. Returns // Returns tables,Views or both on succesfull execution. Returns
// tables by default on succesfull execustion. // tables by default on succesfull execustion.
function &MetaTables($ttype) function &MetaTables($ttype = false, $showSchema = false, $mask = false)
{ {
$recordSet1 = $this->Execute("select * from system.tables"); $recordSet1 = $this->Execute("select * from system.tables");
if(!$recordSet1){ if(!$recordSet1){
@@ -294,7 +294,7 @@ class ADODB_ads extends ADOConnection {
} }
function &MetaPrimaryKeys($table) function &MetaPrimaryKeys($table, $owner = false)
{ {
$recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'"); $recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'");
if(!$recordSet){ if(!$recordSet){
@@ -310,34 +310,34 @@ class ADODB_ads extends ADOConnection {
return $arr; return $arr;
} }
/* /*
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp
/ SQL data type codes / / SQL data type codes /
#define SQL_UNKNOWN_TYPE 0 #define SQL_UNKNOWN_TYPE 0
#define SQL_CHAR 1 #define SQL_CHAR 1
#define SQL_NUMERIC 2 #define SQL_NUMERIC 2
#define SQL_DECIMAL 3 #define SQL_DECIMAL 3
#define SQL_INTEGER 4 #define SQL_INTEGER 4
#define SQL_SMALLINT 5 #define SQL_SMALLINT 5
#define SQL_FLOAT 6 #define SQL_FLOAT 6
#define SQL_REAL 7 #define SQL_REAL 7
#define SQL_DOUBLE 8 #define SQL_DOUBLE 8
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
#define SQL_DATETIME 9 #define SQL_DATETIME 9
#endif #endif
#define SQL_VARCHAR 12 #define SQL_VARCHAR 12
/ One-parameter shortcuts for date/time data types / / One-parameter shortcuts for date/time data types /
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
#define SQL_TYPE_DATE 91 #define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92 #define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93 #define SQL_TYPE_TIMESTAMP 93
#define SQL_UNICODE (-95) #define SQL_UNICODE (-95)
#define SQL_UNICODE_VARCHAR (-96) #define SQL_UNICODE_VARCHAR (-96)
#define SQL_UNICODE_LONGVARCHAR (-97) #define SQL_UNICODE_LONGVARCHAR (-97)
*/ */
function ODBCTypes($t) function ODBCTypes($t)
{ {
switch ((integer)$t) { switch ((integer)$t) {
@@ -378,7 +378,7 @@ class ADODB_ads extends ADOConnection {
} }
} }
function &MetaColumns($table) function &MetaColumns($table, $normalize = true)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -486,7 +486,7 @@ class ADODB_ads extends ADOConnection {
} }
// Returns an array of columns names for a given table // Returns an array of columns names for a given table
function &MetaColumnNames($table) function &MetaColumnNames($table, $numIndexes = false, $useattnum = false)
{ {
$recordSet = $this->Execute("select name from system.columns where parent='$table'"); $recordSet = $this->Execute("select name from system.columns where parent='$table'");
if(!$recordSet){ if(!$recordSet){
@@ -644,7 +644,7 @@ class ADODB_ads extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_ads extends ADORecordSet { class ADORecordSet_ads extends ADORecordSet {
@@ -654,7 +654,7 @@ class ADORecordSet_ads extends ADORecordSet {
var $useFetchArray; var $useFetchArray;
var $_has_stupid_odbc_fetch_api_change; var $_has_stupid_odbc_fetch_api_change;
function ADORecordSet_ads($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -667,7 +667,7 @@ class ADORecordSet_ads extends ADORecordSet {
// the following is required for mysql odbc driver in 4.3.1 -- why? // the following is required for mysql odbc driver in 4.3.1 -- why?
$this->EOF = false; $this->EOF = false;
$this->_currentRow = -1; $this->_currentRow = -1;
//$this->ADORecordSet($id); //parent::__construct($id);
} }
@@ -731,7 +731,7 @@ class ADORecordSet_ads extends ADORecordSet {
$this->fetchMode = $savem; $this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields =& $this->GetRowAssoc();
} }
$results = array(); $results = array();
@@ -749,17 +749,7 @@ class ADORecordSet_ads extends ADORecordSet {
{ {
if ($this->_numOfRows != 0 && !$this->EOF) { if ($this->_numOfRows != 0 && !$this->EOF) {
$this->_currentRow++; $this->_currentRow++;
if( $this->_fetch() ) {
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @ads_fetch_into($this->_queryID,$this->fields);
else {
$row = 0;
$rez = @ads_fetch_into($this->_queryID,$row,$this->fields);
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true; return true;
} }
} }
@@ -770,7 +760,7 @@ class ADORecordSet_ads extends ADORecordSet {
function _fetch() function _fetch()
{ {
$this->fields = false;
if ($this->_has_stupid_odbc_fetch_api_change) if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @ads_fetch_into($this->_queryID,$this->fields); $rez = @ads_fetch_into($this->_queryID,$this->fields);
else { else {
@@ -779,11 +769,10 @@ class ADORecordSet_ads extends ADORecordSet {
} }
if ($rez) { if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields =& $this->GetRowAssoc();
} }
return true; return true;
} }
$this->fields = false;
return false; return false;
} }
@@ -793,4 +782,3 @@ class ADORecordSet_ads extends ADORecordSet {
} }
} }
?>

View File

@@ -1,16 +1,18 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Support Borland Interbase 6.5 and later Support Borland Interbase 6.5 and later
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -20,12 +22,6 @@ include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
class ADODB_borland_ibase extends ADODB_ibase { class ADODB_borland_ibase extends ADODB_ibase {
var $databaseType = "borland_ibase"; var $databaseType = "borland_ibase";
function ADODB_borland_ibase()
{
$this->ADODB_ibase();
}
function BeginTrans() function BeginTrans()
{ {
if ($this->transOff) return true; if ($this->transOff) return true;
@@ -84,9 +80,8 @@ class ADORecordSet_borland_ibase extends ADORecordSet_ibase {
var $databaseType = "borland_ibase"; var $databaseType = "borland_ibase";
function ADORecordSet_borland_ibase($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordSet_ibase($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -13,7 +15,7 @@
Limitation of url length. For IIS, see MaxClientRequestBuffer registry value. Limitation of url length. For IIS, see MaxClientRequestBuffer registry value.
http://support.microsoft.com/default.aspx?scid=kb;en-us;260694 http://support.microsoft.com/default.aspx?scid=kb;en-us;260694
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -21,9 +23,9 @@ if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_CSV_LAYER")) { if (! defined("_ADODB_CSV_LAYER")) {
define("_ADODB_CSV_LAYER", 1 ); define("_ADODB_CSV_LAYER", 1 );
include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
class ADODB_csv extends ADOConnection { class ADODB_csv extends ADOConnection {
var $databaseType = 'csv'; var $databaseType = 'csv';
var $databaseProvider = 'csv'; var $databaseProvider = 'csv';
var $hasInsertID = true; var $hasInsertID = true;
@@ -36,7 +38,7 @@ if (! defined("_ADODB_CSV_LAYER")) {
var $hasTransactions = false; var $hasTransactions = false;
var $_errorNo = false; var $_errorNo = false;
function ADODB_csv() function __construct()
{ {
} }
@@ -79,7 +81,7 @@ if (! defined("_ADODB_CSV_LAYER")) {
// parameters use PostgreSQL convention, not MySQL // parameters use PostgreSQL convention, not MySQL
function SelectLimit($sql,$nrows=-1,$offset=-1) function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -188,20 +190,18 @@ if (! defined("_ADODB_CSV_LAYER")) {
{ {
return true; return true;
} }
} // class } // class
class ADORecordset_csv extends ADORecordset { class ADORecordset_csv extends ADORecordset {
function ADORecordset_csv($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordset($id,$mode); parent::__construct($id,$mode);
} }
function _close() function _close()
{ {
return true; return true;
} }
} }
} // define } // define
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /**
V5.06 16 Oct 2008 (c) 2006 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension
for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or
@@ -13,15 +15,15 @@
I ripped out what I believed to be a lot of redundant or obsolete code, but there are I ripped out what I believed to be a lot of redundant or obsolete code, but there are
probably still some remnants of the ODBC support in this file; I'm relying on reviewers probably still some remnants of the ODBC support in this file; I'm relying on reviewers
of this code to point out any other things that can be removed. of this code to point out any other things that can be removed.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
define("_ADODB_DB2_LAYER", 2 ); define("_ADODB_DB2_LAYER", 2 );
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
@@ -61,7 +63,7 @@ class ADODB_db2 extends ADOConnection {
return ADOConnection::GetOne('VALUES IDENTITY_VAL_LOCAL()'); return ADOConnection::GetOne('VALUES IDENTITY_VAL_LOCAL()');
} }
function ADODB_db2() function __construct()
{ {
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050; $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
} }
@@ -134,7 +136,7 @@ class ADODB_db2 extends ADOConnection {
} }
// format and return date string in database timestamp format // format and return date string in database timestamp format
function DBTimeStamp($ts) function DBTimeStamp($ts, $isfld = false)
{ {
if (empty($ts) && $ts !== 0) return 'null'; if (empty($ts) && $ts !== 0) return 'null';
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
@@ -210,31 +212,19 @@ class ADODB_db2 extends ADOConnection {
function ServerInfo() function ServerInfo()
{ {
$row = $this->GetRow("SELECT service_level, fixpack_num FROM TABLE(sysproc.env_get_inst_info())
as INSTANCEINFO");
if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
$dsn = strtoupper($this->host);
$first = true;
$found = false;
if (!function_exists('db2_data_source')) return false; if ($row) {
$info['version'] = $row[0].':'.$row[1];
while(true) { $info['fixpack'] = $row[1];
$info['description'] = '';
$rez = @db2_data_source($this->_connectionID,
$first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
$first = false;
if (!is_array($rez)) break;
if (strtoupper($rez['server']) == $dsn) {
$found = true;
break;
}
}
if (!$found) return ADOConnection::ServerInfo();
if (!isset($rez['version'])) $rez['version'] = '';
return $rez;
} else { } else {
return ADOConnection::ServerInfo(); return ADOConnection::ServerInfo();
} }
return $info;
} }
function CreateSequence($seqname='adodbseq',$start=1) function CreateSequence($seqname='adodbseq',$start=1)
@@ -245,13 +235,13 @@ class ADODB_db2 extends ADOConnection {
return true; return true;
} }
function DropSequence($seqname) function DropSequence($seqname = 'adodbseq')
{ {
if (empty($this->_dropSeqSQL)) return false; if (empty($this->_dropSeqSQL)) return false;
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
} }
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false) function SelectLimit($sql, $nrows = -1, $offset = -1, $inputArr = false, $secs2cache = 0)
{ {
$nrows = (integer) $nrows; $nrows = (integer) $nrows;
if ($offset <= 0) { if ($offset <= 0) {
@@ -345,7 +335,7 @@ class ADODB_db2 extends ADOConnection {
return $ret; return $ret;
} }
function MetaPrimaryKeys($table) function MetaPrimaryKeys($table, $owner = false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -421,7 +411,7 @@ class ADODB_db2 extends ADOConnection {
} }
function MetaTables($ttype=false,$schema=false) function MetaTables($ttype = false, $schema = false, $mask = false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -458,34 +448,34 @@ class ADODB_db2 extends ADOConnection {
return $arr2; return $arr2;
} }
/* /*
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2datetime_data_type_changes.asp See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2datetime_data_type_changes.asp
/ SQL data type codes / / SQL data type codes /
#define SQL_UNKNOWN_TYPE 0 #define SQL_UNKNOWN_TYPE 0
#define SQL_CHAR 1 #define SQL_CHAR 1
#define SQL_NUMERIC 2 #define SQL_NUMERIC 2
#define SQL_DECIMAL 3 #define SQL_DECIMAL 3
#define SQL_INTEGER 4 #define SQL_INTEGER 4
#define SQL_SMALLINT 5 #define SQL_SMALLINT 5
#define SQL_FLOAT 6 #define SQL_FLOAT 6
#define SQL_REAL 7 #define SQL_REAL 7
#define SQL_DOUBLE 8 #define SQL_DOUBLE 8
#if (DB2VER >= 0x0300) #if (DB2VER >= 0x0300)
#define SQL_DATETIME 9 #define SQL_DATETIME 9
#endif #endif
#define SQL_VARCHAR 12 #define SQL_VARCHAR 12
/ One-parameter shortcuts for date/time data types / / One-parameter shortcuts for date/time data types /
#if (DB2VER >= 0x0300) #if (DB2VER >= 0x0300)
#define SQL_TYPE_DATE 91 #define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92 #define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93 #define SQL_TYPE_TIMESTAMP 93
#define SQL_UNICODE (-95) #define SQL_UNICODE (-95)
#define SQL_UNICODE_VARCHAR (-96) #define SQL_UNICODE_VARCHAR (-96)
#define SQL_UNICODE_LONGVARCHAR (-97) #define SQL_UNICODE_LONGVARCHAR (-97)
*/ */
function DB2Types($t) function DB2Types($t)
{ {
switch ((integer)$t) { switch ((integer)$t) {
@@ -729,7 +719,7 @@ class ADODB_db2 extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_db2 extends ADORecordSet { class ADORecordSet_db2 extends ADORecordSet {
@@ -738,7 +728,7 @@ class ADORecordSet_db2 extends ADORecordSet {
var $dataProvider = "db2"; var $dataProvider = "db2";
var $useFetchArray; var $useFetchArray;
function ADORecordSet_db2($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -805,7 +795,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fetchMode = $savem; $this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
$results = array(); $results = array();
@@ -827,7 +817,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fields = @db2_fetch_array($this->_queryID); $this->fields = @db2_fetch_array($this->_queryID);
if ($this->fields) { if ($this->fields) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
return true; return true;
} }
@@ -843,7 +833,7 @@ class ADORecordSet_db2 extends ADORecordSet {
$this->fields = db2_fetch_array($this->_queryID); $this->fields = db2_fetch_array($this->_queryID);
if ($this->fields) { if ($this->fields) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
return true; return true;
} }
@@ -857,4 +847,3 @@ class ADORecordSet_db2 extends ADORecordSet {
} }
} }
?>

View File

@@ -1,15 +1,17 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows. Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -17,23 +19,23 @@ include(ADODB_DIR."/drivers/adodb-db2.inc.php");
if (!defined('ADODB_DB2OCI')){ if (!defined('ADODB_DB2OCI')){
define('ADODB_DB2OCI',1); define('ADODB_DB2OCI',1);
/* /*
// regex code for smart remapping of :0, :1 bind vars to ? ? // regex code for smart remapping of :0, :1 bind vars to ? ?
function _colontrack($p) function _colontrack($p)
{ {
global $_COLONARR,$_COLONSZ; global $_COLONARR,$_COLONSZ;
$v = (integer) substr($p,1); $v = (integer) substr($p,1);
if ($v > $_COLONSZ) return $p; if ($v > $_COLONSZ) return $p;
$_COLONARR[] = $v; $_COLONARR[] = $v;
return '?'; return '?';
} }
// smart remapping of :0, :1 bind vars to ? ? // smart remapping of :0, :1 bind vars to ? ?
function _colonscope($sql,$arr) function _colonscope($sql,$arr)
{ {
global $_COLONARR,$_COLONSZ; global $_COLONARR,$_COLONSZ;
$_COLONARR = array(); $_COLONARR = array();
$_COLONSZ = sizeof($arr); $_COLONSZ = sizeof($arr);
@@ -47,17 +49,17 @@ if (!defined('ADODB_DB2OCI')){
} }
return array($sql2,$arr2); return array($sql2,$arr2);
} }
*/ */
/* /*
Smart remapping of :0, :1 bind vars to ? ? Smart remapping of :0, :1 bind vars to ? ?
Handles colons in comments -- and / * * / and in quoted strings. Handles colons in comments -- and / * * / and in quoted strings.
*/ */
function _colonparser($sql,$arr) function _colonparser($sql,$arr)
{ {
$lensql = strlen($sql); $lensql = strlen($sql);
$arrsize = sizeof($arr); $arrsize = sizeof($arr);
$state = 'NORM'; $state = 'NORM';
@@ -150,26 +152,21 @@ if (!defined('ADODB_DB2OCI')){
} }
return array($sql2,$arr2); return array($sql2,$arr2);
} }
class ADODB_db2oci extends ADODB_db2 { class ADODB_db2oci extends ADODB_db2 {
var $databaseType = "db2oci"; var $databaseType = "db2oci";
var $sysTimeStamp = 'sysdate'; var $sysTimeStamp = 'sysdate';
var $sysDate = 'trunc(sysdate)'; var $sysDate = 'trunc(sysdate)';
var $_bindInputArray = true; var $_bindInputArray = true;
function ADODB_db2oci() function Param($name,$type='C')
{
parent::ADODB_db2();
}
function Param($name,$type=false)
{ {
return ':'.$name; return ':'.$name;
} }
function MetaTables($ttype=false,$schema=false) function MetaTables($ttype = false, $schema = false, $mask = false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -213,18 +210,17 @@ if (!defined('ADODB_DB2OCI')){
if ($inputarr) list($sql,$inputarr) = _colonparser($sql, $inputarr); if ($inputarr) list($sql,$inputarr) = _colonparser($sql, $inputarr);
return parent::_Execute($sql, $inputarr); return parent::_Execute($sql, $inputarr);
} }
}; };
class ADORecordSet_db2oci extends ADORecordSet_db2 { class ADORecordSet_db2oci extends ADORecordSet_db2 {
var $databaseType = "db2oci"; var $databaseType = "db2oci";
function ADORecordSet_db2oci($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_db2($id,$mode); return parent::__construct($id,$mode);
}
} }
}
} //define } //define
?>

View File

@@ -0,0 +1,86 @@
<?php
/*
@version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include(ADODB_DIR."/drivers/adodb-db2.inc.php");
if (!defined('ADODB_DB2OCI')){
define('ADODB_DB2OCI',1);
/**
* Callback function for preg_replace in _colonscope()
* @param array $p matched patterns
* return string '?' if parameter replaced, :N if not
*/
function _colontrack($p)
{
global $_COLONARR, $_COLONSZ;
$v = (integer) substr($p[1], 1);
if ($v > $_COLONSZ) return $p[1];
$_COLONARR[] = $v;
return '?';
}
/**
* smart remapping of :0, :1 bind vars to ? ?
* @param string $sql SQL statement
* @param array $arr parameters
* @return array
*/
function _colonscope($sql,$arr)
{
global $_COLONARR,$_COLONSZ;
$_COLONARR = array();
$_COLONSZ = sizeof($arr);
$sql2 = preg_replace_callback('/(:[0-9]+)/', '_colontrack', $sql);
if (empty($_COLONARR)) return array($sql,$arr);
foreach($_COLONARR as $k => $v) {
$arr2[] = $arr[$v];
}
return array($sql2,$arr2);
}
class ADODB_db2oci extends ADODB_db2 {
var $databaseType = "db2oci";
var $sysTimeStamp = 'sysdate';
var $sysDate = 'trunc(sysdate)';
function _Execute($sql, $inputarr = false)
{
if ($inputarr) list($sql,$inputarr) = _colonscope($sql, $inputarr);
return parent::_Execute($sql, $inputarr);
}
};
class ADORecordSet_db2oci extends ADORecordSet_odbc {
var $databaseType = "db2oci";
function __construct($id,$mode=false)
{
return parent::__construct($id,$mode);
}
}
} //define

View File

@@ -1,12 +1,14 @@
<?php <?php
/* /*
@version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Contribution by Frank M. Kromann <frank@frontbase.com>. Contribution by Frank M. Kromann <frank@frontbase.com>.
Set tabs to 8. Set tabs to 8.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -14,7 +16,7 @@ if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_FBSQL_LAYER")) { if (! defined("_ADODB_FBSQL_LAYER")) {
define("_ADODB_FBSQL_LAYER", 1 ); define("_ADODB_FBSQL_LAYER", 1 );
class ADODB_fbsql extends ADOConnection { class ADODB_fbsql extends ADOConnection {
var $databaseType = 'fbsql'; var $databaseType = 'fbsql';
var $hasInsertID = true; var $hasInsertID = true;
var $hasAffectedRows = true; var $hasAffectedRows = true;
@@ -23,7 +25,7 @@ if (! defined("_ADODB_FBSQL_LAYER")) {
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = false; var $hasLimit = false;
function ADODB_fbsql() function __construct()
{ {
} }
@@ -151,18 +153,18 @@ if (! defined("_ADODB_FBSQL_LAYER")) {
return @fbsql_close($this->_connectionID); return @fbsql_close($this->_connectionID);
} }
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_fbsql extends ADORecordSet{ class ADORecordSet_fbsql extends ADORecordSet{
var $databaseType = "fbsql"; var $databaseType = "fbsql";
var $canSeek = true; var $canSeek = true;
function ADORecordSet_fbsql($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if (!$mode) { if (!$mode) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -175,7 +177,7 @@ if (! defined("_ADODB_FBSQL_LAYER")) {
default: default:
$this->fetchMode = FBSQL_BOTH; break; $this->fetchMode = FBSQL_BOTH; break;
} }
return $this->ADORecordSet($queryID); return parent::__construct($queryID);
} }
function _initrs() function _initrs()
@@ -261,6 +263,5 @@ if (! defined("_ADODB_FBSQL_LAYER")) {
} }
} }
} //class } //class
} // defined } // defined
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -21,11 +23,6 @@ class ADODB_firebird extends ADODB_ibase {
var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)"; var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)";
function ADODB_firebird()
{
$this->ADODB_ibase();
}
function ServerInfo() function ServerInfo()
{ {
$arr['dialect'] = $this->dialect; $arr['dialect'] = $this->dialect;
@@ -69,9 +66,8 @@ class ADORecordSet_firebird extends ADORecordSet_ibase {
var $databaseType = "firebird"; var $databaseType = "firebird";
function ADORecordSet_firebird($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordSet_ibase($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -21,7 +23,7 @@
$rs = $conn->Execute('select gen_id(adodb,1) from rdb$database'); $rs = $conn->Execute('select gen_id(adodb,1) from rdb$database');
$id = $rs->fields[0]; $id = $rs->fields[0];
$conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)"); $conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)");
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -54,7 +56,7 @@ class ADODB_ibase extends ADOConnection {
var $blobEncodeType = 'C'; var $blobEncodeType = 'C';
var $role = false; var $role = false;
function ADODB_ibase() function __construct()
{ {
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT; if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
} }
@@ -84,8 +86,12 @@ class ADODB_ibase extends ADOConnection {
// PHP5 change. // PHP5 change.
if (function_exists('ibase_timefmt')) { if (function_exists('ibase_timefmt')) {
ibase_timefmt($this->ibase_datefmt,IBASE_DATE ); ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP ); if ($this->dialect == 1) {
else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP ); ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
}
else {
ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
}
ibase_timefmt($this->ibase_timefmt,IBASE_TIME ); ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
} else { } else {
@@ -95,6 +101,7 @@ class ADODB_ibase extends ADOConnection {
} }
return true; return true;
} }
// returns true or false // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{ {
@@ -104,7 +111,9 @@ class ADODB_ibase extends ADOConnection {
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false) function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
{ {
if ($internalKey) return array('RDB$DB_KEY'); if ($internalKey) {
return array('RDB$DB_KEY');
}
$table = strtoupper($table); $table = strtoupper($table);
@@ -144,9 +153,15 @@ class ADODB_ibase extends ADOConnection {
function CommitTrans($ok=true) function CommitTrans($ok=true)
{ {
if (!$ok) return $this->RollbackTrans(); if (!$ok) {
if ($this->transOff) return true; return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1; }
if ($this->transOff) {
return true;
}
if ($this->transCnt) {
$this->transCnt -= 1;
}
$ret = false; $ret = false;
$this->autoCommit = true; $this->autoCommit = true;
if ($this->_transactionID) { if ($this->_transactionID) {
@@ -180,8 +195,9 @@ class ADODB_ibase extends ADOConnection {
if ($this->transCnt) $this->transCnt -= 1; if ($this->transCnt) $this->transCnt -= 1;
$ret = false; $ret = false;
$this->autoCommit = true; $this->autoCommit = true;
if ($this->_transactionID) if ($this->_transactionID) {
$ret = ibase_rollback($this->_transactionID); $ret = ibase_rollback($this->_transactionID);
}
$this->_transactionID = false; $this->_transactionID = false;
return $ret; return $ret;
@@ -219,7 +235,9 @@ class ADODB_ibase extends ADOConnection {
while ($row = $rs->FetchRow()) { while ($row = $rs->FetchRow()) {
$index = $row[0]; $index = $row[0];
if (!isset($indexes[$index])) { if (!isset($indexes[$index])) {
if (is_null($row[3])) {$row[3] = 0;} if (is_null($row[3])) {
$row[3] = 0;
}
$indexes[$index] = array( $indexes[$index] = array(
'unique' => ($row[3] == 1), 'unique' => ($row[3] == 1),
'columns' => array() 'columns' => array()
@@ -244,20 +262,22 @@ class ADODB_ibase extends ADOConnection {
// See http://community.borland.com/article/0,1410,25844,00.html // See http://community.borland.com/article/0,1410,25844,00.html
function RowLock($tables,$where,$col=false) function RowLock($tables,$where,$col=false)
{ {
if ($this->autoCommit) $this->BeginTrans(); if ($this->autoCommit) {
$this->BeginTrans();
}
$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim? $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
return 1; return 1;
} }
function CreateSequence($seqname,$startID=1) function CreateSequence($seqname = 'adodbseq', $startID = 1)
{ {
$ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" )); $ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
if (!$ok) return false; if (!$ok) return false;
return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';'); return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
} }
function DropSequence($seqname) function DropSequence($seqname = 'adodbseq')
{ {
$seqname = strtoupper($seqname); $seqname = strtoupper($seqname);
$this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'"); $this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'");
@@ -272,10 +292,16 @@ class ADODB_ibase extends ADOConnection {
$this->Execute("SET GENERATOR $seqname TO ".($startID-1).';'); $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
$rs = $this->Execute($getnext); $rs = $this->Execute($getnext);
} }
if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields); if ($rs && !$rs->EOF) {
else $this->genID = 0; // false $this->genID = (integer) reset($rs->fields);
}
else {
$this->genID = 0; // false
}
if ($rs) $rs->Close(); if ($rs) {
$rs->Close();
}
return $this->genID; return $this->genID;
} }
@@ -365,7 +391,9 @@ class ADODB_ibase extends ADOConnection {
} }
} else $ret = $fn($conn,$sql); } else $ret = $fn($conn,$sql);
} }
if ($docommit && $ret === true) ibase_commit($this->_connectionID); if ($docommit && $ret === true) {
ibase_commit($this->_connectionID);
}
$this->_handleerror(); $this->_handleerror();
return $ret; return $ret;
@@ -374,7 +402,9 @@ class ADODB_ibase extends ADOConnection {
// returns true or false // returns true or false
function _close() function _close()
{ {
if (!$this->autoCommit) @ibase_rollback($this->_connectionID); if (!$this->autoCommit) {
@ibase_rollback($this->_connectionID);
}
return @ibase_close($this->_connectionID); return @ibase_close($this->_connectionID);
} }
@@ -475,6 +505,7 @@ class ADODB_ibase extends ADOConnection {
} // switch } // switch
} }
//OPN STUFF end //OPN STUFF end
// returns array of ADOFieldObjects for current table // returns array of ADOFieldObjects for current table
function MetaColumns($table, $normalize=true) function MetaColumns($table, $normalize=true)
{ {
@@ -721,7 +752,7 @@ class ADODB_ibase extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_ibase extends ADORecordSet class ADORecordset_ibase extends ADORecordSet
{ {
@@ -730,12 +761,12 @@ class ADORecordset_ibase extends ADORecordSet
var $bind=false; var $bind=false;
var $_cacheType; var $_cacheType;
function ADORecordset_ibase($id,$mode=false) function __construct($id,$mode=false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode;
$this->ADORecordSet($id); parent::__construct($id);
} }
/* Returns: an object containing field information. /* Returns: an object containing field information.
@@ -747,18 +778,19 @@ class ADORecordset_ibase extends ADORecordSet
{ {
$fld = new ADOFieldObject; $fld = new ADOFieldObject;
$ibf = ibase_field_info($this->_queryID,$fieldOffset); $ibf = ibase_field_info($this->_queryID,$fieldOffset);
$name = empty($ibf['alias']) ? $ibf['name'] : $ibf['alias'];
switch (ADODB_ASSOC_CASE) { switch (ADODB_ASSOC_CASE) {
case 2: // the default case ADODB_ASSOC_CASE_UPPER:
$fld->name = ($ibf['alias']); $fld->name = strtoupper($name);
if (empty($fld->name)) $fld->name = ($ibf['name']);
break; break;
case 0: case ADODB_ASSOC_CASE_LOWER:
$fld->name = strtoupper($ibf['alias']); $fld->name = strtolower($name);
if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
break; break;
case 1: case ADODB_ASSOC_CASE_NATIVE:
$fld->name = strtolower($ibf['alias']); default:
if (empty($fld->name)) $fld->name = strtolower($ibf['name']); $fld->name = $name;
break; break;
} }
@@ -822,9 +854,9 @@ class ADORecordset_ibase extends ADORecordSet
$this->fields = $f; $this->fields = $f;
if ($this->fetchMode == ADODB_FETCH_ASSOC) { if ($this->fetchMode == ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} else if ($this->fetchMode == ADODB_FETCH_BOTH) { } else if ($this->fetchMode == ADODB_FETCH_BOTH) {
$this->fields = array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE)); $this->fields = array_merge($this->fields,$this->GetRowAssoc());
} }
return true; return true;
} }
@@ -884,4 +916,3 @@ class ADORecordset_ibase extends ADORecordSet
} }
} }
?>

View File

@@ -1,17 +1,19 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* Released under both BSD license and Lesser GPL library license. * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* Whenever there is any discrepancy between the two licenses, * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* the BSD license will take precedence. * Released under both BSD license and Lesser GPL library license.
* * Whenever there is any discrepancy between the two licenses,
* Set tabs to 4 for best viewing. * the BSD license will take precedence.
* *
* Latest version is available at http://php.weblogs.com * Set tabs to 4 for best viewing.
* *
* Informix 9 driver that supports SELECT FIRST * Latest version is available at http://php.weblogs.com
* *
*/ * Informix 9 driver that supports SELECT FIRST
*
*/
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -32,9 +34,8 @@ class ADODB_informix extends ADODB_informix72 {
class ADORecordset_informix extends ADORecordset_informix72 { class ADORecordset_informix extends ADORecordset_informix72 {
var $databaseType = "informix"; var $databaseType = "informix";
function ADORecordset_informix($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordset_informix72($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim. All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -12,7 +14,7 @@
Further mods by "Samuel CARRIERE" <samuel_carriere@hotmail.com> Further mods by "Samuel CARRIERE" <samuel_carriere@hotmail.com>
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -54,7 +56,7 @@ class ADODB_informix72 extends ADOConnection {
var $sysTimeStamp = 'CURRENT'; var $sysTimeStamp = 'CURRENT';
var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0 var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0
function ADODB_informix72() function __construct()
{ {
// alternatively, use older method: // alternatively, use older method:
//putenv("DBDATE=Y4MD-"); //putenv("DBDATE=Y4MD-");
@@ -123,7 +125,7 @@ class ADODB_informix72 extends ADOConnection {
return true; return true;
} }
function RowLock($tables,$where,$col='1 as ignore') function RowLock($tables,$where,$col='1 as adodbignore')
{ {
if ($this->_autocommit) $this->BeginTrans(); if ($this->_autocommit) $this->BeginTrans();
return $this->GetOne("select $col from $tables where $where for update"); return $this->GetOne("select $col from $tables where $where for update");
@@ -147,6 +149,51 @@ class ADODB_informix72 extends ADOConnection {
} }
function MetaProcedures($NamePattern = false, $catalog = null, $schemaPattern = null)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$procedures = array ();
// get index details
$likepattern = '';
if ($NamePattern) {
$likepattern = " WHERE procname LIKE '".$NamePattern."'";
}
$rs = $this->Execute('SELECT procname, isproc FROM sysprocedures'.$likepattern);
if (is_object($rs)) {
// parse index data into array
while ($row = $rs->FetchRow()) {
$procedures[$row[0]] = array(
'type' => ($row[1] == 'f' ? 'FUNCTION' : 'PROCEDURE'),
'catalog' => '',
'schema' => '',
'remarks' => ''
);
}
}
// restore fetchmode
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
return $procedures;
}
function MetaColumns($table, $normalize=true) function MetaColumns($table, $normalize=true)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -166,7 +213,7 @@ class ADODB_informix72 extends ADOConnection {
while (!$rs->EOF) { //print_r($rs->fields); while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject(); $fld = new ADOFieldObject();
$fld->name = $rs->fields[0]; $fld->name = $rs->fields[0];
/* //!eos. /* //!eos.
$rs->fields[1] is not the correct adodb type $rs->fields[1] is not the correct adodb type
$rs->fields[2] is not correct max_length, because can include not-null bit $rs->fields[2] is not correct max_length, because can include not-null bit
@@ -274,7 +321,7 @@ class ADODB_informix72 extends ADOConnection {
#if ($argDatabasename) return $this->SelectDB($argDatabasename); #if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true; return true;
} }
/* /*
// ifx_do does not accept bind parameters - weird ??? // ifx_do does not accept bind parameters - weird ???
function Prepare($sql) function Prepare($sql)
{ {
@@ -282,7 +329,7 @@ class ADODB_informix72 extends ADOConnection {
if (!$stmt) return $sql; if (!$stmt) return $sql;
else return array($sql,$stmt); else return array($sql,$stmt);
} }
*/ */
// returns query ID if successful, otherwise false // returns query ID if successful, otherwise false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
@@ -331,14 +378,17 @@ class ADODB_informix72 extends ADOConnection {
function _close() function _close()
{ {
$this->lastQuery = false; $this->lastQuery = false;
if($this->_connectionID) {
return ifx_close($this->_connectionID); return ifx_close($this->_connectionID);
} }
return true;
}
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_informix72 extends ADORecordSet { class ADORecordset_informix72 extends ADORecordSet {
@@ -346,14 +396,14 @@ class ADORecordset_informix72 extends ADORecordSet {
var $canSeek = true; var $canSeek = true;
var $_fieldprops = false; var $_fieldprops = false;
function ADORecordset_informix72($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE;
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
return $this->ADORecordSet($id); return parent::__construct($id);
} }
@@ -443,14 +493,17 @@ class ADORecordset_informix72 extends ADORecordSet {
is running. All associated result memory for the specified result identifier will automatically be freed. */ is running. All associated result memory for the specified result identifier will automatically be freed. */
function _close() function _close()
{ {
if($this->_queryID) {
return ifx_free_result($this->_queryID); return ifx_free_result($this->_queryID);
} }
return true;
}
} }
/** !Eos /** !Eos
* Auxiliar function to Parse coltype,collength. Used by Metacolumns * Auxiliar function to Parse coltype,collength. Used by Metacolumns
* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties) * return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties)
*/ */
function ifx_props($coltype,$collength){ function ifx_props($coltype,$collength){
$itype=fmod($coltype+1,256); $itype=fmod($coltype+1,256);
$nullable=floor(($coltype+1) /256) ?"N":"Y"; $nullable=floor(($coltype+1) /256) ?"N":"Y";
@@ -470,6 +523,3 @@ function ifx_props($coltype,$collength){
} }
return array($mtype,$length,$precision,$nullable); return array($mtype,$length,$precision,$nullable);
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -12,7 +14,7 @@
bugs that surfaced when PHP error levels were set high. bugs that surfaced when PHP error levels were set high.
Joshua Eldridge (joshuae74#hotmail.com) Joshua Eldridge (joshuae74#hotmail.com)
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -43,7 +45,7 @@ class ADODB_ldap extends ADOConnection {
# error on binding, eg. "Binding: invalid credentials" # error on binding, eg. "Binding: invalid credentials"
var $_bind_errmsg = "Binding: %s"; var $_bind_errmsg = "Binding: %s";
function ADODB_ldap() function __construct()
{ {
} }
@@ -55,7 +57,7 @@ class ADODB_ldap extends ADOConnection {
if ( !function_exists( 'ldap_connect' ) ) return null; if ( !function_exists( 'ldap_connect' ) ) return null;
if (strpos('ldap://',$host) === 0 || strpos('ldaps://',$host) === 0) { if (strpos($host,'ldap://') === 0 || strpos($host,'ldaps://') === 0) {
$this->_connectionID = @ldap_connect($host); $this->_connectionID = @ldap_connect($host);
} else { } else {
$conn_info = array( $host,$this->port); $conn_info = array( $host,$this->port);
@@ -94,7 +96,7 @@ class ADODB_ldap extends ADOConnection {
return $this->_connectionID; return $this->_connectionID;
} }
/* /*
Valid Domain Values for LDAP Options: Valid Domain Values for LDAP Options:
LDAP_OPT_DEREF (integer) LDAP_OPT_DEREF (integer)
@@ -144,7 +146,7 @@ class ADODB_ldap extends ADOConnection {
"OPTION_VALUE"=>FALSE "OPTION_VALUE"=>FALSE
) )
); );
*/ */
function _inject_bind_options( $options ) { function _inject_bind_options( $options ) {
foreach( $options as $option ) { foreach( $options as $option ) {
@@ -185,7 +187,10 @@ class ADODB_ldap extends ADOConnection {
function ServerInfo() function ServerInfo()
{ {
if( !empty( $this->version ) ) return $this->version; if( !empty( $this->version ) ) {
return $this->version;
}
$version = array(); $version = array();
/* /*
Determines how aliases are handled during search. Determines how aliases are handled during search.
@@ -241,8 +246,8 @@ class ADODB_ldap extends ADOConnection {
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF'; $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF';
} else { } else {
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON'; $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON';
} }
/* /*
Determines whether LDAP I/O operations are automatically restarted if they abort prematurely. Determines whether LDAP I/O operations are automatically restarted if they abort prematurely.
LDAP_OPT_ON LDAP_OPT_ON
@@ -254,8 +259,8 @@ class ADODB_ldap extends ADOConnection {
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF'; $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF';
} else { } else {
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON'; $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON';
} }
/* /*
This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server. This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server.
LDAP_VERSION2 (2) LDAP_VERSION2 (2)
@@ -267,8 +272,8 @@ class ADODB_ldap extends ADOConnection {
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2'; $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2';
} else { } else {
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3'; $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3';
} }
/* The host name (or list of hosts) for the primary LDAP server. */ /* The host name (or list of hosts) for the primary LDAP server. */
ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] ); ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] );
ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] ); ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] );
@@ -276,13 +281,12 @@ class ADODB_ldap extends ADOConnection {
ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] ); ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] );
return $this->version = $version; return $this->version = $version;
} }
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_ldap extends ADORecordSet{ class ADORecordSet_ldap extends ADORecordSet{
@@ -290,7 +294,7 @@ class ADORecordSet_ldap extends ADORecordSet{
var $canSeek = false; var $canSeek = false;
var $_entryID; /* keeps track of the entry resource identifier */ var $_entryID; /* keeps track of the entry resource identifier */
function ADORecordSet_ldap($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -311,7 +315,7 @@ class ADORecordSet_ldap extends ADORecordSet{
break; break;
} }
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function _initrs() function _initrs()
@@ -322,7 +326,6 @@ class ADORecordSet_ldap extends ADORecordSet{
GetAssoc() function GetAssoc() function
*/ */
$this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID ); $this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID );
} }
/* /*
@@ -348,7 +351,7 @@ class ADORecordSet_ldap extends ADORecordSet{
return $results; return $results;
} }
function GetRowAssoc() function GetRowAssoc($upper = ADODB_ASSOC_CASE)
{ {
$results = array(); $results = array();
foreach ( $this->fields as $k=>$v ) { foreach ( $this->fields as $k=>$v ) {
@@ -385,8 +388,9 @@ class ADORecordSet_ldap extends ADORecordSet{
function _fetch() function _fetch()
{ {
if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) {
return false; return false;
}
if ( $this->_currentRow == 0 ) { if ( $this->_currentRow == 0 ) {
$this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID ); $this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID );
@@ -396,6 +400,7 @@ class ADORecordSet_ldap extends ADORecordSet{
$this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID ); $this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID );
$this->_numOfFields = $this->fields['count']; $this->_numOfFields = $this->fields['count'];
switch ( $this->fetchMode ) { switch ( $this->fetchMode ) {
case LDAP_ASSOC: case LDAP_ASSOC:
@@ -411,7 +416,8 @@ class ADORecordSet_ldap extends ADORecordSet{
$this->fields = $this->GetRowNums(); $this->fields = $this->GetRowNums();
break; break;
} }
return ( is_array( $this->fields ) );
return is_array( $this->fields );
} }
function _close() { function _close() {
@@ -420,4 +426,3 @@ class ADORecordSet_ldap extends ADORecordSet{
} }
} }
?>

View File

@@ -1,10 +1,12 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
@@ -12,7 +14,7 @@
To configure for Unix, see To configure for Unix, see
http://phpbuilder.com/columns/alberto20000919.php3 http://phpbuilder.com/columns/alberto20000919.php3
*/ */
// security - hide paths // security - hide paths
@@ -39,10 +41,10 @@ if (!defined('ADODB_DIR')) die();
// has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc // has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
if (ADODB_PHPVER >= 0x4300) { if (ADODB_PHPVER >= 0x4300) {
// docs say 4.2.0, but testing shows only since 4.3.0 does it work! // docs say 4.2.0, but testing shows only since 4.3.0 does it work!
ini_set('mssql.datetimeconvert',0); ini_set('mssql.datetimeconvert',0);
} else { } else {
global $ADODB_mssql_mths; // array, months must be upper-case global $ADODB_mssql_mths; // array, months must be upper-case
$ADODB_mssql_date_order = 'mdy'; $ADODB_mssql_date_order = 'mdy';
@@ -57,7 +59,7 @@ if (ADODB_PHPVER >= 0x4300) {
// Not required for PHP 4.2.0 and above. // Not required for PHP 4.2.0 and above.
function AutoDetect_MSSQL_Date_Order($conn) function AutoDetect_MSSQL_Date_Order($conn)
{ {
global $ADODB_mssql_date_order; global $ADODB_mssql_date_order;
$adate = $conn->GetOne('select getdate()'); $adate = $conn->GetOne('select getdate()');
if ($adate) { if ($adate) {
$anum = (int) $adate; $anum = (int) $adate;
@@ -76,7 +78,7 @@ class ADODB_mssql extends ADOConnection {
var $dataProvider = "mssql"; var $dataProvider = "mssql";
var $replaceQuote = "''"; // string to use to replace quotes var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'"; var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d\TH:i:s'";
var $hasInsertID = true; var $hasInsertID = true;
var $substr = "substring"; var $substr = "substring";
var $length = 'len'; var $length = 'len';
@@ -84,7 +86,7 @@ class ADODB_mssql extends ADOConnection {
var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'"; var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))"; var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
var $metaColumnsSQL = # xtype==61 is datetime var $metaColumnsSQL = # xtype==61 is datetime
"select c.name,t.name,c.length, "select c.name,t.name,c.length,c.isnullable, c.status,
(case when c.xusertype=61 then 0 else c.xprec end), (case when c.xusertype=61 then 0 else c.xprec end),
(case when c.xusertype=61 then 0 else c.xscale end) (case when c.xusertype=61 then 0 else c.xscale end)
from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
@@ -105,7 +107,7 @@ class ADODB_mssql extends ADOConnection {
var $_bindInputArray = true; var $_bindInputArray = true;
var $forceNewConnect = false; var $forceNewConnect = false;
function ADODB_mssql() function __construct()
{ {
$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0); $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
} }
@@ -180,7 +182,7 @@ class ADODB_mssql extends ADOConnection {
} }
// undo magic quotes for " unless sybase is on // undo magic quotes for " unless sybase is on
$sybase = @ini_get('magic_quotes_sybase'); $sybase = ini_get('magic_quotes_sybase');
if (!$sybase) { if (!$sybase) {
$s = str_replace('\\"','"',$s); $s = str_replace('\\"','"',$s);
if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
@@ -193,7 +195,7 @@ class ADODB_mssql extends ADOConnection {
return "'".$s."'"; return "'".$s."'";
} }
} }
// moodle change end - see readme_moodle.txt // moodle change end - see readme_moodle.txt
function _affectedrows() function _affectedrows()
{ {
@@ -366,13 +368,72 @@ class ADODB_mssql extends ADOConnection {
See http://www.swynk.com/friends/achigrik/SQL70Locks.asp See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
*/ */
function RowLock($tables,$where,$col='top 1 null as ignore') function RowLock($tables,$where,$col='1 as adodbignore')
{ {
if ($col == '1 as adodbignore') $col = 'top 1 null as ignore';
if (!$this->transCnt) $this->BeginTrans(); if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where"); return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where");
} }
function MetaColumns($table, $normalize=true)
{
// $arr = ADOConnection::MetaColumns($table);
// return $arr;
$this->_findschema($table,$schema);
if ($schema) {
$dbName = $this->database;
$this->SelectDB($schema);
}
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if ($schema) {
$this->SelectDB($dbName);
}
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
$false = false;
return $false;
}
$retarr = array();
while (!$rs->EOF){
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
$fld->not_null = (!$rs->fields[3]);
$fld->auto_increment = ($rs->fields[4] == 128); // sys.syscolumns status field. 0x80 = 128 ref: http://msdn.microsoft.com/en-us/library/ms186816.aspx
if (isset($rs->fields[5]) && $rs->fields[5]) {
if ($rs->fields[5]>0) $fld->max_length = $rs->fields[5];
$fld->scale = $rs->fields[6];
if ($fld->scale>0) $fld->max_length += 1;
} else
$fld->max_length = $rs->fields[2];
if ($save == ADODB_FETCH_NUM) {
$retarr[] = $fld;
} else {
$retarr[strtoupper($fld->name)] = $fld;
}
$rs->MoveNext();
}
$rs->Close();
return $retarr;
}
function MetaIndexes($table,$primary=false, $owner=false) function MetaIndexes($table,$primary=false, $owner=false)
{ {
$table = $this->qstr($table); $table = $this->qstr($table);
@@ -476,7 +537,7 @@ order by constraint_name, referenced_table_name, keyno";
// "Stein-Aksel Basma" <basma@accelero.no> // "Stein-Aksel Basma" <basma@accelero.no>
// tested with MSSQL 2000 // tested with MSSQL 2000
function MetaPrimaryKeys($table) function MetaPrimaryKeys($table, $owner=false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -591,7 +652,7 @@ order by constraint_name, referenced_table_name, keyno";
return array($sql,$this->qstr($sql2),$max,$sql2); return array($sql,$this->qstr($sql2),$max,$sql2);
} }
function PrepareSP($sql) function PrepareSP($sql,$param=true)
{ {
if (!$this->_has_mssql_init) { if (!$this->_has_mssql_init) {
ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0"); ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
@@ -797,7 +858,7 @@ order by constraint_name, referenced_table_name, keyno";
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_mssql extends ADORecordSet { class ADORecordset_mssql extends ADORecordSet {
@@ -806,7 +867,7 @@ class ADORecordset_mssql extends ADORecordSet {
var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083 var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083
// _mths works only in non-localised system // _mths works only in non-localised system
function ADORecordset_mssql($id,$mode=false) function __construct($id,$mode=false)
{ {
// freedts check... // freedts check...
$this->hasFetchAssoc = function_exists('mssql_fetch_assoc'); $this->hasFetchAssoc = function_exists('mssql_fetch_assoc');
@@ -817,7 +878,7 @@ class ADORecordset_mssql extends ADORecordSet {
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
return $this->ADORecordSet($id,$mode); return parent::__construct($id,$mode);
} }
@@ -911,11 +972,19 @@ class ADORecordset_mssql extends ADORecordSet {
if (is_array($this->fields)) { if (is_array($this->fields)) {
if (ADODB_ASSOC_CASE == 0) { if (ADODB_ASSOC_CASE == 0) {
foreach($this->fields as $k=>$v) { foreach($this->fields as $k=>$v) {
$this->fields[strtolower($k)] = $v; $kn = strtolower($k);
if ($kn <> $k) {
unset($this->fields[$k]);
$this->fields[$kn] = $v;
}
} }
} else if (ADODB_ASSOC_CASE == 1) { } else if (ADODB_ASSOC_CASE == 1) {
foreach($this->fields as $k=>$v) { foreach($this->fields as $k=>$v) {
$this->fields[strtoupper($k)] = $v; $kn = strtoupper($k);
if ($kn <> $k) {
unset($this->fields[$k]);
$this->fields[$kn] = $v;
}
} }
} }
} }
@@ -956,11 +1025,19 @@ class ADORecordset_mssql extends ADORecordSet {
if (!$this->fields) { if (!$this->fields) {
} else if (ADODB_ASSOC_CASE == 0) { } else if (ADODB_ASSOC_CASE == 0) {
foreach($this->fields as $k=>$v) { foreach($this->fields as $k=>$v) {
$this->fields[strtolower($k)] = $v; $kn = strtolower($k);
if ($kn <> $k) {
unset($this->fields[$k]);
$this->fields[$kn] = $v;
}
} }
} else if (ADODB_ASSOC_CASE == 1) { } else if (ADODB_ASSOC_CASE == 1) {
foreach($this->fields as $k=>$v) { foreach($this->fields as $k=>$v) {
$this->fields[strtoupper($k)] = $v; $kn = strtoupper($k);
if ($kn <> $k) {
unset($this->fields[$k]);
$this->fields[$kn] = $v;
}
} }
} }
} else { } else {
@@ -974,10 +1051,14 @@ class ADORecordset_mssql extends ADORecordSet {
function _close() function _close()
{ {
if($this->_queryID) {
$rez = mssql_free_result($this->_queryID); $rez = mssql_free_result($this->_queryID);
$this->_queryID = false; $this->_queryID = false;
return $rez; return $rez;
} }
return true;
}
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v) static function UnixDate($v)
{ {
@@ -993,9 +1074,9 @@ class ADORecordset_mssql extends ADORecordSet {
class ADORecordSet_array_mssql extends ADORecordSet_array { class ADORecordSet_array_mssql extends ADORecordSet_array {
function ADORecordSet_array_mssql($id=-1,$mode=false) function __construct($id=-1,$mode=false)
{ {
$this->ADORecordSet_array($id,$mode); parent::__construct($id,$mode);
} }
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
@@ -1073,27 +1154,25 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
} }
/* /*
Code Example 1: Code Example 1:
select object_name(constid) as constraint_name, select object_name(constid) as constraint_name,
object_name(fkeyid) as table_name, object_name(fkeyid) as table_name,
col_name(fkeyid, fkey) as column_name, col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name, object_name(rkeyid) as referenced_table_name,
col_name(rkeyid, rkey) as referenced_column_name col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys from sysforeignkeys
where object_name(fkeyid) = x where object_name(fkeyid) = x
order by constraint_name, table_name, referenced_table_name, keyno order by constraint_name, table_name, referenced_table_name, keyno
Code Example 2: Code Example 2:
select constraint_name, select constraint_name,
column_name, column_name,
ordinal_position ordinal_position
from information_schema.key_column_usage from information_schema.key_column_usage
where constraint_catalog = db_name() where constraint_catalog = db_name()
and table_name = x and table_name = x
order by constraint_name, ordinal_position order by constraint_name, ordinal_position
http://www.databasejournal.com/scripts/article.php/1440551 http://www.databasejournal.com/scripts/article.php/1440551
*/ */
?>

View File

@@ -9,7 +9,7 @@
// ADOdb - Database Abstraction Library for PHP // // ADOdb - Database Abstraction Library for PHP //
// http://adodb.sourceforge.net/ // // http://adodb.sourceforge.net/ //
// // // //
// Copyright (C) 2000-2009 John Lim (jlim\@natsoft.com.my) // // Copyright (c) 2000-2014 John Lim (jlim\@natsoft.com.my) //
// All rights reserved. // // All rights reserved. //
// Released under both BSD license and LGPL library license. // // Released under both BSD license and LGPL library license. //
// Whenever there is any discrepancy between the two licenses, // // Whenever there is any discrepancy between the two licenses, //
@@ -36,11 +36,11 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/** /**
* MSSQL Driver with auto-prepended "N" for correct unicode storage * MSSQL Driver with auto-prepended "N" for correct unicode storage
* of SQL literal strings. Intended to be used with MSSQL drivers that * of SQL literal strings. Intended to be used with MSSQL drivers that
* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get * are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get
* true cross-db compatibility from the application point of view. * true cross-db compatibility from the application point of view.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -53,11 +53,6 @@ include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
class ADODB_mssql_n extends ADODB_mssql { class ADODB_mssql_n extends ADODB_mssql {
var $databaseType = "mssql_n"; var $databaseType = "mssql_n";
function ADODB_mssqlpo()
{
ADODB_mssql::ADODB_mssql();
}
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$sql = $this->_appendN($sql); $sql = $this->_appendN($sql);
@@ -70,102 +65,185 @@ class ADODB_mssql_n extends ADODB_mssql {
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add * and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
* the "N" notation when working against MSSQL. * the "N" notation when working against MSSQL.
* *
* Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar, * The orginal note indicated that this hack should only be used if ALL the char-based columns
* nvarchar and ntext * in your DB are of type nchar, nvarchar and ntext, but testing seems to indicate that SQL server
* doesn't seem to care if the statement is used against char etc fields.
*
* @todo This function should raise an ADOdb error if one of the transformations fail
*
* @param mixed $inboundData Either a string containing an SQL statement
* or an array with resources from prepared statements
*
* @return mixed
*/ */
function _appendN($sql) { function _appendN($inboundData) {
$result = $sql; $inboundIsArray = false;
/// Check we have some single quote in the query. Exit ok. if (is_array($inboundData))
if (strpos($sql, SINGLEQUOTE) === false) { {
return $sql; $inboundIsArray = true;
$inboundArray = $inboundData;
} else
$inboundArray = (array)$inboundData;
/*
* All changes will be placed here
*/
$outboundArray = $inboundArray;
foreach($inboundArray as $inboundKey=>$inboundValue)
{
if (is_resource($inboundValue))
{
/*
* Prepared statement resource
*/
if ($this->debug)
ADOConnection::outp("{$this->databaseType} index $inboundKey value is resource, continue");
continue;
} }
/// Check we haven't an odd number of single quotes (this can cause problems below if (strpos($inboundValue, SINGLEQUOTE) === false)
/// and should be considered one wrong SQL). Exit with debug info. {
if ((substr_count($sql, SINGLEQUOTE) & 1)) { /*
if ($this->debug) { * Check we have something to manipulate
*/
if ($this->debug)
ADOConnection::outp("{$this->databaseType} index $inboundKey value $inboundValue has no single quotes, continue");
continue;
}
/*
* Check we haven't an odd number of single quotes (this can cause problems below
* and should be considered one wrong SQL). Exit with debug info.
*/
if ((substr_count($inboundValue, SINGLEQUOTE) & 1))
{
if ($this->debug)
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)"); ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
}
return $sql; break;
} }
/// Check we haven't any backslash + single quote combination. It should mean wrong /*
/// backslashes use (bad magic_quotes_sybase?). Exit with debug info. * Check we haven't any backslash + single quote combination. It should mean wrong
* backslashes use (bad magic_quotes_sybase?). Exit with debug info.
*/
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/'; $regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
if (preg_match($regexp, $sql)) { if (preg_match($regexp, $inboundValue))
if ($this->debug) { {
if ($this->debug)
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote"); ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
}
return $sql; break;
} }
/// Remove pairs of single-quotes /*
* Remove pairs of single-quotes
*/
$pairs = array(); $pairs = array();
$regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/'; $regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
preg_match_all($regexp, $result, $list_of_pairs); preg_match_all($regexp, $inboundValue, $list_of_pairs);
if ($list_of_pairs) {
foreach (array_unique($list_of_pairs[0]) as $key=>$value) { if ($list_of_pairs)
{
foreach (array_unique($list_of_pairs[0]) as $key=>$value)
$pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value; $pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
}
if (!empty($pairs)) {
$result = str_replace($pairs, array_keys($pairs), $result); if (!empty($pairs))
} $inboundValue = str_replace($pairs, array_keys($pairs), $inboundValue);
} }
/// Remove the rest of literals present in the query /*
* Remove the rest of literals present in the query
*/
$literals = array(); $literals = array();
$regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is'; $regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
preg_match_all($regexp, $result, $list_of_literals); preg_match_all($regexp, $inboundValue, $list_of_literals);
if ($list_of_literals) {
foreach (array_unique($list_of_literals[0]) as $key=>$value) { if ($list_of_literals)
{
foreach (array_unique($list_of_literals[0]) as $key=>$value)
$literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value; $literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
}
if (!empty($literals)) {
$result = str_replace($literals, array_keys($literals), $result);
}
}
/// Analyse literals to prepend the N char to them if their contents aren't numeric if (!empty($literals))
if (!empty($literals)) { $inboundValue = str_replace($literals, array_keys($literals), $inboundValue);
}
/*
* Analyse literals to prepend the N char to them if their contents aren't numeric
*/
if (!empty($literals))
{
foreach ($literals as $key=>$value) { foreach ($literals as $key=>$value) {
if (!is_numeric(trim($value, SINGLEQUOTE))) { if (!is_numeric(trim($value, SINGLEQUOTE)))
/// Non numeric string, prepend our dear N /*
$literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N" * Non numeric string, prepend our dear N, whilst
} * Trimming potentially existing previous "N"
*/
$literals[$key] = 'N' . trim($value, 'N');
} }
} }
/// Re-apply literals to the text /*
if (!empty($literals)) { * Re-apply literals to the text
$result = str_replace(array_keys($literals), $literals, $result); */
if (!empty($literals))
$inboundValue = str_replace(array_keys($literals), $literals, $inboundValue);
/*
* Any pairs followed by N' must be switched to N' followed by those pairs
* (or strings beginning with single quotes will fail)
*/
$inboundValue = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $inboundValue);
/*
* Re-apply pairs of single-quotes to the text
*/
if (!empty($pairs))
$inboundValue = str_replace(array_keys($pairs), $pairs, $inboundValue);
/*
* Print transformation if debug = on
*/
if (strcmp($inboundValue,$inboundArray[$inboundKey]) <> 0 && $this->debug)
ADOConnection::outp("{$this->databaseType} internal transformation: {$inboundArray[$inboundKey]} to {$inboundValue}");
if (strcmp($inboundValue,$inboundArray[$inboundKey]) <> 0)
/*
* Place the transformed value into the outbound array
*/
$outboundArray[$inboundKey] = $inboundValue;
} }
/// Any pairs followed by N' must be switched to N' followed by those pairs /*
/// (or strings beginning with single quotes will fail) * Any transformations are in the $outboundArray
$result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result); */
if ($inboundIsArray)
return $outboundArray;
/*
* We passed a string in originally
*/
return $outboundArray[0];
/// Re-apply pairs of single-quotes to the text
if (!empty($pairs)) {
$result = str_replace(array_keys($pairs), $pairs, $result);
} }
/// Print transformation if debug = on
if ($result != $sql && $this->debug) {
ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");
}
return $result;
}
} }
class ADORecordset_mssql_n extends ADORecordset_mssql { class ADORecordset_mssql_n extends ADORecordset_mssql {
var $databaseType = "mssql_n"; var $databaseType = "mssql_n";
function ADORecordset_mssql_n($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordset_mssql($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,10 +1,12 @@
<?php <?php
/* /*
V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
@@ -16,7 +18,7 @@ V5.11 5 May 2010 (c) 2000-2010 John Lim (jlim#natsoft.com). All rights reserve
$stream = sqlsrv_get_field($stmt, $index, SQLSRV_SQLTYPE_STREAM(SQLSRV_ENC_BINARY)); $stream = sqlsrv_get_field($stmt, $index, SQLSRV_SQLTYPE_STREAM(SQLSRV_ENC_BINARY));
stream_filter_append($stream, "convert.iconv.ucs-2/utf-8"); // Voila, UTF-8 can be read directly from $stream stream_filter_append($stream, "convert.iconv.ucs-2/utf-8"); // Voila, UTF-8 can be read directly from $stream
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -68,7 +70,7 @@ if (!function_exists('sqlsrv_log_set_subsystems')) {
// has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc // has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
if (ADODB_PHPVER >= 0x4300) { if (ADODB_PHPVER >= 0x4300) {
// docs say 4.2.0, but testing shows only since 4.3.0 does it work! // docs say 4.2.0, but testing shows only since 4.3.0 does it work!
ini_set('mssql.datetimeconvert',0); ini_set('mssql.datetimeconvert',0);
} else { } else {
global $ADODB_mssql_mths; // array, months must be upper-case global $ADODB_mssql_mths; // array, months must be upper-case
@@ -78,32 +80,12 @@ if (ADODB_PHPVER >= 0x4300) {
'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
} }
//---------------------------------------------------------------------------
// Call this to autoset $ADODB_mssql_date_order at the beginning of your code,
// just after you connect to the database. Supports mdy and dmy only.
// Not required for PHP 4.2.0 and above.
function AutoDetect_MSSQL_Date_Order($conn)
{
global $ADODB_mssql_date_order;
$adate = $conn->GetOne('select getdate()');
if ($adate) {
$anum = (int) $adate;
if ($anum > 0) {
if ($anum > 31) {
//ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently");
} else
$ADODB_mssql_date_order = 'dmy';
} else
$ADODB_mssql_date_order = 'mdy';
}
}
class ADODB_mssqlnative extends ADOConnection { class ADODB_mssqlnative extends ADOConnection {
var $databaseType = "mssqlnative"; var $databaseType = "mssqlnative";
var $dataProvider = "mssqlnative"; var $dataProvider = "mssqlnative";
var $replaceQuote = "''"; // string to use to replace quotes var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'"; var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d\TH:i:s'";
var $hasInsertID = true; var $hasInsertID = true;
var $substr = "substring"; var $substr = "substring";
var $length = 'len'; var $length = 'len';
@@ -111,11 +93,23 @@ class ADODB_mssqlnative extends ADOConnection {
var $poorAffectedRows = false; var $poorAffectedRows = false;
var $metaDatabasesSQL = "select name from sys.sysdatabases where name <> 'master'"; var $metaDatabasesSQL = "select name from sys.sysdatabases where name <> 'master'";
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))"; var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
var $metaColumnsSQL = # xtype==61 is datetime var $metaColumnsSQL =
"select c.name,t.name,c.length, "select c.name,
(case when c.xusertype=61 then 0 else c.xprec end), t.name as type,
(case when c.xusertype=61 then 0 else c.xscale end) c.length,
from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; c.xprec as precision,
c.xscale as scale,
c.isnullable as nullable,
c.cdefault as default_value,
c.xtype,
t.length as type_length,
sc.is_identity
from syscolumns c
join systypes t on t.xusertype=c.xusertype
join sysobjects o on o.id=c.id
join sys.tables st on st.name=o.name
join sys.columns sc on sc.object_id = st.object_id and sc.name=c.name
where o.name='%s'";
var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $hasGenID = true; var $hasGenID = true;
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
@@ -130,32 +124,61 @@ class ADODB_mssqlnative extends ADOConnection {
var $uniqueOrderBy = true; var $uniqueOrderBy = true;
var $_bindInputArray = true; var $_bindInputArray = true;
var $_dropSeqSQL = "drop table %s"; var $_dropSeqSQL = "drop table %s";
var $connectionInfo = array();
var $sequences = false;
var $mssql_version = '';
function ADODB_mssqlnative() function __construct()
{ {
if ($this->debug) { if ($this->debug) {
error_log("<pre>"); ADOConnection::outp("<pre>");
sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL ); sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL ); sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL); sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
sqlsrv_configure('warnings_return_as_errors', 0); sqlsrv_configure('WarningsReturnAsErrors', 0);
} else { } else {
sqlsrv_set_error_handling(0); sqlsrv_set_error_handling(0);
sqlsrv_log_set_severity(0); sqlsrv_log_set_severity(0);
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL); sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
sqlsrv_configure('warnings_return_as_errors', 0); sqlsrv_configure('WarningsReturnAsErrors', 0);
} }
} }
function ServerVersion() {
$data = $this->ServerInfo();
if (preg_match('/^09/',$data['version'])){
/*
* SQL Server 2005
*/
$this->mssql_version = 9;
} elseif (preg_match('/^10/',$data['version'])){
/*
* SQL Server 2008
*/
$this->mssql_version = 10;
} elseif (preg_match('/^11/',$data['version'])){
/*
* SQL Server 2012
*/
$this->mssql_version = 11;
} else
die("SQL SERVER VERSION {$data['version']} NOT SUPPORTED IN mssqlnative DRIVER");
}
function ServerInfo() function ServerInfo() {
{
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
static $arr = false;
if (is_array($arr))
return $arr;
if ($this->fetchMode === false) { if ($this->fetchMode === false) {
$savem = $ADODB_FETCH_MODE; $savem = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM; $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
} elseif ($this->fetchMode >=0 && $this->fetchMode <=2) {
$savem = $this->fetchMode;
} else } else
$savem = $this->SetFetchMode(ADODB_FETCH_NUM); $savem = $this->SetFetchMode(ADODB_FETCH_NUM);
$arrServerInfo = sqlsrv_server_info($this->_connectionID); $arrServerInfo = sqlsrv_server_info($this->_connectionID);
$ADODB_FETCH_MODE = $savem;
$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase']; $arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
$arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']); $arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
return $arr; return $arr;
@@ -173,23 +196,58 @@ class ADODB_mssqlnative extends ADOConnection {
// the same scope. A scope is a module -- a stored procedure, trigger, // the same scope. A scope is a module -- a stored procedure, trigger,
// function, or batch. Thus, two statements are in the same scope if // function, or batch. Thus, two statements are in the same scope if
// they are in the same stored procedure, function, or batch. // they are in the same stored procedure, function, or batch.
return $this->GetOne($this->identitySQL); return $this->lastInsertID;
} }
function _affectedrows() function _affectedrows()
{ {
return @sqlsrv_rows_affected($this->_queryID); if ($this->_queryID)
return sqlsrv_rows_affected($this->_queryID);
}
function GenID($seq='adodbseq',$start=1) {
if (!$this->mssql_version)
$this->ServerVersion();
switch($this->mssql_version){
case 9:
case 10:
return $this->GenID2008();
break;
case 11:
return $this->GenID2012();
break;
}
} }
function CreateSequence($seq='adodbseq',$start=1) function CreateSequence($seq='adodbseq',$start=1)
{ {
if($this->debug) error_log("<hr>CreateSequence($seq,$start)"); if (!$this->mssql_vesion)
$this->ServerVersion();
switch($this->mssql_version){
case 9:
case 10:
return $this->CreateSequence2008();
break;
case 11:
return $this->CreateSequence2012();
break;
}
}
/**
* For Server 2005,2008, duplicate a sequence with an identity table
*/
function CreateSequence2008($seq='adodbseq',$start=1)
{
if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
sqlsrv_begin_transaction($this->_connectionID); sqlsrv_begin_transaction($this->_connectionID);
$start -= 1; $start -= 1;
$this->Execute("create table $seq (id int)");//was float(53) $this->Execute("create table $seq (id int)");//was float(53)
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
if (!$ok) { if (!$ok) {
if($this->debug) error_log("<hr>Error: ROLLBACK"); if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
sqlsrv_rollback($this->_connectionID); sqlsrv_rollback($this->_connectionID);
return false; return false;
} }
@@ -197,25 +255,68 @@ class ADODB_mssqlnative extends ADOConnection {
return true; return true;
} }
function GenID($seq='adodbseq',$start=1) /**
* Proper Sequences Only available to Server 2012 and up
*/
function CreateSequence2012($seq='adodb',$start=1){
if (!$this->sequences){
$sql = "SELECT name FROM sys.sequences";
$this->sequences = $this->GetCol($sql);
}
$ok = $this->Execute("CREATE SEQUENCE $seq START WITH $start INCREMENT BY 1");
if (!$ok)
die("CANNOT CREATE SEQUENCE" . print_r(sqlsrv_errors(),true));
$this->sequences[] = $seq;
}
/**
* For Server 2005,2008, duplicate a sequence with an identity table
*/
function GenID2008($seq='adodbseq',$start=1)
{ {
if($this->debug) error_log("<hr>GenID($seq,$start)"); if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
sqlsrv_begin_transaction($this->_connectionID); sqlsrv_begin_transaction($this->_connectionID);
$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
if (!$ok) { if (!$ok) {
$this->Execute("create table $seq (id int)"); $start -= 1;
$this->Execute("create table $seq (id int)");//was float(53)
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
if (!$ok) { if (!$ok) {
if($this->debug) error_log("<hr>Error: ROLLBACK"); if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
sqlsrv_rollback($this->_connectionID); sqlsrv_rollback($this->_connectionID);
return false; return false;
} }
sqlsrv_commit($this->_connectionID);
return $start;
} }
$num = $this->GetOne("select id from $seq"); $num = $this->GetOne("select id from $seq");
sqlsrv_commit($this->_connectionID); sqlsrv_commit($this->_connectionID);
if($this->debug) error_log(" Returning: $num"); return true;
}
/**
* Only available to Server 2012 and up
* Cannot do this the normal adodb way by trapping an error if the
* sequence does not exist because sql server will auto create a
* sequence with the starting number of -9223372036854775808
*/
function GenID2012($seq='adodbseq',$start=1)
{
/*
* First time in create an array of sequence names that we
* can use in later requests to see if the sequence exists
* the overhead is creating a list of sequences every time
* we need access to at least 1. If we really care about
* performance, we could maybe flag a 'nocheck' class variable
*/
if (!$this->sequences){
$sql = "SELECT name FROM sys.sequences";
$this->sequences = $this->GetCol($sql);
}
if (!is_array($this->sequences)
|| is_array($this->sequences) && !in_array($seq,$this->sequences)){
$this->CreateSequence2012($seq='adodbseq',$start=1);
}
$num = $this->GetOne("SELECT NEXT VALUE FOR $seq");
return $num; return $num;
} }
@@ -284,7 +385,7 @@ class ADODB_mssqlnative extends ADOConnection {
{ {
if ($this->transOff) return true; if ($this->transOff) return true;
$this->transCnt += 1; $this->transCnt += 1;
if ($this->debug) error_log('<hr>begin transaction'); if ($this->debug) ADOConnection::outp('<hr>begin transaction');
sqlsrv_begin_transaction($this->_connectionID); sqlsrv_begin_transaction($this->_connectionID);
return true; return true;
} }
@@ -292,7 +393,7 @@ class ADODB_mssqlnative extends ADOConnection {
function CommitTrans($ok=true) function CommitTrans($ok=true)
{ {
if ($this->transOff) return true; if ($this->transOff) return true;
if ($this->debug) error_log('<hr>commit transaction'); if ($this->debug) ADOConnection::outp('<hr>commit transaction');
if (!$ok) return $this->RollbackTrans(); if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1; if ($this->transCnt) $this->transCnt -= 1;
sqlsrv_commit($this->_connectionID); sqlsrv_commit($this->_connectionID);
@@ -301,7 +402,7 @@ class ADODB_mssqlnative extends ADOConnection {
function RollbackTrans() function RollbackTrans()
{ {
if ($this->transOff) return true; if ($this->transOff) return true;
if ($this->debug) error_log('<hr>rollback transaction'); if ($this->debug) ADOConnection::outp('<hr>rollback transaction');
if ($this->transCnt) $this->transCnt -= 1; if ($this->transCnt) $this->transCnt -= 1;
sqlsrv_rollback($this->_connectionID); sqlsrv_rollback($this->_connectionID);
return true; return true;
@@ -377,15 +478,22 @@ class ADODB_mssqlnative extends ADOConnection {
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{ {
if (!function_exists('sqlsrv_connect')) return null; if (!function_exists('sqlsrv_connect')) return null;
$connectionInfo = array("Database"=>$argDatabasename,'UID'=>$argUsername,'PWD'=>$argPassword); $connectionInfo = $this->connectionInfo;
if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true)); $connectionInfo["Database"]=$argDatabasename;
//if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID)); $connectionInfo["UID"]=$argUsername;
$connectionInfo["PWD"]=$argPassword;
foreach ($this->connectionParameters as $parameter=>$value)
$connectionInfo[$parameter] = $value;
if ($this->debug) ADOConnection::outp("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
//if ($this->debug) ADOConnection::outp("<hr>_connectionID before: ".serialize($this->_connectionID));
if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) { if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
if ($this->debug) error_log( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true)); if ($this->debug) ADOConnection::outp( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
return false; return false;
} }
//if ($this->debug) error_log(" _connectionID after: ".serialize($this->_connectionID)); //if ($this->debug) ADOConnection::outp(" _connectionID after: ".serialize($this->_connectionID));
//if ($this->debug) error_log("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>"); //if ($this->debug) ADOConnection::outp("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>");
return true; return true;
} }
@@ -398,6 +506,8 @@ class ADODB_mssqlnative extends ADOConnection {
function Prepare($sql) function Prepare($sql)
{ {
return $sql; // prepare does not work properly with bind parameters as bind parameters are managed by sqlsrv_prepare!
$stmt = sqlsrv_prepare( $this->_connectionID, $sql); $stmt = sqlsrv_prepare( $this->_connectionID, $sql);
if (!$stmt) return $sql; if (!$stmt) return $sql;
return array($sql,$stmt); return array($sql,$stmt);
@@ -454,23 +564,32 @@ class ADODB_mssqlnative extends ADOConnection {
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
$this->_errorMsg = false; $this->_errorMsg = false;
if (is_array($inputarr)) {
$rez = sqlsrv_query($this->_connectionID,$sql,$inputarr); if (is_array($sql)) $sql = $sql[1];
} else if (is_array($sql)) {
$rez = sqlsrv_query($this->_connectionID,$sql[1],$inputarr); $insert = false;
// handle native driver flaw for retrieving the last insert ID
if(preg_match('/^\W*insert\s(?:(?:(?:\'\')*\'[^\']+\'(?:\'\')*)|[^;\'])*;?$/i', $sql)) {
$insert = true;
$sql .= '; '.$this->identitySQL; // select scope_identity()
}
if($inputarr) {
$rez = sqlsrv_query($this->_connectionID, $sql, $inputarr);
} else { } else {
$rez = sqlsrv_query($this->_connectionID,$sql); $rez = sqlsrv_query($this->_connectionID,$sql);
} }
if ($this->debug) error_log("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));//"<hr>connection: ".serialize($this->_connectionID)
//fix for returning true on anything besides select statements if ($this->debug) ADOConnection::outp("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));
if (is_array($sql)) $sql = $sql[1];
$sql = ltrim($sql); if(!$rez) {
if(stripos($sql, 'SELECT') !== 0 && $rez !== false) { $rez = false;
if ($this->debug) error_log(" isn't a select query, returning boolean true"); } else if ($insert) {
return true; // retrieve the last insert ID (where applicable)
while ( sqlsrv_next_result($rez) ) {
sqlsrv_fetch($rez);
$this->lastInsertID = sqlsrv_get_field($rez, 0);
}
} }
//end fix
if(!$rez) $rez = false;
return $rez; return $rez;
} }
@@ -486,15 +605,15 @@ class ADODB_mssqlnative extends ADOConnection {
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v) static function UnixDate($v)
{ {
return ADORecordSet_array_mssql::UnixDate($v); return ADORecordSet_array_mssqlnative::UnixDate($v);
} }
static function UnixTimeStamp($v) static function UnixTimeStamp($v)
{ {
return ADORecordSet_array_mssql::UnixTimeStamp($v); return ADORecordSet_array_mssqlnative::UnixTimeStamp($v);
} }
function &MetaIndexes($table,$primary=false) function MetaIndexes($table,$primary=false, $owner = false)
{ {
$table = $this->qstr($table); $table = $this->qstr($table);
@@ -592,7 +711,7 @@ class ADODB_mssqlnative extends ADOConnection {
// "Stein-Aksel Basma" <basma@accelero.no> // "Stein-Aksel Basma" <basma@accelero.no>
// tested with MSSQL 2000 // tested with MSSQL 2000
function &MetaPrimaryKeys($table) function MetaPrimaryKeys($table, $owner=false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -617,7 +736,7 @@ class ADODB_mssqlnative extends ADOConnection {
} }
function &MetaTables($ttype=false,$showSchema=false,$mask=false) function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
if ($mask) { if ($mask) {
$save = $this->metaTablesSQL; $save = $this->metaTablesSQL;
@@ -631,11 +750,92 @@ class ADODB_mssqlnative extends ADOConnection {
} }
return $ret; return $ret;
} }
function MetaColumns($table, $upper=true, $schema=false){
# start adg
static $cached_columns = array();
if ($this->cachedSchemaFlush)
$cached_columns = array();
if (array_key_exists($table,$cached_columns)){
return $cached_columns[$table];
}
# end adg
if (!$this->mssql_version)
$this->ServerVersion();
$this->_findschema($table,$schema);
if ($schema) {
$dbName = $this->database;
$this->SelectDB($schema);
}
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if ($schema) {
$this->SelectDB($dbName);
}
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
$false = false;
return $false;
}
$retarr = array();
while (!$rs->EOF){
$fld = new ADOFieldObject();
if (array_key_exists(0,$rs->fields)) {
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
$fld->max_length = $rs->fields[2];
$fld->precision = $rs->fields[3];
$fld->scale = $rs->fields[4];
$fld->not_null =!$rs->fields[5];
$fld->has_default = $rs->fields[6];
$fld->xtype = $rs->fields[7];
$fld->type_length = $rs->fields[8];
$fld->auto_increment= $rs->fields[9];
} else {
$fld->name = $rs->fields['name'];
$fld->type = $rs->fields['type'];
$fld->max_length = $rs->fields['length'];
$fld->precision = $rs->fields['precision'];
$fld->scale = $rs->fields['scale'];
$fld->not_null =!$rs->fields['nullable'];
$fld->has_default = $rs->fields['default_value'];
$fld->xtype = $rs->fields['xtype'];
$fld->type_length = $rs->fields['type_length'];
$fld->auto_increment= $rs->fields['is_identity'];
}
if ($save == ADODB_FETCH_NUM)
$retarr[] = $fld;
else
$retarr[strtoupper($fld->name)] = $fld;
$rs->MoveNext();
}
$rs->Close();
# start adg
$cached_columns[$table] = $retarr;
# end adg
return $retarr;
}
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_mssqlnative extends ADORecordSet { class ADORecordset_mssqlnative extends ADORecordSet {
@@ -644,7 +844,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
var $fieldOffset = 0; var $fieldOffset = 0;
// _mths works only in non-localised system // _mths works only in non-localised system
function ADORecordset_mssqlnative($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -652,21 +852,30 @@ class ADORecordset_mssqlnative extends ADORecordSet {
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
return $this->ADORecordSet($id,$mode); return parent::__construct($id,$mode);
} }
function _initrs() function _initrs()
{ {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;
if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); # KMN # if ($this->connection->debug) ADOConnection::outp("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
/*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results." /*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results."
error_log("rowsaff: ".serialize($retRowsAff)); ADOConnection::outp("rowsaff: ".serialize($retRowsAff));
$this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/ $this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/
$this->_numOfRows = -1;//not supported $this->_numOfRows = -1;//not supported
$fieldmeta = sqlsrv_field_metadata($this->_queryID); $fieldmeta = sqlsrv_field_metadata($this->_queryID);
$this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1; $this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1;
if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); # KMN # if ($this->connection->debug) ADOConnection::outp("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
/*
* Copy the oracle method and cache the metadata at init time
*/
if ($this->_numOfFields>0) {
$this->_fieldobjs = array();
$max = $this->_numOfFields;
for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i);
}
} }
@@ -700,9 +909,10 @@ class ADORecordset_mssqlnative extends ADORecordSet {
/* Returns: an object containing field information. /* Returns: an object containing field information.
Get column information in the Recordset object. fetchField() can be used in order to obtain information about Get column information in the Recordset object. fetchField() can be used in order to obtain information about
fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
fetchField() is retrieved. */ fetchField() is retrieved.
Designed By jcortinap#jc.com.mx
function &FetchField($fieldOffset = -1) */
function _FetchField($fieldOffset = -1)
{ {
$_typeConversion = array( $_typeConversion = array(
-155 => 'datetimeoffset', -155 => 'datetimeoffset',
@@ -771,6 +981,18 @@ class ADORecordset_mssqlnative extends ADORecordSet {
return $f; return $f;
} }
/*
* Fetchfield copies the oracle method, it loads the field information
* into the _fieldobjs array once, to save multiple calls to the
* sqlsrv_field_metadata function
*
* @author KM Newnham
* @date 02/20/2013
*/
function FetchField($fieldOffset = -1)
{
return $this->_fieldobjs[$fieldOffset];
}
function _seek($row) function _seek($row)
{ {
@@ -780,16 +1002,16 @@ class ADORecordset_mssqlnative extends ADORecordSet {
// speedup // speedup
function MoveNext() function MoveNext()
{ {
if ($this->connection->debug) error_log("movenext()"); //# KMN # if ($this->connection->debug) ADOConnection::outp("movenext()");
//if ($this->connection->debug) error_log("eof (beginning): ".$this->EOF); //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (beginning): ".$this->EOF);
if ($this->EOF) return false; if ($this->EOF) return false;
$this->_currentRow++; $this->_currentRow++;
if ($this->connection->debug) error_log("_currentRow: ".$this->_currentRow); // # KMN # if ($this->connection->debug) ADOConnection::outp("_currentRow: ".$this->_currentRow);
if ($this->_fetch()) return true; if ($this->_fetch()) return true;
$this->EOF = true; $this->EOF = true;
//if ($this->connection->debug) error_log("eof (end): ".$this->EOF); //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (end): ".$this->EOF);
return false; return false;
} }
@@ -799,16 +1021,17 @@ class ADORecordset_mssqlnative extends ADORecordSet {
// also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
function _fetch($ignore_fields=false) function _fetch($ignore_fields=false)
{ {
if ($this->connection->debug) error_log("_fetch()"); # KMN # if ($this->connection->debug) ADOConnection::outp("_fetch()");
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
if ($this->fetchMode & ADODB_FETCH_NUM) { if ($this->fetchMode & ADODB_FETCH_NUM) {
if ($this->connection->debug) error_log("fetch mode: both"); //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: both");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH); $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH);
} else { } else {
if ($this->connection->debug) error_log("fetch mode: assoc"); //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: assoc");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC); $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC);
} }
if (is_array($this->fields)) {
if (ADODB_ASSOC_CASE == 0) { if (ADODB_ASSOC_CASE == 0) {
foreach($this->fields as $k=>$v) { foreach($this->fields as $k=>$v) {
$this->fields[strtolower($k)] = $v; $this->fields[strtolower($k)] = $v;
@@ -818,8 +1041,9 @@ class ADORecordset_mssqlnative extends ADORecordSet {
$this->fields[strtoupper($k)] = $v; $this->fields[strtoupper($k)] = $v;
} }
} }
}
} else { } else {
if ($this->connection->debug) error_log("fetch mode: num"); //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: num");
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC); $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC);
} }
if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based
@@ -831,18 +1055,18 @@ class ADORecordset_mssqlnative extends ADORecordSet {
$arrFixed[$key] = $value; $arrFixed[$key] = $value;
} }
} }
//if($this->connection->debug) error_log("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true)); //if($this->connection->debug) ADOConnection::outp("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true));
$this->fields = $arrFixed; $this->fields = $arrFixed;
} }
if(is_array($this->fields)) { if(is_array($this->fields)) {
foreach($this->fields as $key=>$value) { foreach($this->fields as $key=>$value) {
if (is_object($value) && method_exists($value, 'format')) {//is DateTime object if (is_object($value) && method_exists($value, 'format')) {//is DateTime object
$this->fields[$key] = $value->format("Y-m-d H:i:s"); $this->fields[$key] = $value->format("Y-m-d\TH:i:s\Z");
} }
} }
} }
if($this->fields === null) $this->fields = false; if($this->fields === null) $this->fields = false;
if ($this->connection->debug) error_log("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false)); # KMN # if ($this->connection->debug) ADOConnection::outp("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
return $this->fields; return $this->fields;
} }
@@ -850,10 +1074,13 @@ class ADORecordset_mssqlnative extends ADORecordSet {
is running. All associated result memory for the specified result identifier will automatically be freed. */ is running. All associated result memory for the specified result identifier will automatically be freed. */
function _close() function _close()
{ {
if($this->_queryID) {
$rez = sqlsrv_free_stmt($this->_queryID); $rez = sqlsrv_free_stmt($this->_queryID);
$this->_queryID = false; $this->_queryID = false;
return $rez; return $rez;
} }
return true;
}
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v) static function UnixDate($v)
@@ -869,9 +1096,9 @@ class ADORecordset_mssqlnative extends ADORecordSet {
class ADORecordSet_array_mssqlnative extends ADORecordSet_array { class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
function ADORecordSet_array_mssqlnative($id=-1,$mode=false) function __construct($id=-1,$mode=false)
{ {
$this->ADORecordSet_array($id,$mode); parent::__construct($id,$mode);
} }
// mssql uses a default date like Dec 30 2000 12:00AM // mssql uses a default date like Dec 30 2000 12:00AM
@@ -903,7 +1130,7 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
$themth = $ADODB_mssql_mths[$themth]; $themth = $ADODB_mssql_mths[$themth];
if ($themth <= 0) return false; if ($themth <= 0) return false;
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return mktime(0,0,0,$themth,$theday,$rr[3]); return adodb_mktime(0,0,0,$themth,$theday,$rr[3]);
} }
static function UnixTimeStamp($v) static function UnixTimeStamp($v)
@@ -944,32 +1171,30 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
break; break;
} }
// h-m-s-MM-DD-YY // h-m-s-MM-DD-YY
return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]); return adodb_mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
} }
} }
/* /*
Code Example 1: Code Example 1:
select object_name(constid) as constraint_name, select object_name(constid) as constraint_name,
object_name(fkeyid) as table_name, object_name(fkeyid) as table_name,
col_name(fkeyid, fkey) as column_name, col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name, object_name(rkeyid) as referenced_table_name,
col_name(rkeyid, rkey) as referenced_column_name col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys from sysforeignkeys
where object_name(fkeyid) = x where object_name(fkeyid) = x
order by constraint_name, table_name, referenced_table_name, keyno order by constraint_name, table_name, referenced_table_name, keyno
Code Example 2: Code Example 2:
select constraint_name, select constraint_name,
column_name, column_name,
ordinal_position ordinal_position
from information_schema.key_column_usage from information_schema.key_column_usage
where constraint_catalog = db_name() where constraint_catalog = db_name()
and table_name = x and table_name = x
order by constraint_name, ordinal_position order by constraint_name, ordinal_position
http://www.databasejournal.com/scripts/article.php/1440551 http://www.databasejournal.com/scripts/article.php/1440551
*/ */
?>

View File

@@ -1,17 +1,19 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* Released under both BSD license and Lesser GPL library license. * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* Whenever there is any discrepancy between the two licenses, * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* the BSD license will take precedence. * Released under both BSD license and Lesser GPL library license.
* * Whenever there is any discrepancy between the two licenses,
* Set tabs to 4 for best viewing. * the BSD license will take precedence.
* *
* Latest version is available at http://php.weblogs.com * Set tabs to 4 for best viewing.
* *
* Portable MSSQL Driver that supports || instead of + * Latest version is available at http://php.weblogs.com
* *
*/ * Portable MSSQL Driver that supports || instead of +
*
*/
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -20,7 +22,7 @@ if (!defined('ADODB_DIR')) die();
/* /*
The big difference between mssqlpo and it's parent mssql is that mssqlpo supports The big difference between mssqlpo and it's parent mssql is that mssqlpo supports
the more standard || string concatenation operator. the more standard || string concatenation operator.
*/ */
include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php'); include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
@@ -28,12 +30,7 @@ class ADODB_mssqlpo extends ADODB_mssql {
var $databaseType = "mssqlpo"; var $databaseType = "mssqlpo";
var $concat_operator = '||'; var $concat_operator = '||';
function ADODB_mssqlpo() function PrepareSP($sql, $param = true)
{
ADODB_mssql::ADODB_mssql();
}
function PrepareSP($sql)
{ {
if (!$this->_has_mssql_init) { if (!$this->_has_mssql_init) {
ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0"); ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
@@ -54,9 +51,8 @@ class ADODB_mssqlpo extends ADODB_mssql {
class ADORecordset_mssqlpo extends ADORecordset_mssql { class ADORecordset_mssqlpo extends ADORecordset_mssql {
var $databaseType = "mssqlpo"; var $databaseType = "mssqlpo";
function ADORecordset_mssqlpo($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordset_mssql($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,16 +1,22 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
MySQL code that does not support transactions. Use mysqlt if you need transactions. This driver only supports the original non-transactional MySQL driver. It
is deprected in PHP version 5.5 and removed in PHP version 7. It is deprecated
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
transactional and non-transactional updates
Requires mysql client. Works on Windows and Unix. Requires mysql client. Works on Windows and Unix.
28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com) 28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -18,12 +24,16 @@ if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_MYSQL_LAYER")) { if (! defined("_ADODB_MYSQL_LAYER")) {
define("_ADODB_MYSQL_LAYER", 1 ); define("_ADODB_MYSQL_LAYER", 1 );
class ADODB_mysql extends ADOConnection { class ADODB_mysql extends ADOConnection {
var $databaseType = 'mysql'; var $databaseType = 'mysql';
var $dataProvider = 'mysql'; var $dataProvider = 'mysql';
var $hasInsertID = true; var $hasInsertID = true;
var $hasAffectedRows = true; var $hasAffectedRows = true;
var $metaTablesSQL = "SHOW TABLES"; var $metaTablesSQL = "SELECT
TABLE_NAME,
CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA=";
var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`"; var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = true; var $hasLimit = true;
@@ -36,15 +46,35 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
var $forceNewConnect = false; var $forceNewConnect = false;
var $poorAffectedRows = true; var $poorAffectedRows = true;
var $clientFlags = 0; var $clientFlags = 0;
var $charSet = '';
var $substr = "substring"; var $substr = "substring";
var $nameQuote = '`'; /// string to use to quote identifiers and names var $nameQuote = '`'; /// string to use to quote identifiers and names
var $compat323 = false; // true if compat with mysql 3.23 var $compat323 = false; // true if compat with mysql 3.23
function ADODB_mysql() function __construct()
{ {
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
} }
// SetCharSet - switch the client encoding
function SetCharSet($charset_name)
{
if (!function_exists('mysql_set_charset')) {
return false;
}
if ($this->charSet !== $charset_name) {
$ok = @mysql_set_charset($charset_name,$this->_connectionID);
if ($ok) {
$this->charSet = $charset_name;
return true;
}
return false;
}
return true;
}
function ServerInfo() function ServerInfo()
{ {
$arr['description'] = ADOConnection::GetOne("select version()"); $arr['description'] = ADOConnection::GetOne("select version()");
@@ -57,17 +87,84 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
return " IFNULL($field, $ifNull) "; // if MySQL return " IFNULL($field, $ifNull) "; // if MySQL
} }
function MetaProcedures($NamePattern = false, $catalog = null, $schemaPattern = null)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$procedures = array ();
// get index details
$likepattern = '';
if ($NamePattern) {
$likepattern = " LIKE '".$NamePattern."'";
}
$rs = $this->Execute('SHOW PROCEDURE STATUS'.$likepattern);
if (is_object($rs)) {
// parse index data into array
while ($row = $rs->FetchRow()) {
$procedures[$row[1]] = array(
'type' => 'PROCEDURE',
'catalog' => '',
'schema' => '',
'remarks' => $row[7],
);
}
}
$rs = $this->Execute('SHOW FUNCTION STATUS'.$likepattern);
if (is_object($rs)) {
// parse index data into array
while ($row = $rs->FetchRow()) {
$procedures[$row[1]] = array(
'type' => 'FUNCTION',
'catalog' => '',
'schema' => '',
'remarks' => $row[7]
);
}
}
// restore fetchmode
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
return $procedures;
}
/**
* Retrieves a list of tables based on given criteria
*
* @param string $ttype Table type = 'TABLE', 'VIEW' or false=both (default)
* @param string $showSchema schema name, false = current schema (default)
* @param string $mask filters the table by name
*
* @return array list of tables
*/
function MetaTables($ttype=false,$showSchema=false,$mask=false) function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
$save = $this->metaTablesSQL; $save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) { if ($showSchema && is_string($showSchema)) {
$this->metaTablesSQL .= " from $showSchema"; $this->metaTablesSQL .= $this->qstr($showSchema);
} else {
$this->metaTablesSQL .= "schema()";
} }
if ($mask) { if ($mask) {
$mask = $this->qstr($mask); $mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask"; $this->metaTablesSQL .= " AND table_name LIKE $mask";
} }
$ret = ADOConnection::MetaTables($ttype,$showSchema); $ret = ADOConnection::MetaTables($ttype,$showSchema);
@@ -158,11 +255,12 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
function GetOne($sql,$inputarr=false) function GetOne($sql,$inputarr=false)
{ {
global $ADODB_GETONE_EOF;
if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) { if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) {
$rs = $this->SelectLimit($sql,1,-1,$inputarr); $rs = $this->SelectLimit($sql,1,-1,$inputarr);
if ($rs) { if ($rs) {
$rs->Close(); $rs->Close();
if ($rs->EOF) return null; if ($rs->EOF) return $ADODB_GETONE_EOF;
return reset($rs->fields); return reset($rs->fields);
} }
} else { } else {
@@ -184,10 +282,10 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
// Reference on Last_Insert_ID on the recommended way to simulate sequences // Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)"; var $_genSeqSQL = "create table if not exists %s (id int not null)";
var $_genSeqCountSQL = "select count(*) from %s"; var $_genSeqCountSQL = "select count(*) from %s";
var $_genSeq2SQL = "insert into %s values (%s)"; var $_genSeq2SQL = "insert into %s values (%s)";
var $_dropSeqSQL = "drop table %s"; var $_dropSeqSQL = "drop table if exists %s";
function CreateSequence($seqname='adodbseq',$startID=1) function CreateSequence($seqname='adodbseq',$startID=1)
{ {
@@ -351,7 +449,7 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
$fraction = $dayFraction * 24 * 3600; $fraction = $dayFraction * 24 * 3600;
return '('. $date . ' + INTERVAL ' . $fraction.' SECOND)'; return '('. $date . ' + INTERVAL ' . $fraction.' SECOND)';
// return "from_unixtime(unix_timestamp($date)+$fraction)"; // return "from_unixtime(unix_timestamp($date)+$fraction)";
} }
// returns true or false // returns true or false
@@ -501,10 +599,15 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
// returns queryID or false // returns queryID or false
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
//global $ADODB_COUNTRECS;
//if($ADODB_COUNTRECS)
return mysql_query($sql,$this->_connectionID); return mysql_query($sql,$this->_connectionID);
//else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6 /*
global $ADODB_COUNTRECS;
if($ADODB_COUNTRECS)
return mysql_query($sql,$this->_connectionID);
else
return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
*/
} }
/* Returns: the last error message from previous database operation */ /* Returns: the last error message from previous database operation */
@@ -529,6 +632,8 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
function _close() function _close()
{ {
@mysql_close($this->_connectionID); @mysql_close($this->_connectionID);
$this->charSet = '';
$this->_connectionID = false; $this->_connectionID = false;
} }
@@ -561,7 +666,9 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
if ($associative) { if ($associative) {
$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"]; $create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
} else $create_sql = $a_create_table[1]; } else {
$create_sql = $a_create_table[1];
}
$matches = array(); $matches = array();
@@ -595,19 +702,19 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
} }
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_mysql extends ADORecordSet{ class ADORecordSet_mysql extends ADORecordSet{
var $databaseType = "mysql"; var $databaseType = "mysql";
var $canSeek = true; var $canSeek = true;
function ADORecordSet_mysql($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -623,7 +730,7 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
$this->fetchMode = MYSQL_BOTH; break; $this->fetchMode = MYSQL_BOTH; break;
} }
$this->adodbFetchMode = $mode; $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function _initrs() function _initrs()
@@ -643,19 +750,23 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
if ($o) $o->binary = (strpos($f,'binary')!== false); if ($o) $o->binary = (strpos($f,'binary')!== false);
} }
else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ else { /* The $fieldOffset argument is not provided thus its -1 */
$o = @mysql_fetch_field($this->_queryID); $o = @mysql_fetch_field($this->_queryID);
if ($o) $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com) //if ($o) $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com)
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable $o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
} }
return $o; return $o;
} }
function GetRowAssoc($upper=true) function GetRowAssoc($upper = ADODB_ASSOC_CASE)
{ {
if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields; if ($this->fetchMode == MYSQL_ASSOC && $upper == ADODB_ASSOC_CASE_LOWER) {
else $row = ADORecordSet::GetRowAssoc($upper); $row = $this->fields;
}
else {
$row = ADORecordSet::GetRowAssoc($upper);
}
return $row; return $row;
} }
@@ -686,6 +797,7 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
//return adodb_movenext($this); //return adodb_movenext($this);
//if (defined('ADODB_EXTENSION')) return adodb_movenext($this); //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
$this->_updatefields();
$this->_currentRow += 1; $this->_currentRow += 1;
return true; return true;
} }
@@ -699,6 +811,7 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
function _fetch() function _fetch()
{ {
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
$this->_updatefields();
return is_array($this->fields); return is_array($this->fields);
} }
@@ -761,34 +874,18 @@ if (! defined("_ADODB_MYSQL_LAYER")) {
} }
} }
} }
class ADORecordSet_ext_mysql extends ADORecordSet_mysql { class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
function ADORecordSet_ext_mysql($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { parent::__construct($queryID,$mode);
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
} }
function MoveNext() function MoveNext()
{ {
return @adodb_movenext($this); return @adodb_movenext($this);
} }
} }
} }
?>

View File

@@ -1,17 +1,23 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
MySQL code that does not support transactions. Use mysqlt if you need transactions. This is the preferred driver for MySQL connections, and supports both transactional
and non-transactional table types. You can use this as a drop-in replacement for both
the mysql and mysqlt drivers. As of ADOdb Version 5.20.0, all other native MySQL drivers
are deprecated
Requires mysql client. Works on Windows and Unix. Requires mysql client. Works on Windows and Unix.
21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl) 21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
Based on adodb 3.40 Based on adodb 3.40
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -26,12 +32,16 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
// disable adodb extension - currently incompatible. // disable adodb extension - currently incompatible.
global $ADODB_EXTENSION; $ADODB_EXTENSION = false; global $ADODB_EXTENSION; $ADODB_EXTENSION = false;
class ADODB_mysqli extends ADOConnection { class ADODB_mysqli extends ADOConnection {
var $databaseType = 'mysqli'; var $databaseType = 'mysqli';
var $dataProvider = 'native'; var $dataProvider = 'mysql';
var $hasInsertID = true; var $hasInsertID = true;
var $hasAffectedRows = true; var $hasAffectedRows = true;
var $metaTablesSQL = "SHOW TABLES"; var $metaTablesSQL = "SELECT
TABLE_NAME,
CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA=";
var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`"; var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = true; var $hasLimit = true;
@@ -45,19 +55,18 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
var $poorAffectedRows = true; var $poorAffectedRows = true;
var $clientFlags = 0; var $clientFlags = 0;
var $substr = "substring"; var $substr = "substring";
var $port = false; var $port = 3306; //Default to 3306 to fix HHVM bug
var $socket = false; var $socket = ''; //Default to empty string to fix HHVM bug
var $_bindInputArray = false; var $_bindInputArray = false;
var $nameQuote = '`'; /// string to use to quote identifiers and names var $nameQuote = '`'; /// string to use to quote identifiers and names
var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0)); var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0));
var $arrayClass = 'ADORecordSet_array_mysqli'; var $arrayClass = 'ADORecordSet_array_mysqli';
var $multiQuery = false; var $multiQuery = false;
function ADODB_mysqli() function __construct()
{ {
// if(!extension_loaded("mysqli")) // if(!extension_loaded("mysqli"))
;//trigger_error("You must have the mysqli extension installed.", E_USER_ERROR); //trigger_error("You must have the mysqli extension installed.", E_USER_ERROR);
} }
function SetTransactionMode( $transaction_mode ) function SetTransactionMode( $transaction_mode )
@@ -86,8 +95,9 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
if (is_null($this->_connectionID)) { if (is_null($this->_connectionID)) {
// mysqli_init only fails if insufficient memory // mysqli_init only fails if insufficient memory
if ($this->debug) if ($this->debug) {
ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg()); ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
}
return false; return false;
} }
/* /*
@@ -99,13 +109,17 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
mysqli_options($this->_connectionID,$arr[0],$arr[1]); mysqli_options($this->_connectionID,$arr[0],$arr[1]);
} }
//http ://php.net/manual/en/mysqli.persistconns.php
if ($persist && PHP_VERSION > 5.2 && strncmp($argHostname,'p:',2) != 0) $argHostname = 'p:'.$argHostname;
#if (!empty($this->port)) $argHostname .= ":".$this->port; #if (!empty($this->port)) $argHostname .= ":".$this->port;
$ok = mysqli_real_connect($this->_connectionID, $ok = mysqli_real_connect($this->_connectionID,
$argHostname, $argHostname,
$argUsername, $argUsername,
$argPassword, $argPassword,
$argDatabasename, $argDatabasename,
$this->port, # PHP7 compat: port must be int. Use default port if cast yields zero
(int)$this->port != 0 ? (int)$this->port : 3306,
$this->socket, $this->socket,
$this->clientFlags); $this->clientFlags);
@@ -113,8 +127,9 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
if ($argDatabasename) return $this->SelectDB($argDatabasename); if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true; return true;
} else { } else {
if ($this->debug) if ($this->debug) {
ADOConnection::outp("Could't connect : " . $this->ErrorMsg()); ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
}
$this->_connectionID = null; $this->_connectionID = null;
return false; return false;
} }
@@ -125,7 +140,6 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{ {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true); return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
} }
// When is this used? Close old connection first? // When is this used? Close old connection first?
@@ -145,12 +159,13 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
function GetOne($sql,$inputarr=false) function GetOne($sql,$inputarr=false)
{ {
global $ADODB_GETONE_EOF; global $ADODB_GETONE_EOF;
$ret = false; $ret = false;
$rs = $this->Execute($sql,$inputarr); $rs = $this->Execute($sql,$inputarr);
if ($rs) { if ($rs) {
if ($rs->EOF) $ret = $ADODB_GETONE_EOF;
else $ret = reset($rs->fields);
$rs->Close(); $rs->Close();
if ($rs->EOF) return $ADODB_GETONE_EOF;
return reset($rs->fields);
} }
return $ret; return $ret;
} }
@@ -197,7 +212,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
return true; return true;
} }
function RowLock($tables,$where='',$col='1 as adodb_ignore') function RowLock($tables,$where='',$col='1 as adodbignore')
{ {
if ($this->transCnt==0) $this->BeginTrans(); if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where; if ($where) $where = ' where '.$where;
@@ -205,26 +220,32 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
return !empty($rs); return !empty($rs);
} }
// if magic quotes disabled, use mysql_real_escape_string() /**
// From readme.htm: * Quotes a string to be sent to the database
// Quotes a string to be sent to the database. The $magic_quotes_enabled * When there is no active connection,
// parameter may look funny, but the idea is if you are quoting a * @param string $s The string to quote
// string extracted from a POST/GET variable, then * @param boolean $magic_quotes If false, use mysqli_real_escape_string()
// pass get_magic_quotes_gpc() as the second parameter. This will * if you are quoting a string extracted from a POST/GET variable,
// ensure that the variable is not quoted twice, once by qstr and once * then pass get_magic_quotes_gpc() as the second parameter. This will
// by the magic_quotes_gpc. * ensure that the variable is not quoted twice, once by qstr() and
// * once by the magic_quotes_gpc.
//Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc()); * Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc());
* @return string Quoted string
*/
function qstr($s, $magic_quotes = false) function qstr($s, $magic_quotes = false)
{ {
if (is_null($s)) return 'NULL'; if (is_null($s)) return 'NULL';
if (!$magic_quotes) { if (!$magic_quotes) {
if (PHP_VERSION >= 5) // mysqli_real_escape_string() throws a warning when the given
// connection is invalid
if (PHP_VERSION >= 5 && $this->_connectionID) {
return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'"; return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
}
if ($this->replaceQuote[0] == '\\') if ($this->replaceQuote[0] == '\\') {
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); $s = adodb_str_replace(array('\\',"\0"), array('\\\\',"\\\0") ,$s);
return "'".str_replace("'",$this->replaceQuote,$s)."'"; }
return "'" . str_replace("'", $this->replaceQuote, $s) . "'";
} }
// undo magic quotes for " // undo magic quotes for "
$s = str_replace('\\"','"',$s); $s = str_replace('\\"','"',$s);
@@ -234,7 +255,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
function _insertid() function _insertid()
{ {
$result = @mysqli_insert_id($this->_connectionID); $result = @mysqli_insert_id($this->_connectionID);
if ($result == -1){ if ($result == -1) {
if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg()); if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
} }
return $result; return $result;
@@ -253,10 +274,10 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
// Reference on Last_Insert_ID on the recommended way to simulate sequences // Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)"; var $_genSeqSQL = "create table if not exists %s (id int not null)";
var $_genSeqCountSQL = "select count(*) from %s"; var $_genSeqCountSQL = "select count(*) from %s";
var $_genSeq2SQL = "insert into %s values (%s)"; var $_genSeq2SQL = "insert into %s values (%s)";
var $_dropSeqSQL = "drop table %s"; var $_dropSeqSQL = "drop table if exists %s";
function CreateSequence($seqname='adodbseq',$startID=1) function CreateSequence($seqname='adodbseq',$startID=1)
{ {
@@ -311,7 +332,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
} }
function MetaIndexes ($table, $primary = FALSE) function MetaIndexes ($table, $primary = FALSE, $owner = false)
{ {
// save old fetch mode // save old fetch mode
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -463,19 +484,87 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
$fraction = $dayFraction * 24 * 3600; $fraction = $dayFraction * 24 * 3600;
return $date . ' + INTERVAL ' . $fraction.' SECOND'; return $date . ' + INTERVAL ' . $fraction.' SECOND';
// return "from_unixtime(unix_timestamp($date)+$fraction)"; // return "from_unixtime(unix_timestamp($date)+$fraction)";
} }
function MetaProcedures($NamePattern = false, $catalog = null, $schemaPattern = null)
{
// save old fetch mode
global $ADODB_FETCH_MODE;
$false = false;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== FALSE) {
$savem = $this->SetFetchMode(FALSE);
}
$procedures = array ();
// get index details
$likepattern = '';
if ($NamePattern) {
$likepattern = " LIKE '".$NamePattern."'";
}
$rs = $this->Execute('SHOW PROCEDURE STATUS'.$likepattern);
if (is_object($rs)) {
// parse index data into array
while ($row = $rs->FetchRow()) {
$procedures[$row[1]] = array(
'type' => 'PROCEDURE',
'catalog' => '',
'schema' => '',
'remarks' => $row[7],
);
}
}
$rs = $this->Execute('SHOW FUNCTION STATUS'.$likepattern);
if (is_object($rs)) {
// parse index data into array
while ($row = $rs->FetchRow()) {
$procedures[$row[1]] = array(
'type' => 'FUNCTION',
'catalog' => '',
'schema' => '',
'remarks' => $row[7]
);
}
}
// restore fetchmode
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
return $procedures;
}
/**
* Retrieves a list of tables based on given criteria
*
* @param string $ttype Table type = 'TABLE', 'VIEW' or false=both (default)
* @param string $showSchema schema name, false = current schema (default)
* @param string $mask filters the table by name
*
* @return array list of tables
*/
function MetaTables($ttype=false,$showSchema=false,$mask=false) function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
$save = $this->metaTablesSQL; $save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) { if ($showSchema && is_string($showSchema)) {
$this->metaTablesSQL .= " from $showSchema"; $this->metaTablesSQL .= $this->qstr($showSchema);
} else {
$this->metaTablesSQL .= "schema()";
} }
if ($mask) { if ($mask) {
$mask = $this->qstr($mask); $mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask"; $this->metaTablesSQL .= " AND table_name LIKE $mask";
} }
$ret = ADOConnection::MetaTables($ttype,$showSchema); $ret = ADOConnection::MetaTables($ttype,$showSchema);
@@ -603,7 +692,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
// returns true or false // returns true or false
function SelectDB($dbName) function SelectDB($dbName)
{ {
// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID); // $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
$this->database = $dbName; $this->database = $dbName;
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
@@ -749,7 +838,6 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
} }
// this is a set of functions for managing client encoding - very important if the encodings // this is a set of functions for managing client encoding - very important if the encodings
// of your database and your output target (i.e. HTML) don't match // of your database and your output target (i.e. HTML) don't match
// for instance, you may have UTF8 database and server it on-site as latin1 etc. // for instance, you may have UTF8 database and server it on-site as latin1 etc.
@@ -774,41 +862,37 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
// SetCharSet - switch the client encoding // SetCharSet - switch the client encoding
function SetCharSet($charset_name) function SetCharSet($charset_name)
{ {
if (!method_exists($this->_connectionID,'set_charset')) if (!method_exists($this->_connectionID,'set_charset')) {
return false; return false;
}
if ($this->charSet !== $charset_name) { if ($this->charSet !== $charset_name) {
$if = @$this->_connectionID->set_charset($charset_name); $if = @$this->_connectionID->set_charset($charset_name);
if ($if == "0" & $this->GetCharSet() == $charset_name) { return ($if === true & $this->GetCharSet() == $charset_name);
} else {
return true; return true;
} else return false; }
} else return true;
} }
}
/*--------------------------------------------------------------------------------------
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_mysqli extends ADORecordSet{ class ADORecordSet_mysqli extends ADORecordSet{
var $databaseType = "mysqli"; var $databaseType = "mysqli";
var $canSeek = true; var $canSeek = true;
function ADORecordSet_mysqli($queryID, $mode = false) function __construct($queryID, $mode = false)
{
if ($mode === false)
{ {
if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE;
} }
switch ($mode) switch ($mode) {
{
case ADODB_FETCH_NUM: case ADODB_FETCH_NUM:
$this->fetchMode = MYSQLI_NUM; $this->fetchMode = MYSQLI_NUM;
break; break;
@@ -822,7 +906,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
break; break;
} }
$this->adodbFetchMode = $mode; $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function _initrs() function _initrs()
@@ -833,25 +917,25 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
$this->_numOfFields = @mysqli_num_fields($this->_queryID); $this->_numOfFields = @mysqli_num_fields($this->_queryID);
} }
/* /*
1 = MYSQLI_NOT_NULL_FLAG 1 = MYSQLI_NOT_NULL_FLAG
2 = MYSQLI_PRI_KEY_FLAG 2 = MYSQLI_PRI_KEY_FLAG
4 = MYSQLI_UNIQUE_KEY_FLAG 4 = MYSQLI_UNIQUE_KEY_FLAG
8 = MYSQLI_MULTIPLE_KEY_FLAG 8 = MYSQLI_MULTIPLE_KEY_FLAG
16 = MYSQLI_BLOB_FLAG 16 = MYSQLI_BLOB_FLAG
32 = MYSQLI_UNSIGNED_FLAG 32 = MYSQLI_UNSIGNED_FLAG
64 = MYSQLI_ZEROFILL_FLAG 64 = MYSQLI_ZEROFILL_FLAG
128 = MYSQLI_BINARY_FLAG 128 = MYSQLI_BINARY_FLAG
256 = MYSQLI_ENUM_FLAG 256 = MYSQLI_ENUM_FLAG
512 = MYSQLI_AUTO_INCREMENT_FLAG 512 = MYSQLI_AUTO_INCREMENT_FLAG
1024 = MYSQLI_TIMESTAMP_FLAG 1024 = MYSQLI_TIMESTAMP_FLAG
2048 = MYSQLI_SET_FLAG 2048 = MYSQLI_SET_FLAG
32768 = MYSQLI_NUM_FLAG 32768 = MYSQLI_NUM_FLAG
16384 = MYSQLI_PART_KEY_FLAG 16384 = MYSQLI_PART_KEY_FLAG
32768 = MYSQLI_GROUP_FLAG 32768 = MYSQLI_GROUP_FLAG
65536 = MYSQLI_UNIQUE_FLAG 65536 = MYSQLI_UNIQUE_FLAG
131072 = MYSQLI_BINCMP_FLAG 131072 = MYSQLI_BINCMP_FLAG
*/ */
function FetchField($fieldOffset = -1) function FetchField($fieldOffset = -1)
{ {
@@ -861,6 +945,11 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
} }
$o = @mysqli_fetch_field($this->_queryID); $o = @mysqli_fetch_field($this->_queryID);
if (!$o) return false; if (!$o) return false;
//Fix for HHVM
if ( !isset($o->flags) ) {
$o->flags = 0;
}
/* Properties of an ADOFieldObject as set by MetaColumns */ /* Properties of an ADOFieldObject as set by MetaColumns */
$o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG; $o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
$o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG; $o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
@@ -872,10 +961,11 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
return $o; return $o;
} }
function GetRowAssoc($upper = true) function GetRowAssoc($upper = ADODB_ASSOC_CASE)
{ {
if ($this->fetchMode == MYSQLI_ASSOC && !$upper) if ($this->fetchMode == MYSQLI_ASSOC && $upper == ADODB_ASSOC_CASE_LOWER) {
return $this->fields; return $this->fields;
}
$row = ADORecordSet::GetRowAssoc($upper); $row = ADORecordSet::GetRowAssoc($upper);
return $row; return $row;
} }
@@ -883,8 +973,9 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
/* Use associative array to get fields array */ /* Use associative array to get fields array */
function Fields($colname) function Fields($colname)
{ {
if ($this->fetchMode != MYSQLI_NUM) if ($this->fetchMode != MYSQLI_NUM) {
return @$this->fields[$colname]; return @$this->fields[$colname];
}
if (!$this->bind) { if (!$this->bind) {
$this->bind = array(); $this->bind = array();
@@ -898,11 +989,9 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
function _seek($row) function _seek($row)
{ {
if ($this->_numOfRows == 0) if ($this->_numOfRows == 0 || $row < 0) {
return false;
if ($row < 0)
return false; return false;
}
mysqli_data_seek($this->_queryID, $row); mysqli_data_seek($this->_queryID, $row);
$this->EOF = false; $this->EOF = false;
@@ -945,7 +1034,10 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
$this->_currentRow++; $this->_currentRow++;
$this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode); $this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
if (is_array($this->fields)) return true; if (is_array($this->fields)) {
$this->_updatefields();
return true;
}
$this->EOF = true; $this->EOF = true;
return false; return false;
} }
@@ -953,6 +1045,7 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
function _fetch() function _fetch()
{ {
$this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode); $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
$this->_updatefields();
return is_array($this->fields); return is_array($this->fields);
} }
@@ -961,48 +1054,46 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
//if results are attached to this pointer from Stored Proceedure calls, the next standard query will die 2014 //if results are attached to this pointer from Stored Proceedure calls, the next standard query will die 2014
//only a problem with persistant connections //only a problem with persistant connections
//mysqli_next_result($this->connection->_connectionID); trashes the DB side attached results. if($this->connection->_connectionID) {
while(mysqli_more_results($this->connection->_connectionID)){ while(mysqli_more_results($this->connection->_connectionID)){
@mysqli_next_result($this->connection->_connectionID); mysqli_next_result($this->connection->_connectionID);
}
} }
//Because you can have one attached result, without tripping mysqli_more_results if($this->_queryID instanceof mysqli_result) {
@mysqli_next_result($this->connection->_connectionID);
mysqli_free_result($this->_queryID); mysqli_free_result($this->_queryID);
}
$this->_queryID = false; $this->_queryID = false;
} }
/* /*
0 = MYSQLI_TYPE_DECIMAL 0 = MYSQLI_TYPE_DECIMAL
1 = MYSQLI_TYPE_CHAR 1 = MYSQLI_TYPE_CHAR
1 = MYSQLI_TYPE_TINY 1 = MYSQLI_TYPE_TINY
2 = MYSQLI_TYPE_SHORT 2 = MYSQLI_TYPE_SHORT
3 = MYSQLI_TYPE_LONG 3 = MYSQLI_TYPE_LONG
4 = MYSQLI_TYPE_FLOAT 4 = MYSQLI_TYPE_FLOAT
5 = MYSQLI_TYPE_DOUBLE 5 = MYSQLI_TYPE_DOUBLE
6 = MYSQLI_TYPE_NULL 6 = MYSQLI_TYPE_NULL
7 = MYSQLI_TYPE_TIMESTAMP 7 = MYSQLI_TYPE_TIMESTAMP
8 = MYSQLI_TYPE_LONGLONG 8 = MYSQLI_TYPE_LONGLONG
9 = MYSQLI_TYPE_INT24 9 = MYSQLI_TYPE_INT24
10 = MYSQLI_TYPE_DATE 10 = MYSQLI_TYPE_DATE
11 = MYSQLI_TYPE_TIME 11 = MYSQLI_TYPE_TIME
12 = MYSQLI_TYPE_DATETIME 12 = MYSQLI_TYPE_DATETIME
13 = MYSQLI_TYPE_YEAR 13 = MYSQLI_TYPE_YEAR
14 = MYSQLI_TYPE_NEWDATE 14 = MYSQLI_TYPE_NEWDATE
247 = MYSQLI_TYPE_ENUM 247 = MYSQLI_TYPE_ENUM
248 = MYSQLI_TYPE_SET 248 = MYSQLI_TYPE_SET
249 = MYSQLI_TYPE_TINY_BLOB 249 = MYSQLI_TYPE_TINY_BLOB
250 = MYSQLI_TYPE_MEDIUM_BLOB 250 = MYSQLI_TYPE_MEDIUM_BLOB
251 = MYSQLI_TYPE_LONG_BLOB 251 = MYSQLI_TYPE_LONG_BLOB
252 = MYSQLI_TYPE_BLOB 252 = MYSQLI_TYPE_BLOB
253 = MYSQLI_TYPE_VAR_STRING 253 = MYSQLI_TYPE_VAR_STRING
254 = MYSQLI_TYPE_STRING 254 = MYSQLI_TYPE_STRING
255 = MYSQLI_TYPE_GEOMETRY 255 = MYSQLI_TYPE_GEOMETRY
*/ */
function MetaType($t, $len = -1, $fieldobj = false) function MetaType($t, $len = -1, $fieldobj = false)
{ {
@@ -1036,7 +1127,6 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
case 'MEDIUMTEXT': case 'MEDIUMTEXT':
return 'X'; return 'X';
// php_mysql extension always returns 'blob' even if 'text' // php_mysql extension always returns 'blob' even if 'text'
// so we have to check whether binary... // so we have to check whether binary...
case 'IMAGE': case 'IMAGE':
@@ -1047,13 +1137,12 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
case MYSQLI_TYPE_BLOB : case MYSQLI_TYPE_BLOB :
case MYSQLI_TYPE_LONG_BLOB : case MYSQLI_TYPE_LONG_BLOB :
case MYSQLI_TYPE_MEDIUM_BLOB : case MYSQLI_TYPE_MEDIUM_BLOB :
return !empty($fieldobj->binary) ? 'B' : 'X'; return !empty($fieldobj->binary) ? 'B' : 'X';
case 'YEAR': case 'YEAR':
case 'DATE': case 'DATE':
case MYSQLI_TYPE_DATE : case MYSQLI_TYPE_DATE :
case MYSQLI_TYPE_YEAR : case MYSQLI_TYPE_YEAR :
return 'D'; return 'D';
case 'TIME': case 'TIME':
@@ -1064,7 +1153,6 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
case MYSQLI_TYPE_NEWDATE : case MYSQLI_TYPE_NEWDATE :
case MYSQLI_TYPE_TIME : case MYSQLI_TYPE_TIME :
case MYSQLI_TYPE_TIMESTAMP : case MYSQLI_TYPE_TIMESTAMP :
return 'T'; return 'T';
case 'INT': case 'INT':
@@ -1079,17 +1167,14 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
case MYSQLI_TYPE_LONGLONG : case MYSQLI_TYPE_LONGLONG :
case MYSQLI_TYPE_SHORT : case MYSQLI_TYPE_SHORT :
case MYSQLI_TYPE_TINY : case MYSQLI_TYPE_TINY :
if (!empty($fieldobj->primary_key)) return 'R'; if (!empty($fieldobj->primary_key)) return 'R';
return 'I'; return 'I';
// Added floating-point types // Added floating-point types
// Maybe not necessery. // Maybe not necessery.
case 'FLOAT': case 'FLOAT':
case 'DOUBLE': case 'DOUBLE':
// case 'DOUBLE PRECISION': // case 'DOUBLE PRECISION':
case 'DECIMAL': case 'DECIMAL':
case 'DEC': case 'DEC':
case 'FIXED': case 'FIXED':
@@ -1100,15 +1185,15 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
} // function } // function
} // rs class } // rs class
} }
class ADORecordSet_array_mysqli extends ADORecordSet_array { class ADORecordSet_array_mysqli extends ADORecordSet_array {
function ADORecordSet_array_mysqli($id=-1,$mode=false) function __construct($id=-1,$mode=false)
{ {
$this->ADORecordSet_array($id,$mode); parent::__construct($id,$mode);
} }
function MetaType($t, $len = -1, $fieldobj = false) function MetaType($t, $len = -1, $fieldobj = false)
@@ -1143,7 +1228,6 @@ class ADORecordSet_array_mysqli extends ADORecordSet_array {
case 'MEDIUMTEXT': case 'MEDIUMTEXT':
return 'X'; return 'X';
// php_mysql extension always returns 'blob' even if 'text' // php_mysql extension always returns 'blob' even if 'text'
// so we have to check whether binary... // so we have to check whether binary...
case 'IMAGE': case 'IMAGE':
@@ -1196,7 +1280,7 @@ class ADORecordSet_array_mysqli extends ADORecordSet_array {
// Maybe not necessery. // Maybe not necessery.
case 'FLOAT': case 'FLOAT':
case 'DOUBLE': case 'DOUBLE':
// case 'DOUBLE PRECISION': // case 'DOUBLE PRECISION':
case 'DECIMAL': case 'DECIMAL':
case 'DEC': case 'DEC':
case 'FIXED': case 'FIXED':
@@ -1207,5 +1291,3 @@ class ADORecordSet_array_mysqli extends ADORecordSet_array {
} // function } // function
} }
?>

View File

@@ -1,7 +1,9 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -10,8 +12,13 @@
MySQL code that supports transactions. For MySQL 3.23 or later. MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com> Code from James Poon <jpoon88@yahoo.com>
This driver extends the deprecated mysql driver, and was originally designed to be a
portable driver in the same manner as oci8po and mssqlpo. Its functionality
is exactly duplicated in the mysqlt driver, which is itself deprecated.
This driver will be removed in ADOdb version 6.0.0.
Requires mysql client. Works on Windows and Unix. Requires mysql client. Works on Windows and Unix.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -25,7 +32,7 @@ class ADODB_mysqlt extends ADODB_mysql {
var $hasTransactions = true; var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly var $autoRollback = true; // apparently mysql does not autorollback properly
function ADODB_mysqlt() function __construct()
{ {
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
} }
@@ -59,7 +66,7 @@ class ADODB_mysqlt extends ADODB_mysql {
return true; return true;
} }
function RowLock($tables,$where='',$col='1 as adodb_ignore') function RowLock($tables,$where='',$col='1 as adodbignore')
{ {
if ($this->transCnt==0) $this->BeginTrans(); if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where; if ($where) $where = ' where '.$where;
@@ -72,7 +79,7 @@ class ADODB_mysqlt extends ADODB_mysql {
class ADORecordSet_mysqlt extends ADORecordSet_mysql{ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt"; var $databaseType = "mysqlt";
function ADORecordSet_mysqlt($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -90,7 +97,7 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
} }
$this->adodbFetchMode = $mode; $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function MoveNext() function MoveNext()
@@ -109,24 +116,9 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
function ADORecordSet_ext_mysqlt($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { parent::__construct($queryID,$mode);
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
} }
function MoveNext() function MoveNext()
@@ -134,5 +126,3 @@ class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
return adodb_movenext($this); return adodb_movenext($this);
} }
} }
?>

View File

@@ -1,17 +1,21 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
MySQL code that supports transactions. For MySQL 3.23 or later. This driver only supports the original MySQL driver in transactional mode. It
Code from James Poon <jpoon88@yahoo.com> is deprected in PHP version 5.5 and removed in PHP version 7. It is deprecated
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
transactional and non-transactional updates
Requires mysql client. Works on Windows and Unix. Requires mysql client. Works on Windows and Unix.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -25,7 +29,7 @@ class ADODB_mysqlt extends ADODB_mysql {
var $hasTransactions = true; var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly var $autoRollback = true; // apparently mysql does not autorollback properly
function ADODB_mysqlt() function __construct()
{ {
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
} }
@@ -33,7 +37,7 @@ class ADODB_mysqlt extends ADODB_mysql {
/* set transaction mode /* set transaction mode
SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
{ READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
*/ */
function SetTransactionMode( $transaction_mode ) function SetTransactionMode( $transaction_mode )
@@ -76,7 +80,7 @@ class ADODB_mysqlt extends ADODB_mysql {
return $ok ? true : false; return $ok ? true : false;
} }
function RowLock($tables,$where='',$col='1 as adodb_ignore') function RowLock($tables,$where='',$col='1 as adodbignore')
{ {
if ($this->transCnt==0) $this->BeginTrans(); if ($this->transCnt==0) $this->BeginTrans();
if ($where) $where = ' where '.$where; if ($where) $where = ' where '.$where;
@@ -89,7 +93,7 @@ class ADODB_mysqlt extends ADODB_mysql {
class ADORecordSet_mysqlt extends ADORecordSet_mysql{ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt"; var $databaseType = "mysqlt";
function ADORecordSet_mysqlt($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -107,7 +111,7 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
} }
$this->adodbFetchMode = $mode; $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function MoveNext() function MoveNext()
@@ -126,30 +130,8 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
function MoveNext() function MoveNext()
{ {
return adodb_movenext($this); return adodb_movenext($this);
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
Based on the previous postgres drivers. Based on the previous postgres drivers.
@@ -13,7 +15,7 @@
as well as added the default lengths for certain types as well as added the default lengths for certain types
Updated public variables for Netezza Updated public variables for Netezza
Still need to remove blob functions, as Netezza doesn't suppport blob Still need to remove blob functions, as Netezza doesn't suppport blob
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -48,7 +50,7 @@ class ADODB_netezza extends ADODB_postgres64 {
// http://bugs.php.net/bug.php?id=25404 // http://bugs.php.net/bug.php?id=25404
function ADODB_netezza() function __construct()
{ {
} }
@@ -132,39 +134,24 @@ class ADODB_netezza extends ADODB_postgres64 {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_netezza extends ADORecordSet_postgres64 class ADORecordSet_netezza extends ADORecordSet_postgres64
{ {
var $databaseType = "netezza"; var $databaseType = "netezza";
var $canSeek = true; var $canSeek = true;
function ADORecordSet_netezza($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { parent::__construct($queryID,$mode);
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
case ADODB_FETCH_DEFAULT:
case ADODB_FETCH_BOTH:
default: $this->fetchMode = PGSQL_BOTH; break;
}
$this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
} }
// _initrs modified to disable blob handling // _initrs modified to disable blob handling
function _initrs() function _initrs()
{ {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1; $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1;
$this->_numOfFields = @pg_numfields($this->_queryID); $this->_numOfFields = @pg_num_fields($this->_queryID);
} }
} }
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,8 @@
<?php <?php
/** /**
* @version V5.06 16 Oct 2008 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. * @version v5.20.4 30-Mar-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license. * Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses, * Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence. * the BSD license will take precedence.
@@ -10,7 +12,7 @@
* Latest version is available at http://php.weblogs.com * Latest version is available at http://php.weblogs.com
* *
* Oracle 8.0.5 driver * Oracle 8.0.5 driver
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -21,11 +23,6 @@ class ADODB_oci805 extends ADODB_oci8 {
var $databaseType = "oci805"; var $databaseType = "oci805";
var $connectSID = true; var $connectSID = true;
function ADODB_oci805()
{
$this->ADODB_oci8();
}
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{ {
// seems that oracle only supports 1 hint comment in 8i // seems that oracle only supports 1 hint comment in 8i
@@ -51,9 +48,8 @@ class ADODB_oci805 extends ADODB_oci8 {
class ADORecordset_oci805 extends ADORecordset_oci8 { class ADORecordset_oci805 extends ADORecordset_oci8 {
var $databaseType = "oci805"; var $databaseType = "oci805";
function ADORecordset_oci805($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordset_oci8($id,$mode); parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim. All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -15,7 +17,7 @@
Should some emulation of RecordCount() be implemented? Should some emulation of RecordCount() be implemented?
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -28,13 +30,13 @@ class ADODB_oci8po extends ADODB_oci8 {
var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net
var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"; var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')";
function ADODB_oci8po() function __construct()
{ {
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
# oci8po does not support adodb extension: adodb_movenext() # oci8po does not support adodb extension: adodb_movenext()
} }
function Param($name) function Param($name,$type='C')
{ {
return '?'; return '?';
} }
@@ -49,6 +51,11 @@ class ADODB_oci8po extends ADODB_oci8 {
return ADODB_oci8::Prepare($sql,$cursor); return ADODB_oci8::Prepare($sql,$cursor);
} }
function Execute($sql,$inputarr=false)
{
return ADOConnection::Execute($sql,$inputarr);
}
// emulate handling of parameters ? ?, replacing with :bind0 :bind1 // emulate handling of parameters ? ?, replacing with :bind0 :bind1
function _query($sql,$inputarr=false) function _query($sql,$inputarr=false)
{ {
@@ -59,11 +66,22 @@ class ADODB_oci8po extends ADODB_oci8 {
$arr['bind'.$i++] = $v; $arr['bind'.$i++] = $v;
} }
} else { } else {
// Need to identify if the ? is inside a quoted string, and if
// so not use it as a bind variable
preg_match_all('/".*\??"|\'.*\?.*?\'/', $sql, $matches);
foreach($matches[0] as $qmMatch){
$qmReplace = str_replace('?', '-QUESTIONMARK-', $qmMatch);
$sql = str_replace($qmMatch, $qmReplace, $sql);
}
$sqlarr = explode('?',$sql); $sqlarr = explode('?',$sql);
$sql = $sqlarr[0]; $sql = $sqlarr[0];
foreach($inputarr as $k => $v) { foreach($inputarr as $k => $v) {
$sql .= ":$k" . $sqlarr[++$i]; $sql .= ":$k" . $sqlarr[++$i];
} }
$sql = str_replace('-QUESTIONMARK-', '?', $sql);
} }
} }
return ADODB_oci8::_query($sql,$inputarr); return ADODB_oci8::_query($sql,$inputarr);
@@ -72,15 +90,15 @@ class ADODB_oci8po extends ADODB_oci8 {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_oci8po extends ADORecordset_oci8 { class ADORecordset_oci8po extends ADORecordset_oci8 {
var $databaseType = 'oci8po'; var $databaseType = 'oci8po';
function ADORecordset_oci8po($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
$this->ADORecordset_oci8($queryID,$mode); parent::__construct($queryID,$mode);
} }
function Fields($colname) function Fields($colname)
@@ -103,29 +121,19 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
$fld = new ADOFieldObject; $fld = new ADOFieldObject;
$fieldOffset += 1; $fieldOffset += 1;
$fld->name = OCIcolumnname($this->_queryID, $fieldOffset); $fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
if (ADODB_ASSOC_CASE == 0) $fld->name = strtolower($fld->name); if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER) {
$fld->name = strtolower($fld->name);
}
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset); $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') { if ($fld->type == 'NUMBER') {
//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
$sc = OCIColumnScale($this->_queryID, $fieldOffset); $sc = OCIColumnScale($this->_queryID, $fieldOffset);
if ($sc == 0) $fld->type = 'INT'; if ($sc == 0) {
$fld->type = 'INT';
}
} }
return $fld; return $fld;
} }
/*
function MoveNext()
{
if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
$this->_currentRow += 1;
return true;
}
if (!$this->EOF) {
$this->_currentRow += 1;
$this->EOF = true;
}
return false;
}*/
// 10% speedup to move MoveNext to child class // 10% speedup to move MoveNext to child class
function MoveNext() function MoveNext()
@@ -133,8 +141,8 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
global $ADODB_ANSI_PADDING_OFF; global $ADODB_ANSI_PADDING_OFF;
$this->_currentRow++; $this->_currentRow++;
$this->_updatefields();
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
if (!empty($ADODB_ANSI_PADDING_OFF)) { if (!empty($ADODB_ANSI_PADDING_OFF)) {
foreach($this->fields as $k => $v) { foreach($this->fields as $k => $v) {
if (is_string($v)) $this->fields[$k] = rtrim($v); if (is_string($v)) $this->fields[$k] = rtrim($v);
@@ -165,7 +173,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
$arr = array(); $arr = array();
return $arr; return $arr;
} }
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); $this->_updatefields();
$results = array(); $results = array();
$cnt = 0; $cnt = 0;
while (!$this->EOF && $nrows != $cnt) { while (!$this->EOF && $nrows != $cnt) {
@@ -176,33 +184,14 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
return $results; return $results;
} }
// Create associative array
function _updatefields()
{
if (ADODB_ASSOC_CASE == 2) return; // native
$arr = array();
$lowercase = (ADODB_ASSOC_CASE == 0);
foreach($this->fields as $k => $v) {
if (is_integer($k)) $arr[$k] = $v;
else {
if ($lowercase)
$arr[strtolower($k)] = $v;
else
$arr[strtoupper($k)] = $v;
}
}
$this->fields = $arr;
}
function _fetch() function _fetch()
{ {
$ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
if ($ret) {
global $ADODB_ANSI_PADDING_OFF; global $ADODB_ANSI_PADDING_OFF;
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
if ($ret) {
$this->_updatefields();
if (!empty($ADODB_ANSI_PADDING_OFF)) { if (!empty($ADODB_ANSI_PADDING_OFF)) {
foreach($this->fields as $k => $v) { foreach($this->fields as $k => $v) {
if (is_string($v)) $this->fields[$k] = rtrim($v); if (is_string($v)) $this->fields[$k] = rtrim($v);
@@ -213,6 +202,3 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
} }
} }
?>

View File

@@ -0,0 +1,89 @@
<?php
/*
@version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Latest version is available at http://adodb.sourceforge.net
Portable version of oci8 driver, to make it more similar to other database drivers.
The main differences are
1. that the OCI_ASSOC names are in lowercase instead of uppercase.
2. bind variables are mapped using ? instead of :<bindvar>
Should some emulation of RecordCount() be implemented?
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
class ADODB_oci8quercus extends ADODB_oci8 {
var $databaseType = 'oci8quercus';
var $dataProvider = 'oci8';
function __construct()
{
}
}
/*--------------------------------------------------------------------------------------
Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordset_oci8quercus extends ADORecordset_oci8 {
var $databaseType = 'oci8quercus';
function __construct($queryID,$mode=false)
{
parent::__construct($queryID,$mode);
}
function _FetchField($fieldOffset = -1)
{
global $QUERCUS;
$fld = new ADOFieldObject;
if (!empty($QUERCUS)) {
$fld->name = oci_field_name($this->_queryID, $fieldOffset);
$fld->type = oci_field_type($this->_queryID, $fieldOffset);
$fld->max_length = oci_field_size($this->_queryID, $fieldOffset);
//if ($fld->name == 'VAL6_NUM_12_4') $fld->type = 'NUMBER';
switch($fld->type) {
case 'string': $fld->type = 'VARCHAR'; break;
case 'real': $fld->type = 'NUMBER'; break;
}
} else {
$fieldOffset += 1;
$fld->name = oci_field_name($this->_queryID, $fieldOffset);
$fld->type = oci_field_type($this->_queryID, $fieldOffset);
$fld->max_length = oci_field_size($this->_queryID, $fieldOffset);
}
switch($fld->type) {
case 'NUMBER':
$p = oci_field_precision($this->_queryID, $fieldOffset);
$sc = oci_field_scale($this->_queryID, $fieldOffset);
if ($p != 0 && $sc == 0) $fld->type = 'INT';
$fld->scale = $p;
break;
case 'CLOB':
case 'NCLOB':
case 'BLOB':
$fld->max_length = -1;
break;
}
return $fld;
}
}

View File

@@ -1,22 +1,24 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Requires ODBC. Works on Windows and Unix. Requires ODBC. Works on Windows and Unix.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
define("_ADODB_ODBC_LAYER", 2 ); define("_ADODB_ODBC_LAYER", 2 );
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADODB_odbc extends ADOConnection { class ADODB_odbc extends ADOConnection {
@@ -39,7 +41,7 @@ class ADODB_odbc extends ADOConnection {
var $_lastAffectedRows = 0; var $_lastAffectedRows = 0;
var $uCaseTables = true; // for meta* functions, uppercase table names var $uCaseTables = true; // for meta* functions, uppercase table names
function ADODB_odbc() function __construct()
{ {
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050; $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
@@ -52,9 +54,13 @@ class ADODB_odbc extends ADOConnection {
if (!function_exists('odbc_connect')) return null; if (!function_exists('odbc_connect')) return null;
if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') { if (!empty($argDatabasename) && stristr($argDSN, 'Database=') === false) {
ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); $argDSN = trim($argDSN);
$endDSN = substr($argDSN, strlen($argDSN) - 1);
if ($endDSN != ';') $argDSN .= ';';
$argDSN .= 'Database='.$argDatabasename;
} }
if (isset($php_errormsg)) $php_errormsg = ''; if (isset($php_errormsg)) $php_errormsg = '';
if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode); else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
@@ -128,7 +134,7 @@ class ADODB_odbc extends ADOConnection {
} }
var $_dropSeqSQL = 'drop table %s'; var $_dropSeqSQL = 'drop table %s';
function DropSequence($seqname) function DropSequence($seqname = 'adodbseq')
{ {
if (empty($this->_dropSeqSQL)) return false; if (empty($this->_dropSeqSQL)) return false;
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
@@ -161,6 +167,12 @@ class ADODB_odbc extends ADOConnection {
$num += 1; $num += 1;
$this->genID = $num; $this->genID = $num;
return $num; return $num;
} elseif ($this->affected_rows() == 0) {
// some drivers do not return a valid value => try with another method
$value = $this->GetOne("select id from $seq");
if ($value == $num + 1) {
return $value;
}
} }
} }
if ($fn = $this->raiseErrorFn) { if ($fn = $this->raiseErrorFn) {
@@ -230,7 +242,7 @@ class ADODB_odbc extends ADOConnection {
return $ret; return $ret;
} }
function MetaPrimaryKeys($table) function MetaPrimaryKeys($table,$owner=false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -264,7 +276,7 @@ class ADODB_odbc extends ADOConnection {
function MetaTables($ttype=false) function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -302,34 +314,34 @@ class ADODB_odbc extends ADOConnection {
return $arr2; return $arr2;
} }
/* /*
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp
/ SQL data type codes / / SQL data type codes /
#define SQL_UNKNOWN_TYPE 0 #define SQL_UNKNOWN_TYPE 0
#define SQL_CHAR 1 #define SQL_CHAR 1
#define SQL_NUMERIC 2 #define SQL_NUMERIC 2
#define SQL_DECIMAL 3 #define SQL_DECIMAL 3
#define SQL_INTEGER 4 #define SQL_INTEGER 4
#define SQL_SMALLINT 5 #define SQL_SMALLINT 5
#define SQL_FLOAT 6 #define SQL_FLOAT 6
#define SQL_REAL 7 #define SQL_REAL 7
#define SQL_DOUBLE 8 #define SQL_DOUBLE 8
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
#define SQL_DATETIME 9 #define SQL_DATETIME 9
#endif #endif
#define SQL_VARCHAR 12 #define SQL_VARCHAR 12
/ One-parameter shortcuts for date/time data types / / One-parameter shortcuts for date/time data types /
#if (ODBCVER >= 0x0300) #if (ODBCVER >= 0x0300)
#define SQL_TYPE_DATE 91 #define SQL_TYPE_DATE 91
#define SQL_TYPE_TIME 92 #define SQL_TYPE_TIME 92
#define SQL_TYPE_TIMESTAMP 93 #define SQL_TYPE_TIMESTAMP 93
#define SQL_UNICODE (-95) #define SQL_UNICODE (-95)
#define SQL_UNICODE_VARCHAR (-96) #define SQL_UNICODE_VARCHAR (-96)
#define SQL_UNICODE_LONGVARCHAR (-97) #define SQL_UNICODE_LONGVARCHAR (-97)
*/ */
function ODBCTypes($t) function ODBCTypes($t)
{ {
switch ((integer)$t) { switch ((integer)$t) {
@@ -586,7 +598,7 @@ class ADODB_odbc extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_odbc extends ADORecordSet { class ADORecordSet_odbc extends ADORecordSet {
@@ -596,7 +608,7 @@ class ADORecordSet_odbc extends ADORecordSet {
var $useFetchArray; var $useFetchArray;
var $_has_stupid_odbc_fetch_api_change; var $_has_stupid_odbc_fetch_api_change;
function ADORecordSet_odbc($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -609,7 +621,7 @@ class ADORecordSet_odbc extends ADORecordSet {
// the following is required for mysql odbc driver in 4.3.1 -- why? // the following is required for mysql odbc driver in 4.3.1 -- why?
$this->EOF = false; $this->EOF = false;
$this->_currentRow = -1; $this->_currentRow = -1;
//$this->ADORecordSet($id); //parent::__construct($id);
} }
@@ -673,7 +685,7 @@ class ADORecordSet_odbc extends ADORecordSet {
$this->fetchMode = $savem; $this->fetchMode = $savem;
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
$results = array(); $results = array();
@@ -691,17 +703,7 @@ class ADORecordSet_odbc extends ADORecordSet {
{ {
if ($this->_numOfRows != 0 && !$this->EOF) { if ($this->_numOfRows != 0 && !$this->EOF) {
$this->_currentRow++; $this->_currentRow++;
if( $this->_fetch() ) {
if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @odbc_fetch_into($this->_queryID,$this->fields);
else {
$row = 0;
$rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
}
if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
}
return true; return true;
} }
} }
@@ -712,7 +714,7 @@ class ADORecordSet_odbc extends ADORecordSet {
function _fetch() function _fetch()
{ {
$this->fields = false;
if ($this->_has_stupid_odbc_fetch_api_change) if ($this->_has_stupid_odbc_fetch_api_change)
$rez = @odbc_fetch_into($this->_queryID,$this->fields); $rez = @odbc_fetch_into($this->_queryID,$this->fields);
else { else {
@@ -721,11 +723,10 @@ class ADORecordSet_odbc extends ADORecordSet {
} }
if ($rez) { if ($rez) {
if ($this->fetchMode & ADODB_FETCH_ASSOC) { if ($this->fetchMode & ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); $this->fields = $this->GetRowAssoc();
} }
return true; return true;
} }
$this->fields = false;
return false; return false;
} }
@@ -735,4 +736,3 @@ class ADORecordSet_odbc extends ADORecordSet {
} }
} }
?>

View File

@@ -1,90 +1,92 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
DB2 data driver. Requires ODBC. DB2 data driver. Requires ODBC.
From phpdb list: From phpdb list:
Hi Andrew, Hi Andrew,
thanks a lot for your help. Today we discovered what thanks a lot for your help. Today we discovered what
our real problem was: our real problem was:
After "playing" a little bit with the php-scripts that try After "playing" a little bit with the php-scripts that try
to connect to the IBM DB2, we set the optional parameter to connect to the IBM DB2, we set the optional parameter
Cursortype when calling odbc_pconnect(....). Cursortype when calling odbc_pconnect(....).
And the exciting thing: When we set the cursor type And the exciting thing: When we set the cursor type
to SQL_CUR_USE_ODBC Cursor Type, then to SQL_CUR_USE_ODBC Cursor Type, then
the whole query speed up from 1 till 10 seconds the whole query speed up from 1 till 10 seconds
to 0.2 till 0.3 seconds for 100 records. Amazing!!! to 0.2 till 0.3 seconds for 100 records. Amazing!!!
Therfore, PHP is just almost fast as calling the DB2 Therfore, PHP is just almost fast as calling the DB2
from Servlets using JDBC (don't take too much care from Servlets using JDBC (don't take too much care
about the speed at whole: the database was on a about the speed at whole: the database was on a
completely other location, so the whole connection completely other location, so the whole connection
was made over a slow network connection). was made over a slow network connection).
I hope this helps when other encounter the same I hope this helps when other encounter the same
problem when trying to connect to DB2 from problem when trying to connect to DB2 from
PHP. PHP.
Kind regards, Kind regards,
Christian Szardenings Christian Szardenings
2 Oct 2001 2 Oct 2001
Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by
IBM's DB2 ODBC driver, so this must be a 3rd party ODBC driver. IBM's DB2 ODBC driver, so this must be a 3rd party ODBC driver.
From the IBM CLI Reference: From the IBM CLI Reference:
SQL_ATTR_ODBC_CURSORS (DB2 CLI v5) SQL_ATTR_ODBC_CURSORS (DB2 CLI v5)
This connection attribute is defined by ODBC, but is not supported by DB2 This connection attribute is defined by ODBC, but is not supported by DB2
CLI. Any attempt to set or get this attribute will result in an SQLSTATE of CLI. Any attempt to set or get this attribute will result in an SQLSTATE of
HYC00 (Driver not capable). HYC00 (Driver not capable).
A 32-bit option specifying how the Driver Manager uses the ODBC cursor A 32-bit option specifying how the Driver Manager uses the ODBC cursor
library. library.
So I guess this means the message [above] was related to using a 3rd party So I guess this means the message [above] was related to using a 3rd party
odbc driver. odbc driver.
Setting SQL_CUR_USE_ODBC Setting SQL_CUR_USE_ODBC
======================== ========================
To set SQL_CUR_USE_ODBC for drivers that require it, do this: To set SQL_CUR_USE_ODBC for drivers that require it, do this:
$db = NewADOConnection('odbc_db2'); $db = NewADOConnection('odbc_db2');
$db->curMode = SQL_CUR_USE_ODBC; $db->curMode = SQL_CUR_USE_ODBC;
$db->Connect($dsn, $userid, $pwd); $db->Connect($dsn, $userid, $pwd);
USING CLI INTERFACE USING CLI INTERFACE
=================== ===================
I have had reports that the $host and $database params have to be reversed in I have had reports that the $host and $database params have to be reversed in
Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu: Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu:
> The symptom is that if I change the database engine from postgres or any other to DB2 then the following > The symptom is that if I change the database engine from postgres or any other to DB2 then the following
> connection command becomes wrong despite being described this version to be correct in the docs. > connection command becomes wrong despite being described this version to be correct in the docs.
> >
> $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME ) > $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME )
> >
> In case of DB2 I had to swap the first and last arguments in order to connect properly. > In case of DB2 I had to swap the first and last arguments in order to connect properly.
System Error 5 System Error 5
============== ==============
IF you get a System Error 5 when trying to Connect/Load, it could be a permission problem. Give the user connecting IF you get a System Error 5 when trying to Connect/Load, it could be a permission problem. Give the user connecting
to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSERS group. to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSERS group.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -93,9 +95,9 @@ if (!defined('_ADODB_ODBC_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
} }
if (!defined('ADODB_ODBC_DB2')){ if (!defined('ADODB_ODBC_DB2')){
define('ADODB_ODBC_DB2',1); define('ADODB_ODBC_DB2',1);
class ADODB_ODBC_DB2 extends ADODB_odbc { class ADODB_ODBC_DB2 extends ADODB_odbc {
var $databaseType = "db2"; var $databaseType = "db2";
var $concat_operator = '||'; var $concat_operator = '||';
var $sysTime = 'CURRENT TIME'; var $sysTime = 'CURRENT TIME';
@@ -110,10 +112,10 @@ if (!defined('ADODB_ODBC_DB2')){
var $hasInsertID = true; var $hasInsertID = true;
var $rsPrefix = 'ADORecordset_odbc_'; var $rsPrefix = 'ADORecordset_odbc_';
function ADODB_DB2() function __construct()
{ {
if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC; if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
$this->ADODB_odbc(); parent::__construct();
} }
function IfNull( $field, $ifNull ) function IfNull( $field, $ifNull )
@@ -134,7 +136,7 @@ if (!defined('ADODB_ODBC_DB2')){
return $this->GetOne($this->identitySQL); return $this->GetOne($this->identitySQL);
} }
function RowLock($tables,$where,$col='1 as ignore') function RowLock($tables,$where,$col='1 as adodbignore')
{ {
if ($this->_autocommit) $this->BeginTrans(); if ($this->_autocommit) $this->BeginTrans();
return $this->GetOne("select $col from $tables where $where for update"); return $this->GetOne("select $col from $tables where $where for update");
@@ -278,7 +280,7 @@ if (!defined('ADODB_ODBC_DB2')){
} }
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false) function SelectLimit($sql, $nrows = -1, $offset = -1, $inputArr = false, $secs2cache = 0)
{ {
$nrows = (integer) $nrows; $nrows = (integer) $nrows;
if ($offset <= 0) { if ($offset <= 0) {
@@ -297,16 +299,16 @@ if (!defined('ADODB_ODBC_DB2')){
return $rs; return $rs;
} }
}; };
class ADORecordSet_odbc_db2 extends ADORecordSet_odbc { class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
var $databaseType = "db2"; var $databaseType = "db2";
function ADORecordSet_db2($id,$mode=false) function __construct($id,$mode=false)
{ {
$this->ADORecordSet_odbc($id,$mode); parent::__construct($id,$mode);
} }
function MetaType($t,$len=-1,$fieldobj=false) function MetaType($t,$len=-1,$fieldobj=false)
@@ -362,7 +364,6 @@ if (!defined('ADODB_ODBC_DB2')){
default: return 'N'; default: return 'N';
} }
} }
} }
} //define } //define
?>

View File

@@ -1,16 +1,18 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix. MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix.
For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3 For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -23,10 +25,15 @@ if (!defined('_ADODB_ODBC_LAYER')) {
class ADODB_odbc_mssql extends ADODB_odbc { class ADODB_odbc_mssql extends ADODB_odbc {
var $databaseType = 'odbc_mssql'; var $databaseType = 'odbc_mssql';
var $fmtDate = "'Y-m-d'"; var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'"; var $fmtTimeStamp = "'Y-m-d\TH:i:s'";
var $_bindInputArray = true; var $_bindInputArray = true;
var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE'))"; var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE'))";
var $metaColumnsSQL = "select c.name,t.name,c.length from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; var $metaColumnsSQL = # xtype==61 is datetime
"select c.name,t.name,c.length,c.isnullable, c.status,
(case when c.xusertype=61 then 0 else c.xprec end),
(case when c.xusertype=61 then 0 else c.xscale end)
from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
var $hasTop = 'top'; // support mssql/interbase SELECT TOP 10 * FROM TABLE var $hasTop = 'top'; // support mssql/interbase SELECT TOP 10 * FROM TABLE
var $sysDate = 'GetDate()'; var $sysDate = 'GetDate()';
var $sysTimeStamp = 'GetDate()'; var $sysTimeStamp = 'GetDate()';
@@ -35,14 +42,14 @@ class ADODB_odbc_mssql extends ADODB_odbc {
var $substr = 'substring'; var $substr = 'substring';
var $length = 'len'; var $length = 'len';
var $ansiOuter = true; // for mssql7 or later var $ansiOuter = true; // for mssql7 or later
var $identitySQL = 'select @@identity'; // 'select SCOPE_IDENTITY'; # for mssql 2000 var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $hasInsertID = true; var $hasInsertID = true;
var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON, var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON,
# concatenating a null value with a string yields a NULL result # concatenating a null value with a string yields a NULL result
function ADODB_odbc_mssql() function __construct()
{ {
$this->ADODB_odbc(); parent::__construct();
//$this->curmode = SQL_CUR_USE_ODBC; //$this->curmode = SQL_CUR_USE_ODBC;
} }
@@ -50,9 +57,10 @@ class ADODB_odbc_mssql extends ADODB_odbc {
function ServerInfo() function ServerInfo()
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$save=$this->SetFetchMode(ADODB_FETCH_NUM); $save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$row = $this->GetRow("execute sp_server_info 2"); $row = $this->GetRow("execute sp_server_info 2");
$this->SetFetchMode($save); $ADODB_FETCH_MODE = $save;
if (!is_array($row)) return false; if (!is_array($row)) return false;
$arr['description'] = $row[2]; $arr['description'] = $row[2];
$arr['version'] = ADOConnection::_findvers($arr['description']); $arr['version'] = ADOConnection::_findvers($arr['description']);
@@ -116,7 +124,7 @@ order by constraint_name, referenced_table_name, keyno";
function MetaTables($ttype=false,$showSchema=false,$mask=false) function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
if ($mask) { if ($mask) {//$this->debug=1;
$save = $this->metaTablesSQL; $save = $this->metaTablesSQL;
$mask = $this->qstr($mask); $mask = $this->qstr($mask);
$this->metaTablesSQL .= " AND name like $mask"; $this->metaTablesSQL .= " AND name like $mask";
@@ -131,8 +139,59 @@ order by constraint_name, referenced_table_name, keyno";
function MetaColumns($table, $normalize=true) function MetaColumns($table, $normalize=true)
{ {
$arr = ADOConnection::MetaColumns($table);
return $arr; $this->_findschema($table,$schema);
if ($schema) {
$dbName = $this->database;
$this->SelectDB($schema);
}
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
if ($schema) {
$this->SelectDB($dbName);
}
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!is_object($rs)) {
$false = false;
return $false;
}
$retarr = array();
while (!$rs->EOF){
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
$fld->not_null = (!$rs->fields[3]);
$fld->auto_increment = ($rs->fields[4] == 128); // sys.syscolumns status field. 0x80 = 128 ref: http://msdn.microsoft.com/en-us/library/ms186816.aspx
if (isset($rs->fields[5]) && $rs->fields[5]) {
if ($rs->fields[5]>0) $fld->max_length = $rs->fields[5];
$fld->scale = $rs->fields[6];
if ($fld->scale>0) $fld->max_length += 1;
} else
$fld->max_length = $rs->fields[2];
if ($save == ADODB_FETCH_NUM) {
$retarr[] = $fld;
} else {
$retarr[strtoupper($fld->name)] = $fld;
}
$rs->MoveNext();
}
$rs->Close();
return $retarr;
} }
@@ -195,7 +254,7 @@ order by constraint_name, referenced_table_name, keyno";
// "Stein-Aksel Basma" <basma@accelero.no> // "Stein-Aksel Basma" <basma@accelero.no>
// tested with MSSQL 2000 // tested with MSSQL 2000
function MetaPrimaryKeys($table) function MetaPrimaryKeys($table, $owner = false)
{ {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -297,9 +356,8 @@ class ADORecordSet_odbc_mssql extends ADORecordSet_odbc {
var $databaseType = 'odbc_mssql'; var $databaseType = 'odbc_mssql';
function ADORecordSet_odbc_mssql($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbc($id,$mode); return parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,15 +1,17 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
Oracle support via ODBC. Requires ODBC. Works on Windows. Oracle support via ODBC. Requires ODBC. Works on Windows.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -31,12 +33,7 @@ class ADODB_odbc_oracle extends ADODB_odbc {
//var $_bindInputArray = false; //var $_bindInputArray = false;
function ADODB_odbc_oracle() function MetaTables($ttype = false, $showSchema = false, $mask = false)
{
$this->ADODB_odbc();
}
function MetaTables()
{ {
$false = false; $false = false;
$rs = $this->Execute($this->metaTablesSQL); $rs = $this->Execute($this->metaTablesSQL);
@@ -107,9 +104,8 @@ class ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
var $databaseType = 'odbc_oracle'; var $databaseType = 'odbc_oracle';
function ADORecordSet_odbc_oracle($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbc($id,$mode); return parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,12 +1,14 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
*/ */
// Code contributed by "stefan bogdan" <sbogdan#rsb.ro> // Code contributed by "stefan bogdan" <sbogdan#rsb.ro>
// security - hide paths // security - hide paths
@@ -33,7 +35,7 @@ class ADODB_odbtp extends ADOConnection{
var $_canPrepareSP = false; var $_canPrepareSP = false;
var $_dontPoolDBC = true; var $_dontPoolDBC = true;
function ADODB_odbtp() function __construct()
{ {
} }
@@ -56,7 +58,7 @@ class ADODB_odbtp extends ADOConnection{
if (empty($this->_connectionID)) return @odbtp_last_error_state(); if (empty($this->_connectionID)) return @odbtp_last_error_state();
return @odbtp_last_error_state($this->_connectionID); return @odbtp_last_error_state($this->_connectionID);
} }
/* /*
function DBDate($d,$isfld=false) function DBDate($d,$isfld=false)
{ {
if (empty($d) && $d !== 0) return 'null'; if (empty($d) && $d !== 0) return 'null';
@@ -76,7 +78,7 @@ class ADODB_odbtp extends ADOConnection{
$d = adodb_date($this->fmtDate,$d); $d = adodb_date($this->fmtDate,$d);
return "convert(datetime, $d, 120)"; return "convert(datetime, $d, 120)";
} }
*/ */
function _insertid() function _insertid()
{ {
@@ -120,7 +122,7 @@ class ADODB_odbtp extends ADOConnection{
return $this->Execute("insert into adodb_seq values('$seqname',$start)"); return $this->Execute("insert into adodb_seq values('$seqname',$start)");
} }
function DropSequence($seqname) function DropSequence($seqname = 'adodbseq')
{ {
if (empty($this->_dropSeqSQL)) return false; if (empty($this->_dropSeqSQL)) return false;
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
@@ -172,6 +174,9 @@ class ADODB_odbtp extends ADOConnection{
//if uid & pwd can be separate //if uid & pwd can be separate
function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='') function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
{ {
if ($argPassword && stripos($UserOrDSN,'DRIVER=') !== false) {
$this->_connectionID = odbtp_connect($HostOrInterface,$UserOrDSN.';PWD='.$argPassword);
} else
$this->_connectionID = odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase); $this->_connectionID = odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase);
if ($this->_connectionID === false) { if ($this->_connectionID === false) {
$this->_errorMsg = $this->ErrorMsg() ; $this->_errorMsg = $this->ErrorMsg() ;
@@ -472,7 +477,7 @@ class ADODB_odbtp extends ADOConnection{
return array($sql,$stmt,false); return array($sql,$stmt,false);
} }
function PrepareSP($sql) function PrepareSP($sql, $param = true)
{ {
if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
@@ -551,7 +556,7 @@ class ADODB_odbtp extends ADOConnection{
} }
} }
function MetaIndexes_mssql($table,$primary=false) function MetaIndexes_mssql($table,$primary=false, $owner = false)
{ {
$table = strtolower($this->qstr($table)); $table = strtolower($this->qstr($table));
@@ -665,14 +670,14 @@ class ADORecordSet_odbtp extends ADORecordSet {
var $databaseType = 'odbtp'; var $databaseType = 'odbtp';
var $canSeek = true; var $canSeek = true;
function ADORecordSet_odbtp($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE;
} }
$this->fetchMode = $mode; $this->fetchMode = $mode;
$this->ADORecordSet($queryID); parent::__construct($queryID);
} }
function _initrs() function _initrs()
@@ -788,9 +793,9 @@ class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_mssql'; var $databaseType = 'odbtp_mssql';
function ADORecordSet_odbtp_mssql($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbtp($id,$mode); return parent::__construct($id,$mode);
} }
} }
@@ -798,9 +803,9 @@ class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_access'; var $databaseType = 'odbtp_access';
function ADORecordSet_odbtp_access($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbtp($id,$mode); return parent::__construct($id,$mode);
} }
} }
@@ -808,9 +813,9 @@ class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_vfp'; var $databaseType = 'odbtp_vfp';
function ADORecordSet_odbtp_vfp($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbtp($id,$mode); return parent::__construct($id,$mode);
} }
} }
@@ -818,9 +823,9 @@ class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_oci8'; var $databaseType = 'odbtp_oci8';
function ADORecordSet_odbtp_oci8($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbtp($id,$mode); return parent::__construct($id,$mode);
} }
} }
@@ -828,9 +833,8 @@ class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_sybase'; var $databaseType = 'odbtp_sybase';
function ADORecordSet_odbtp_sybase($id,$mode=false) function __construct($id,$mode=false)
{ {
return $this->ADORecordSet_odbtp($id,$mode); return parent::__construct($id,$mode);
} }
} }
?>

View File

@@ -1,12 +1,14 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt. the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
*/ */
// Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org> // Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org>
@@ -21,7 +23,7 @@ if (!defined('ADODB_DIR')) die();
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Also, all SQL query strings must be submitted as UTF-8 encoded text. Also, all SQL query strings must be submitted as UTF-8 encoded text.
*/ */
if (!defined('_ADODB_ODBTP_LAYER')) { if (!defined('_ADODB_ODBTP_LAYER')) {
include(ADODB_DIR."/drivers/adodb-odbtp.inc.php"); include(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
@@ -30,10 +32,4 @@ if (!defined('_ADODB_ODBTP_LAYER')) {
class ADODB_odbtp_unicode extends ADODB_odbtp { class ADODB_odbtp_unicode extends ADODB_odbtp {
var $databaseType = 'odbtp'; var $databaseType = 'odbtp';
var $_useUnicodeSQL = true; var $_useUnicodeSQL = true;
function ADODB_odbtp_unicode()
{
$this->ADODB_odbtp();
}
} }
?>

View File

@@ -1,6 +1,8 @@
<?php <?php
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
@@ -10,7 +12,7 @@
Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7. Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.
If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable. If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
@@ -27,12 +29,12 @@ class ADODB_oracle extends ADOConnection {
var $sysTimeStamp = 'SYSDATE'; var $sysTimeStamp = 'SYSDATE';
var $connectSID = true; var $connectSID = true;
function ADODB_oracle() function __construct()
{ {
} }
// format and return date string in database date format // format and return date string in database date format
function DBDate($d) function DBDate($d, $isfld = false)
{ {
if (is_string($d)) $d = ADORecordSet::UnixDate($d); if (is_string($d)) $d = ADORecordSet::UnixDate($d);
if (is_object($d)) $ds = $d->format($this->fmtDate); if (is_object($d)) $ds = $d->format($this->fmtDate);
@@ -41,7 +43,7 @@ class ADODB_oracle extends ADOConnection {
} }
// format and return date string in database timestamp format // format and return date string in database timestamp format
function DBTimeStamp($ts) function DBTimeStamp($ts, $isfld = false)
{ {
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
@@ -127,7 +129,7 @@ class ADODB_oracle extends ADOConnection {
// G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set // G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set
// the oracle home to the host name of remote DB? // the oracle home to the host name of remote DB?
// if ($argHostname) putenv("ORACLE_HOME=$argHostname"); // if ($argHostname) putenv("ORACLE_HOME=$argHostname");
if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen <jorma.tuomainen@ppoy.fi> if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
if (empty($argDatabasename)) $argDatabasename = $argHostname; if (empty($argDatabasename)) $argDatabasename = $argHostname;
@@ -212,14 +214,14 @@ class ADODB_oracle extends ADOConnection {
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordset_oracle extends ADORecordSet { class ADORecordset_oracle extends ADORecordSet {
var $databaseType = "oracle"; var $databaseType = "oracle";
var $bind = false; var $bind = false;
function ADORecordset_oracle($queryID,$mode=false) function __construct($queryID,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
@@ -288,7 +290,7 @@ class ADORecordset_oracle extends ADORecordSet {
} }
function _fetch($ignore_fields=false) { function _fetch($ignore_fields=false) {
// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1 // should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1
if ($this->fetchMode & ADODB_FETCH_ASSOC) if ($this->fetchMode & ADODB_FETCH_ASSOC)
return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC); return @ora_fetch_into($this->_queryID,$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
else else
@@ -299,11 +301,11 @@ class ADORecordset_oracle extends ADORecordSet {
is running. All associated result memory for the specified result identifier will automatically be freed. */ is running. All associated result memory for the specified result identifier will automatically be freed. */
function _close() function _close()
{ {
return @ora_close($this->_queryID); return @ora_close($this->_queryID);
} }
function MetaType($t,$len=-1) function MetaType($t, $len = -1, $fieldobj = false)
{ {
if (is_object($t)) { if (is_object($t)) {
$fieldobj = $t; $fieldobj = $t;
@@ -339,4 +341,3 @@ class ADORecordset_oracle extends ADORecordSet {
} }
} }
} }
?>

View File

@@ -1,9 +1,13 @@
<?php <?php
/* /**
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net Latest version is available at http://adodb.sourceforge.net
@@ -13,40 +17,41 @@
Problems: Problems:
Where is float/decimal type in pdo_param_type Where is float/decimal type in pdo_param_type
LOB handling for CLOB/BLOB differs significantly LOB handling for CLOB/BLOB differs significantly
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
/* /*
enum pdo_param_type { enum pdo_param_type {
PDO::PARAM_NULL, 0 PDO::PARAM_NULL, 0
/* int as in long (the php native int type). /* int as in long (the php native int type).
* If you mark a column as an int, PDO expects get_col to return * If you mark a column as an int, PDO expects get_col to return
* a pointer to a long * a pointer to a long
PDO::PARAM_INT, 1 PDO::PARAM_INT, 1
/* get_col ptr should point to start of the string buffer /* get_col ptr should point to start of the string buffer
PDO::PARAM_STR, 2 PDO::PARAM_STR, 2
/* get_col: when len is 0 ptr should point to a php_stream *, /* get_col: when len is 0 ptr should point to a php_stream *,
* otherwise it should behave like a string. Indicate a NULL field * otherwise it should behave like a string. Indicate a NULL field
* value by setting the ptr to NULL * value by setting the ptr to NULL
PDO::PARAM_LOB, 3 PDO::PARAM_LOB, 3
/* get_col: will expect the ptr to point to a new PDOStatement object handle, /* get_col: will expect the ptr to point to a new PDOStatement object handle,
* but this isn't wired up yet * but this isn't wired up yet
PDO::PARAM_STMT, 4 /* hierarchical result set PDO::PARAM_STMT, 4 /* hierarchical result set
/* get_col ptr should point to a zend_bool /* get_col ptr should point to a zend_bool
PDO::PARAM_BOOL, 5 PDO::PARAM_BOOL, 5
/* magic flag to denote a parameter as being input/output /* magic flag to denote a parameter as being input/output
PDO::PARAM_INPUT_OUTPUT = 0x80000000 PDO::PARAM_INPUT_OUTPUT = 0x80000000
}; };
*/ */
function adodb_pdo_type($t) function adodb_pdo_type($t)
{ {
@@ -57,14 +62,7 @@ function adodb_pdo_type($t)
} }
} }
/*-------------------------------------------------------------------------------------- /*----------------------------------------------------------------------------*/
--------------------------------------------------------------------------------------*/
////////////////////////////////////////////////
class ADODB_pdo extends ADOConnection { class ADODB_pdo extends ADOConnection {
@@ -75,7 +73,9 @@ class ADODB_pdo extends ADOConnection {
var $replaceQuote = "''"; // string to use to replace quotes var $replaceQuote = "''"; // string to use to replace quotes
var $hasAffectedRows = true; var $hasAffectedRows = true;
var $_bindInputArray = true; var $_bindInputArray = true;
var $_genIDSQL;
var $_genSeqSQL = "create table %s (id integer)"; var $_genSeqSQL = "create table %s (id integer)";
var $_dropSeqSQL;
var $_autocommit = true; var $_autocommit = true;
var $_haserrorfunctions = true; var $_haserrorfunctions = true;
var $_lastAffectedRows = 0; var $_lastAffectedRows = 0;
@@ -85,8 +85,9 @@ class ADODB_pdo extends ADOConnection {
var $dsnType = ''; var $dsnType = '';
var $stmt = false; var $stmt = false;
var $_driver;
function ADODB_pdo() function __construct()
{ {
} }
@@ -112,11 +113,17 @@ class ADODB_pdo extends ADOConnection {
function Time() function Time()
{ {
if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual"; if (!empty($this->_driver->_hasdual)) {
else $sql = "select $this->sysTimeStamp"; $sql = "select $this->sysTimeStamp from dual";
}
else {
$sql = "select $this->sysTimeStamp";
}
$rs = $this->_Execute($sql); $rs = $this->_Execute($sql);
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); if ($rs && !$rs->EOF) {
return $this->UnixTimeStamp(reset($rs->fields));
}
return false; return false;
} }
@@ -128,8 +135,19 @@ class ADODB_pdo extends ADOConnection {
$this->dsnType = substr($argDSN,0,$at); $this->dsnType = substr($argDSN,0,$at);
if ($argDatabasename) { if ($argDatabasename) {
switch($this->dsnType){
case 'sqlsrv':
$argDSN .= ';database='.$argDatabasename;
break;
case 'mssql':
case 'mysql':
case 'oci':
case 'pgsql':
case 'sqlite':
default:
$argDSN .= ';dbname='.$argDatabasename; $argDSN .= ';dbname='.$argDatabasename;
} }
}
try { try {
$this->_connectionID = new PDO($argDSN, $argUsername, $argPassword); $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
} catch (Exception $e) { } catch (Exception $e) {
@@ -142,10 +160,16 @@ class ADODB_pdo extends ADOConnection {
if ($this->_connectionID) { if ($this->_connectionID) {
switch(ADODB_ASSOC_CASE){ switch(ADODB_ASSOC_CASE){
case 0: $m = PDO::CASE_LOWER; break; case ADODB_ASSOC_CASE_LOWER:
case 1: $m = PDO::CASE_UPPER; break; $m = PDO::CASE_LOWER;
break;
case ADODB_ASSOC_CASE_UPPER:
$m = PDO::CASE_UPPER;
break;
default: default:
case 2: $m = PDO::CASE_NATURAL; break; case ADODB_ASSOC_CASE_NATIVE:
$m = PDO::CASE_NATURAL;
break;
} }
//$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT ); //$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT );
@@ -154,18 +178,21 @@ class ADODB_pdo extends ADOConnection {
$class = 'ADODB_pdo_'.$this->dsnType; $class = 'ADODB_pdo_'.$this->dsnType;
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); //$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
switch($this->dsnType) { switch($this->dsnType) {
case 'oci':
case 'mysql':
case 'pgsql':
case 'mssql': case 'mssql':
case 'mysql':
case 'oci':
case 'pgsql':
case 'sqlite': case 'sqlite':
case 'sqlsrv':
include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php'); include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
break; break;
} }
if (class_exists($class)) if (class_exists($class)) {
$this->_driver = new $class(); $this->_driver = new $class();
else }
else {
$this->_driver = new ADODB_pdo_base(); $this->_driver = new ADODB_pdo_base();
}
$this->_driver->_connectionID = $this->_connectionID; $this->_driver->_connectionID = $this->_connectionID;
$this->_UpdatePDO(); $this->_UpdatePDO();
@@ -178,9 +205,13 @@ class ADODB_pdo extends ADOConnection {
function Concat() function Concat()
{ {
$args = func_get_args(); $args = func_get_args();
if(method_exists($this->_driver, 'Concat')) if(method_exists($this->_driver, 'Concat')) {
return call_user_func_array(array($this->_driver, 'Concat'), $args); return call_user_func_array(array($this->_driver, 'Concat'), $args);
}
if (PHP_VERSION >= 5.3) {
return call_user_func_array('parent::Concat', $args);
}
return call_user_func_array(array($this,'parent::Concat'), $args); return call_user_func_array(array($this,'parent::Concat'), $args);
} }
@@ -222,8 +253,12 @@ class ADODB_pdo extends ADOConnection {
function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
{ {
$obj = $stmt[1]; $obj = $stmt[1];
if ($type) $obj->bindParam($name,$var,$type,$maxLen); if ($type) {
else $obj->bindParam($name, $var); $obj->bindParam($name, $var, $type, $maxLen);
}
else {
$obj->bindParam($name, $var);
}
} }
function OffsetDate($dayFraction,$date=false) function OffsetDate($dayFraction,$date=false)
@@ -233,65 +268,108 @@ class ADODB_pdo extends ADOConnection {
function ErrorMsg() function ErrorMsg()
{ {
if ($this->_errormsg !== false) return $this->_errormsg; if ($this->_errormsg !== false) {
if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo(); return $this->_errormsg;
else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo(); }
else return 'No Connection Established'; if (!empty($this->_stmt)) {
$arr = $this->_stmt->errorInfo();
}
else if (!empty($this->_connectionID)) {
$arr = $this->_connectionID->errorInfo();
}
else {
return 'No Connection Established';
}
if ($arr) { if ($arr) {
if (sizeof($arr)<2) return ''; if (sizeof($arr)<2) {
if ((integer)$arr[1]) return $arr[2]; return '';
else return ''; }
} else return '-1'; if ((integer)$arr[0]) {
return $arr[2];
}
else {
return '';
}
}
else {
return '-1';
}
} }
function ErrorNo() function ErrorNo()
{ {
if ($this->_errorno !== false) return $this->_errorno; if ($this->_errorno !== false) {
if (!empty($this->_stmt)) $err = $this->_stmt->errorCode(); return $this->_errorno;
}
if (!empty($this->_stmt)) {
$err = $this->_stmt->errorCode();
}
else if (!empty($this->_connectionID)) { else if (!empty($this->_connectionID)) {
$arr = $this->_connectionID->errorInfo(); $arr = $this->_connectionID->errorInfo();
if (isset($arr[0])) $err = $arr[0]; if (isset($arr[0])) {
else $err = -1; $err = $arr[0];
} else }
else {
$err = -1;
}
} else {
return 0; return 0;
}
if ($err == '00000') return 0; // allows empty check if ($err == '00000') {
return 0; // allows empty check
}
return $err; return $err;
} }
function SetTransactionMode($transaction_mode) function SetTransactionMode($transaction_mode)
{ {
if(method_exists($this->_driver, 'SetTransactionMode')) if(method_exists($this->_driver, 'SetTransactionMode')) {
return $this->_driver->SetTransactionMode($transaction_mode); return $this->_driver->SetTransactionMode($transaction_mode);
}
return parent::SetTransactionMode($seqname); return parent::SetTransactionMode($seqname);
} }
function BeginTrans() function BeginTrans()
{ {
if(method_exists($this->_driver, 'BeginTrans')) if(method_exists($this->_driver, 'BeginTrans')) {
return $this->_driver->BeginTrans(); return $this->_driver->BeginTrans();
}
if (!$this->hasTransactions) return false; if (!$this->hasTransactions) {
if ($this->transOff) return true; return false;
}
if ($this->transOff) {
return true;
}
$this->transCnt += 1; $this->transCnt += 1;
$this->_autocommit = false; $this->_autocommit = false;
$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false); $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false);
return $this->_connectionID->beginTransaction(); return $this->_connectionID->beginTransaction();
} }
function CommitTrans($ok=true) function CommitTrans($ok=true)
{ {
if(method_exists($this->_driver, 'CommitTrans')) if(method_exists($this->_driver, 'CommitTrans')) {
return $this->_driver->CommitTrans($ok); return $this->_driver->CommitTrans($ok);
}
if (!$this->hasTransactions) return false; if (!$this->hasTransactions) {
if ($this->transOff) return true; return false;
if (!$ok) return $this->RollbackTrans(); }
if ($this->transCnt) $this->transCnt -= 1; if ($this->transOff) {
return true;
}
if (!$ok) {
return $this->RollbackTrans();
}
if ($this->transCnt) {
$this->transCnt -= 1;
}
$this->_autocommit = true; $this->_autocommit = true;
$ret = $this->_connectionID->commit(); $ret = $this->_connectionID->commit();
@@ -301,12 +379,19 @@ class ADODB_pdo extends ADOConnection {
function RollbackTrans() function RollbackTrans()
{ {
if(method_exists($this->_driver, 'RollbackTrans')) if(method_exists($this->_driver, 'RollbackTrans')) {
return $this->_driver->RollbackTrans(); return $this->_driver->RollbackTrans();
}
if (!$this->hasTransactions) return false; if (!$this->hasTransactions) {
if ($this->transOff) return true; return false;
if ($this->transCnt) $this->transCnt -= 1; }
if ($this->transOff) {
return true;
}
if ($this->transCnt) {
$this->transCnt -= 1;
}
$this->_autocommit = true; $this->_autocommit = true;
$ret = $this->_connectionID->rollback(); $ret = $this->_connectionID->rollback();
@@ -317,7 +402,9 @@ class ADODB_pdo extends ADOConnection {
function Prepare($sql) function Prepare($sql)
{ {
$this->_stmt = $this->_connectionID->prepare($sql); $this->_stmt = $this->_connectionID->prepare($sql);
if ($this->_stmt) return array($sql,$this->_stmt); if ($this->_stmt) {
return array($sql,$this->_stmt);
}
return false; return false;
} }
@@ -325,31 +412,36 @@ class ADODB_pdo extends ADOConnection {
function PrepareStmt($sql) function PrepareStmt($sql)
{ {
$stmt = $this->_connectionID->prepare($sql); $stmt = $this->_connectionID->prepare($sql);
if (!$stmt) return false; if (!$stmt) {
return false;
}
$obj = new ADOPDOStatement($stmt,$this); $obj = new ADOPDOStatement($stmt,$this);
return $obj; return $obj;
} }
function CreateSequence($seqname='adodbseq',$startID=1) function CreateSequence($seqname='adodbseq',$startID=1)
{ {
if(method_exists($this->_driver, 'CreateSequence')) if(method_exists($this->_driver, 'CreateSequence')) {
return $this->_driver->CreateSequence($seqname, $startID); return $this->_driver->CreateSequence($seqname, $startID);
}
return parent::CreateSequence($seqname, $startID); return parent::CreateSequence($seqname, $startID);
} }
function DropSequence($seqname='adodbseq') function DropSequence($seqname='adodbseq')
{ {
if(method_exists($this->_driver, 'DropSequence')) if(method_exists($this->_driver, 'DropSequence')) {
return $this->_driver->DropSequence($seqname); return $this->_driver->DropSequence($seqname);
}
return parent::DropSequence($seqname); return parent::DropSequence($seqname);
} }
function GenID($seqname='adodbseq',$startID=1) function GenID($seqname='adodbseq',$startID=1)
{ {
if(method_exists($this->_driver, 'GenID')) if(method_exists($this->_driver, 'GenID')) {
return $this->_driver->GenID($seqname, $startID); return $this->_driver->GenID($seqname, $startID);
}
return parent::GenID($seqname, $startID); return parent::GenID($seqname, $startID);
} }
@@ -367,8 +459,12 @@ class ADODB_pdo extends ADOConnection {
#var_dump($this->_bindInputArray); #var_dump($this->_bindInputArray);
if ($stmt) { if ($stmt) {
$this->_driver->debug = $this->debug; $this->_driver->debug = $this->debug;
if ($inputarr) $ok = $stmt->execute($inputarr); if ($inputarr) {
else $ok = $stmt->execute(); $ok = $stmt->execute($inputarr);
}
else {
$ok = $stmt->execute();
}
} }
@@ -436,12 +532,12 @@ class ADODB_pdo_base extends ADODB_pdo {
return $ret; return $ret;
} }
function MetaTables() function MetaTables($ttype=false,$showSchema=false,$mask=false)
{ {
return false; return false;
} }
function MetaColumns() function MetaColumns($table,$normalize=true)
{ {
return false; return false;
} }
@@ -454,7 +550,7 @@ class ADOPDOStatement {
var $_stmt; var $_stmt;
var $_connectionID; var $_connectionID;
function ADOPDOStatement($stmt,$connection) function __construct($stmt,$connection)
{ {
$this->_stmt = $stmt; $this->_stmt = $stmt;
$this->_connectionID = $connection; $this->_connectionID = $connection;
@@ -471,8 +567,12 @@ class ADOPDOStatement {
function InParameter(&$var,$name,$maxLen=4000,$type=false) function InParameter(&$var,$name,$maxLen=4000,$type=false)
{ {
if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen); if ($type) {
else $this->_stmt->bindParam($name, $var); $this->_stmt->bindParam($name,$var,$type,$maxLen);
}
else {
$this->_stmt->bindParam($name, $var);
}
} }
function Affected_Rows() function Affected_Rows()
@@ -482,13 +582,23 @@ class ADOPDOStatement {
function ErrorMsg() function ErrorMsg()
{ {
if ($this->_stmt) $arr = $this->_stmt->errorInfo(); if ($this->_stmt) {
else $arr = $this->_connectionID->errorInfo(); $arr = $this->_stmt->errorInfo();
}
else {
$arr = $this->_connectionID->errorInfo();
}
if (is_array($arr)) { if (is_array($arr)) {
if ((integer) $arr[0] && isset($arr[2])) return $arr[2]; if ((integer) $arr[0] && isset($arr[2])) {
else return ''; return $arr[2];
} else return '-1'; }
else {
return '';
}
} else {
return '-1';
}
} }
function NumCols() function NumCols()
@@ -498,14 +608,18 @@ class ADOPDOStatement {
function ErrorNo() function ErrorNo()
{ {
if ($this->_stmt) return $this->_stmt->errorCode(); if ($this->_stmt) {
else return $this->_connectionID->errorInfo(); return $this->_stmt->errorCode();
}
else {
return $this->_connectionID->errorInfo();
}
} }
} }
/*-------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------
Class Name: Recordset Class Name: Recordset
--------------------------------------------------------------------------------------*/ --------------------------------------------------------------------------------------*/
class ADORecordSet_pdo extends ADORecordSet { class ADORecordSet_pdo extends ADORecordSet {
@@ -513,7 +627,7 @@ class ADORecordSet_pdo extends ADORecordSet {
var $databaseType = "pdo"; var $databaseType = "pdo";
var $dataProvider = "pdo"; var $dataProvider = "pdo";
function ADORecordSet_pdo($id,$mode=false) function __construct($id,$mode=false)
{ {
if ($mode === false) { if ($mode === false) {
global $ADODB_FETCH_MODE; global $ADODB_FETCH_MODE;
@@ -530,15 +644,19 @@ class ADORecordSet_pdo extends ADORecordSet {
$this->fetchMode = $mode; $this->fetchMode = $mode;
$this->_queryID = $id; $this->_queryID = $id;
$this->ADORecordSet($id); parent::__construct($id);
} }
function Init() function Init()
{ {
if ($this->_inited) return; if ($this->_inited) {
return;
}
$this->_inited = true; $this->_inited = true;
if ($this->_queryID) @$this->_initrs(); if ($this->_queryID) {
@$this->_initrs();
}
else { else {
$this->_numOfRows = 0; $this->_numOfRows = 0;
$this->_numOfFields = 0; $this->_numOfFields = 0;
@@ -558,7 +676,9 @@ class ADORecordSet_pdo extends ADORecordSet {
global $ADODB_COUNTRECS; global $ADODB_COUNTRECS;
$this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1; $this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1;
if (!$this->_numOfRows) $this->_numOfRows = -1; if (!$this->_numOfRows) {
$this->_numOfRows = -1;
}
$this->_numOfFields = $this->_queryID->columnCount(); $this->_numOfFields = $this->_queryID->columnCount();
} }
@@ -579,13 +699,23 @@ class ADORecordSet_pdo extends ADORecordSet {
} }
//adodb_pr($arr); //adodb_pr($arr);
$o->name = $arr['name']; $o->name = $arr['name'];
if (isset($arr['native_type']) && $arr['native_type'] <> "null") $o->type = $arr['native_type']; if (isset($arr['native_type']) && $arr['native_type'] <> "null") {
else $o->type = adodb_pdo_type($arr['pdo_type']); $o->type = $arr['native_type'];
}
else {
$o->type = adodb_pdo_type($arr['pdo_type']);
}
$o->max_length = $arr['len']; $o->max_length = $arr['len'];
$o->precision = $arr['precision']; $o->precision = $arr['precision'];
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); switch(ADODB_ASSOC_CASE) {
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); case ADODB_ASSOC_CASE_LOWER:
$o->name = strtolower($o->name);
break;
case ADODB_ASSOC_CASE_UPPER:
$o->name = strtoupper($o->name);
break;
}
return $o; return $o;
} }
@@ -596,7 +726,9 @@ class ADORecordSet_pdo extends ADORecordSet {
function _fetch() function _fetch()
{ {
if (!$this->_queryID) return false; if (!$this->_queryID) {
return false;
}
$this->fields = $this->_queryID->fetch($this->fetchMode); $this->fields = $this->_queryID->fetch($this->fetchMode);
return !empty($this->fields); return !empty($this->fields);
@@ -609,7 +741,9 @@ class ADORecordSet_pdo extends ADORecordSet {
function Fields($colname) function Fields($colname)
{ {
if ($this->adodbFetchMode != ADODB_FETCH_NUM) return @$this->fields[$colname]; if ($this->adodbFetchMode != ADODB_FETCH_NUM) {
return @$this->fields[$colname];
}
if (!$this->bind) { if (!$this->bind) {
$this->bind = array(); $this->bind = array();
@@ -622,5 +756,3 @@ class ADORecordSet_pdo extends ADORecordSet {
} }
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
if (!defined('ADODB_DIR')) die();
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
*/ */
class ADODB_pdo_mssql extends ADODB_pdo { class ADODB_pdo_mssql extends ADODB_pdo {
@@ -58,4 +60,3 @@ class ADODB_pdo_mssql extends ADODB_pdo {
} }
} }
?>

View File

@@ -1,17 +1,22 @@
<?php <?php
if (!defined('ADODB_DIR')) die();
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
*/ */
class ADODB_pdo_mysql extends ADODB_pdo { class ADODB_pdo_mysql extends ADODB_pdo {
var $metaTablesSQL = "SHOW TABLES";
var $metaTablesSQL = "SELECT
TABLE_NAME,
CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA=";
var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`"; var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
var $sysDate = 'CURDATE()'; var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()'; var $sysTimeStamp = 'NOW()';
@@ -23,42 +28,45 @@ class ADODB_pdo_mysql extends ADODB_pdo {
function _init($parentDriver) function _init($parentDriver)
{ {
$parentDriver->hasTransactions = false; $parentDriver->hasTransactions = false;
#$parentDriver->_bindInputArray = false; #$parentDriver->_bindInputArray = false;
$parentDriver->hasInsertID = true; $parentDriver->hasInsertID = true;
$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); $parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
} }
// dayFraction is a day in floating point // dayFraction is a day in floating point
function OffsetDate($dayFraction,$date=false) function OffsetDate($dayFraction, $date=false)
{ {
if (!$date) $date = $this->sysDate; if (!$date) {
$date = $this->sysDate;
}
$fraction = $dayFraction * 24 * 3600; $fraction = $dayFraction * 24 * 3600;
return $date . ' + INTERVAL ' . $fraction.' SECOND'; return $date . ' + INTERVAL ' . $fraction . ' SECOND';
// return "from_unixtime(unix_timestamp($date)+$fraction)";
// return "from_unixtime(unix_timestamp($date)+$fraction)";
} }
function Concat() function Concat()
{ {
$s = ""; $s = '';
$arr = func_get_args(); $arr = func_get_args();
// suggestion by andrew005#mnogo.ru // suggestion by andrew005#mnogo.ru
$s = implode(',',$arr); $s = implode(',', $arr);
if (strlen($s) > 0) return "CONCAT($s)"; return ''; if (strlen($s) > 0) {
return "CONCAT($s)";
}
return '';
} }
function ServerInfo() function ServerInfo()
{ {
$arr['description'] = ADOConnection::GetOne("select version()"); $arr['description'] = ADOConnection::GetOne('select version()');
$arr['version'] = ADOConnection::_findvers($arr['description']); $arr['version'] = ADOConnection::_findvers($arr['description']);
return $arr; return $arr;
} }
function MetaTables($ttype=false,$showSchema=false,$mask=false) function MetaTables($ttype=false, $showSchema=false, $mask=false)
{ {
$save = $this->metaTablesSQL; $save = $this->metaTablesSQL;
if ($showSchema && is_string($showSchema)) { if ($showSchema && is_string($showSchema)) {
@@ -69,26 +77,28 @@ class ADODB_pdo_mysql extends ADODB_pdo {
$mask = $this->qstr($mask); $mask = $this->qstr($mask);
$this->metaTablesSQL .= " like $mask"; $this->metaTablesSQL .= " like $mask";
} }
$ret = ADOConnection::MetaTables($ttype,$showSchema); $ret = ADOConnection::MetaTables($ttype, $showSchema);
$this->metaTablesSQL = $save; $this->metaTablesSQL = $save;
return $ret; return $ret;
} }
function SetTransactionMode( $transaction_mode ) function SetTransactionMode($transaction_mode)
{ {
$this->_transmode = $transaction_mode; $this->_transmode = $transaction_mode;
if (empty($transaction_mode)) { if (empty($transaction_mode)) {
$this->Execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'); $this->Execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ');
return; return;
} }
if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; if (!stristr($transaction_mode, 'isolation')) {
$this->Execute("SET SESSION TRANSACTION ".$transaction_mode); $transaction_mode = 'ISOLATION LEVEL ' . $transaction_mode;
}
$this->Execute('SET SESSION TRANSACTION ' . $transaction_mode);
} }
function MetaColumns($table,$normalize=true) function MetaColumns($table, $normalize=true)
{ {
$this->_findschema($table,$schema); $this->_findschema($table, $schema);
if ($schema) { if ($schema) {
$dbName = $this->database; $dbName = $this->database;
$this->SelectDB($schema); $this->SelectDB($schema);
@@ -97,14 +107,18 @@ class ADODB_pdo_mysql extends ADODB_pdo {
$save = $ADODB_FETCH_MODE; $save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM; $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); if ($this->fetchMode !== false) {
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); $savem = $this->SetFetchMode(false);
}
$rs = $this->Execute(sprintf($this->metaColumnsSQL, $table));
if ($schema) { if ($schema) {
$this->SelectDB($dbName); $this->SelectDB($dbName);
} }
if (isset($savem)) $this->SetFetchMode($savem); if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save; $ADODB_FETCH_MODE = $save;
if (!is_object($rs)) { if (!is_object($rs)) {
$false = false; $false = false;
@@ -119,18 +133,18 @@ class ADODB_pdo_mysql extends ADODB_pdo {
// split type into type(length): // split type into type(length):
$fld->scale = null; $fld->scale = null;
if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { if (preg_match('/^(.+)\((\d+),(\d+)/', $type, $query_array)) {
$fld->type = $query_array[1]; $fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { } elseif (preg_match('/^(.+)\((\d+)/', $type, $query_array)) {
$fld->type = $query_array[1]; $fld->type = $query_array[1];
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { } elseif (preg_match('/^(enum)\((.*)\)$/i', $type, $query_array)) {
$fld->type = $query_array[1]; $fld->type = $query_array[1];
$arr = explode(",",$query_array[2]); $arr = explode(',', $query_array[2]);
$fld->enums = $arr; $fld->enums = $arr;
$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6 $zlen = max(array_map('strlen', $arr)) - 2; // PHP >= 4.0.6
$fld->max_length = ($zlen > 0) ? $zlen : 1; $fld->max_length = ($zlen > 0) ? $zlen : 1;
} else { } else {
$fld->type = $type; $fld->type = $type;
@@ -139,8 +153,8 @@ class ADODB_pdo_mysql extends ADODB_pdo {
$fld->not_null = ($rs->fields[2] != 'YES'); $fld->not_null = ($rs->fields[2] != 'YES');
$fld->primary_key = ($rs->fields[3] == 'PRI'); $fld->primary_key = ($rs->fields[3] == 'PRI');
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
$fld->binary = (strpos($type,'blob') !== false); $fld->binary = (strpos($type, 'blob') !== false);
$fld->unsigned = (strpos($type,'unsigned') !== false); $fld->unsigned = (strpos($type, 'unsigned') !== false);
if (!$fld->binary) { if (!$fld->binary) {
$d = $rs->fields[4]; $d = $rs->fields[4];
@@ -164,19 +178,123 @@ class ADODB_pdo_mysql extends ADODB_pdo {
return $retarr; return $retarr;
} }
// returns true or false
function SelectDB($dbName)
{
$this->database = $dbName;
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
$try = $this->Execute('use ' . $dbName);
return ($try !== false);
}
// parameters use PostgreSQL convention, not MySQL // parameters use PostgreSQL convention, not MySQL
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs=0)
{ {
$offsetStr =($offset>=0) ? "$offset," : ''; $offsetStr =($offset>=0) ? "$offset," : '';
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
if ($nrows < 0) $nrows = '18446744073709551615'; if ($nrows < 0) {
$nrows = '18446744073709551615';
}
if ($secs) if ($secs) {
$rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); $rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows", $inputarr);
else } else {
$rs = $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); $rs = $this->Execute($sql . " LIMIT $offsetStr$nrows", $inputarr);
}
return $rs; return $rs;
} }
function SQLDate($fmt, $col=false)
{
if (!$col) {
$col = $this->sysTimeStamp;
}
$s = 'DATE_FORMAT(' . $col . ",'";
$concat = false;
$len = strlen($fmt);
for ($i=0; $i < $len; $i++) {
$ch = $fmt[$i];
switch($ch) {
default:
if ($ch == '\\') {
$i++;
$ch = substr($fmt, $i, 1);
}
// FALL THROUGH
case '-':
case '/':
$s .= $ch;
break;
case 'Y':
case 'y':
$s .= '%Y';
break;
case 'M':
$s .= '%b';
break;
case 'm':
$s .= '%m';
break;
case 'D':
case 'd':
$s .= '%d';
break;
case 'Q':
case 'q':
$s .= "'),Quarter($col)";
if ($len > $i+1) {
$s .= ",DATE_FORMAT($col,'";
} else {
$s .= ",('";
}
$concat = true;
break;
case 'H':
$s .= '%H';
break;
case 'h':
$s .= '%I';
break;
case 'i':
$s .= '%i';
break;
case 's':
$s .= '%s';
break;
case 'a':
case 'A':
$s .= '%p';
break;
case 'w':
$s .= '%w';
break;
case 'W':
$s .= '%U';
break;
case 'l':
$s .= '%W';
break;
}
}
$s .= "')";
if ($concat) {
$s = "CONCAT($s)";
}
return $s;
}
} }
?>

View File

@@ -1,14 +1,16 @@
<?php <?php
if (!defined('ADODB_DIR')) die();
/* /*
V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved. @version v5.20.4 30-Mar-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 8. Set tabs to 8.
*/ */
class ADODB_pdo_oci extends ADODB_pdo_base { class ADODB_pdo_oci extends ADODB_pdo_base {
@@ -89,5 +91,3 @@ class ADODB_pdo_oci extends ADODB_pdo_base {
return $retarr; return $retarr;
} }
} }
?>

Some files were not shown because too many files have changed in this diff Show More