コード例 #1
0
$updateLog = "";
// Operation: insert or update
$civiOps = array();
// civi vars }
// --variables } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//#'M --MAIN - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
clearIs4cWorkVars();
clearCiviWorkVars();
// The "@" prevents the error from being reported immediately,
//  but the test further on will still see it.
if (!$dev) {
    $dbConn = new SQLManager($CIVICRM_SERVER, $CIVICRM_SERVER_DBMS, $CIVICRM_DB, $CIVICRM_SERVER_USER, $CIVICRM_SERVER_PW);
} else {
    $dbConn = new SQLManager($CIVICRM_SERVER, $CIVICRM_SERVER_DBMS, $CIVICRM_DB_DEV, $CIVICRM_SERVER_USER_DEV, $CIVICRM_SERVER_PW_DEV);
}
$message = $dbConn->error();
if ($message != "") {
    dieHere("{$message}", $dieMail);
}
/* Little tests of civiCRM connection.
dieHere("Civi connection did not fail, bailing ...", 0);
civiTestAndDie2($dbConn);
*/
$dbConn2 = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
if ($dbConn2->connect_errno) {
    $message = sprintf("Connect2 failed: %s\n", $dbConn2->connect_error);
    dieHere("{$message}", $dieMail);
}
/*Get the timestamp of the last run of this program
 * Not sure that is safe. Always use epoch.
 * The pairs with same datestamps are ignored.
コード例 #2
0
//$dbConn = @new mysqli("$CIVI_IP", "$CIVI_USER", "$CIVI_PASSWORD", "$CIVI_DB");
// Cannot do this - func doesn't exist, or object doesn't.
//$conn->SetFetchMode(ADODB_FETCH_ASSOC);
//$dbConn->SetFetchMode(ADODB_FETCH_ASSOC);
/* mysqli How to trap errors?
 * The die trap does not work.
 * $dbConn = new mysqli("$CIVI_IP", "$CIVI_USER", "$CIVI_PASSWORD", "$CIVI_DB")
     or die($dbConn->connect_error);
 * This works:
 * $dbConn exists even if the connection failed.
 * connect_errno returns 0 if no error.
*/
/* SQLManager - this doesn't trap a real error
   If there is a forced error there is a Fatal further down at a place that doesn't make sense.
*/
$message = $dbConn->error();
if ($message != "") {
    dieHere("{$message}");
} else {
    $message = "1CiviCRM connection did not fail";
    if ($debug == 1) {
        echo "{$message}\n";
    }
}
if (FALSE && $dbConn->error()) {
    $message = sprintf("Connect1 failed: %s\n", $dbConn->error());
    dieHere("{$message}");
    //die("dying ...");
    //exit();
}
//echo "Hello?\n";