Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed


follow us on Twitter





New Security Features Planned for Firefox 4

Another Laptop Theft Exposes 21K Patients' Data

Oracle Hits to Road to Pitch Data Center Plans
Database Journal |DBA Support |SQLCourse |SQLCourse2









Systems Programmer / Software Engineer - C, Unix-Linux, Multi-threading, IPC
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

PHP

Aug 27, 2002

Faking It - Simulated Database Queries - Page 7

By DatabaseJournal.com Staff

Run-time Options

QuerySim has three options that may be set at run-time:

columnDelim
Sets the delimiter for column names.
Default is a comma (,).
dataDelim
Sets the delimiter for data lines.
Default is a pipe (|).
eolDelim
Sets the delimiter for an end-of-line.
Default is a Windows carriage return/line feed (ASCII decimal characters 13 and 10) and may, of course, be adjusted for -nix and Mac files.

All of these options may be set to virtually any character or combination of characters. The escape character, back slash (\), may not be used. Attempting to set any of the delimiters to back slash by using an escaped back slash (\\) will throw an error.

Non-printing characters may be set using their ASCII code or PHP alias. For example, a tab may be expressed as 'chr(9)' or '\t'.

External File Example

Suppose we want pull a comma delimited server log for a web based administration tool:


<?php 
require_once 'DB.php';

$dsn "querysim:///c:/weblogs/webserver.log";

$conn DB::connect($dsn, array('persistent'=>true'dataDelim'=>','));// notice that we change the dataDelim to a ','
if (DB::isError($conn)) {
    die (
'Cannot connect: '.$conn->getMessage()."\n<br />\n<pre>".$conn->getUserInfo()."\n</pre>\n<br />");
}

$user $conn->query('read from file');
if (
DB::isError($user)){
    die (
'Database Error: '.$user->getMessage()."\n<br />\n<pre>".$user->getUserInfo()."\n</pre>\n<br />");
}

$conn->disconnect();
?>

Using a sub-string search in a conditional, we could easily display only certain types of errors, 404s for example.

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

PHP Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.