1601
alain01
Re: A big surprise for 2020
  • 2020/1/29 14:14

  • alain01

  • Just can't stay away

  • Posts: 530

  • Since: 2003/6/20


Lot of works again, greg and me.

Want to see a little part ?
https://codepen.io/alain01/full/dyPEVdG

https://codepen.io/alain01/full/RwNmLKR

Please, try the responsive mode (smartphone, tablet, laptop, desktop)



1602
mjoel
Re: help with mysql xoops query and msaccess database
  • 2020/1/29 3:30

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


nevermind i got it..thanks again to zyspec for the help
// get the Access dB departments Name not in XOOPS
$accessQuery1 "SELECT DEPTID, DEPTNAME FROM DEPARTMENTS WHERE DEPTNAME NOT IN ('$deptNameArray')";
$rs1 odbc_exec($conn$accessQuery1);
if (!
$rs1) {
    exit(
"Error in SQL");
}

// now update departments into 'mydepartments' table
while(odbc_fetch_row($rs1)){
$deptId=odbc_result($rs1,"DEPTID");
$deptName=odbc_result($rs1,"DEPTNAME"); 
 
$updateprocess$GLOBALS['xoopsDB']->query("UPDATE ".$xoopsDB->prefix("mydepartments")."
SET DEPTNAME='
$deptName' WHERE DEPTID='$deptId'");
}

// get the Access dB all departments
$accessQuery2 "SELECT DEPTID FROM DEPARTMENTS";
$rs2 odbc_exec($conn$accessQuery2);
if (!
$rs2) {
    exit(
"Error in SQL");
}

// now delete department in 'mytr_departments' table
while(odbc_fetch_row($rs2)){
$deptId2[]=odbc_result($rs2,"DEPTID");
}
$deptIdArray2 implode(', '$deptId2);
$deleteprocess=$GLOBALS['xoopsDB']->queryF("DELETE FROM ".$xoopsDB->prefix("mydepartments").
WHERE DEPTID NOT IN (
$deptIdArray2)");



1603
mjoel
Re: help with mysql xoops query and msaccess database
  • 2020/1/28 8:18

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


How about update process if there's changes in access db departments update it in xoops db mydepartments

whats the best way to combine with the code above ?

UPDATE mydepartments AS mydepartmentsdepartments AS departments 
SET mydepartments
.DEPTNAME departments.DEPTNAME
WHERE departments
.DEPTID mydepartments.DEPTID;



1604
mjoel
Re: help with mysql xoops query and msaccess database
  • 2020/1/28 6:54

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


zyspec i made some adjustment to your code and now its working ..thank you again for the help

// first get a list of department IDs
$result=$GLOBALS['xoopsDB']->query("SELECT DEPTID FROM ".$xoopsDB->prefix("mydepartments")."");
while(
$row=$GLOBALS['xoopsDB']->fetchArray($result))
{
$deptId[]=$row['DEPTID'];}
$deptIdArray implode(', '$deptId);

// connect to the Access dB
$conn odbc_connect('mydata','','');
if (!
$conn) {
    exit(
"Connection Failed: " $conn);
}

// now get the Access dB departments not in XOOPS
$accessQuery "SELECT DEPTID, DEPTNAME FROM DEPARTMENTS WHERE DEPTID NOT IN ($deptIdArray)";
$rs odbc_exec($conn$accessQuery);
if (!
$rs) {
    exit(
"Error in SQL");
}

// now put new departments into 'mydepartments' table
while(odbc_fetch_row($rs)){


$deptId=odbc_result($rs,"DEPTID");
$deptName=odbc_result($rs,"DEPTNAME");    
$resultx$GLOBALS['xoopsDB']->query("INSERT INTO ".$xoopsDB->prefix("mydepartments")."(`DEPTID`, `DEPTNAME`)
VALUES ('
$deptId','$deptName')");
    if (!
$resultx) {
    
redirect_header($_SERVER['PHP_SELF'], 2'Error inserting new department'); 
    exit(); 
    }
    ++
$i;
    }
    
redirect_header($_SERVER['PHP_SELF'], 2"{$i} new departments entered into the database"); 
    exit();



1605
mjoel
Re: help with mysql xoops query and msaccess database
  • 2020/1/28 1:34

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


Quote:

goffy wrote:
Hi mjoel

I do it always the other way around (because I am very familiar with access :) )
I link the mysql tables via odbc into my ms access database (only mysql-driver is necessary).
Then you can handle the data in the access db.


Hi Goffy

what im trying to do here is to migrate all the data to xoops and stop using msaccess database
since the access db now is too big and slow



1606
mjoel
Re: help with mysql xoops query and msaccess database
  • 2020/1/28 1:13

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


// first get a list of department IDs
$result $GLOBALS['xoopsDB']->query('SELECT DISTINCT(DEPTID) FROM ' $GLOBALS['xoopsDB']->prefix('mydepartments'));
list(
$deptIdArray) = $GLOBALS['xoopsDB']->fetchRow($result);

// connect to the Access dB
$conn odbc_connect('mydata','','');
if (!
$conn) {
    exit(
"Connection Failed: " $conn);
}

// now get the Access dB departments not in XOOPS
$accessQuery "SELECT DEPTID, DEPTNAME FROM DEPARTMENTS WHERE DEPTID NOT IN (" implode(','$deptIdArray) . ")";
$rs odbc_exec($conn$accessQuery);
if (!
$rs) {
    exit(
"Error in SQL");
}

// now put new departments into 'mydepartments' table
while(odbc_fetch_row($rs)){
    list(
$deptId$deptName) = odbc_result($rs'DEPTID''DEPTNAME');
    
$result $GLOBALS['xoopsDB']->query("INSERT INTO " $xoopsDB->prefix('mydepartments') . "($deptId$deptName)");
    if (!
$result) {
        exit(
'Error inserting new department');
    }
    ++
$i;
    }
}
exit(
"{$i} new departments entered into the database");

Thanks zyspec for the input....i received error in SQL..

btw may i know what is the diffrence between
$GLOBALS['xoopsDB']->
and
$xoopsDB->
which is better ?



1607
goffy
Re: help with mysql xoops query and msaccess database
  • 2020/1/27 17:02

  • goffy

  • Just can't stay away

  • Posts: 535

  • Since: 2010/12/27


Hi mjoel

I do it always the other way around (because I am very familiar with access :) )
I link the mysql tables via odbc into my ms access database (only mysql-driver is necessary).
Then you can handle the data in the access db.



1608
zyspec
Re: help with mysql xoops query and msaccess database
  • 2020/1/27 14:06

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


sorry... just looked at the code I posted again.

implode(',''deptIdArray')

should be:
implode(','$deptIdArray)



1609
zyspec
Re: help with mysql xoops query and msaccess database
  • 2020/1/27 1:48

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


@mjoel,

I haven't tried this but I think I'd take an approach something like this:

// first get a list of department IDs
$result $GLOBALS['xoopsDB']->query('SELECT DISTINCT(DEPTID) FROM ' $GLOBALS['xoopsDB']->prefix('mydepartments'));
list(
$deptIdArray) = $GLOBALS['xoopsDB']->fetchRow($result);

// connect to the Access dB
$conn odbc_connect('mydata','','');
if (!
$conn) {
    exit(
"Connection Failed: " $conn);
}

// now get the Access dB departments not in XOOPS
$accessQuery "SELECT DEPTID, DEPTNAME FROM DEPARTMENTS WHERE DEPTID NOT IN (" implode(',''deptIdArray') . ")";
$rs odbc_exec($conn$accessQuery);
if (!
$rs) {
    exit(
"Error in SQL");
}

// now put new departments into 'mydepartments' table
while(odbc_fetch_row($rs)){
    list(
$deptId$deptName) = odbc_result($rs'DEPTID''DEPTNAME');
    
$result $GLOBALS['xoopsDB']->query("INSERT INTO " $xoopsDB->prefix('mydepartments') . "($deptId$deptName));
    if (!
$result) {
        exit('Error inserting new department');
    }
    ++
$i;
    }
}
exit("
{$i} new departments entered into the database");



1610
alain01
Re: (More ?) Useful Tags in User Message Manager
  • 2020/1/27 0:39

  • alain01

  • Just can't stay away

  • Posts: 530

  • Since: 2003/6/20


Haaaaa
Thank you Michael for this full anwser with examples !

I didnt know it !




TopTop
« 1 ... 158 159 160 (161) 162 163 164 ... 29425 »



Login

Who's Online

572 user(s) are online (334 user(s) are browsing Support Forums)


Members: 0


Guests: 572


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits