Is this MS-Access feature available in PHP/MySql
Posted: Tue Oct 07, 2014 5:51 am
Hi,
Being pretty new at PHP and MySql I have not discovered an example that parallels a feature that MS-Access has.
I was hoping someone could review these two sets of code to tell me if my PHP/MySql conversion of the MS-Access code is the only way (most efficient way)
or if PHP/MySql has a similar set of commands that MS-Access offers (and if PHP does if this is a good idea anyway).
This is a very simple example. I commented only the part of the code that parallels between MS-Access and PHP/MySql.
MS-Access comments start with a quote ' rather than the PHP //
The speacial MS-Access commands are .edit and .update
Both functions are tested and working.
Thanks,
John
Being pretty new at PHP and MySql I have not discovered an example that parallels a feature that MS-Access has.
I was hoping someone could review these two sets of code to tell me if my PHP/MySql conversion of the MS-Access code is the only way (most efficient way)
or if PHP/MySql has a similar set of commands that MS-Access offers (and if PHP does if this is a good idea anyway).
This is a very simple example. I commented only the part of the code that parallels between MS-Access and PHP/MySql.
MS-Access comments start with a quote ' rather than the PHP //
The speacial MS-Access commands are .edit and .update
Both functions are tested and working.
Thanks,
John
Code: Select all
Private Function funcResetTempMembers()
lngTempNameNumber = 0
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
lngjwMultiQueryOneOrAny2Long4 = Me.fldJLTR_Key
Set rst = dbs.OpenRecordset("qryMemberTempList", dbOpenDynaset)
DoCmd.SetWarnings False
With rst
If .RecordCount = 0 Then
GoTo Closefiles
End If
.MoveFirst
Dim TempName As String
Dim MyDate As Date
MyDate = Now()
Do Until .EOF
lngTempNameNumber = lngTempNameNumber + 1
TempName = "Temp_" & Me.fldJLTR_Key & MyDate & "_" & lngTempNameNumber
.Edit 'This is the special command the MS-Access has to allow direct updates to the records produced by the query. You also use .new to create a new record
!fldMM_FirstName = TempName 'Direct update of the fields without need for a 2nd SQL statement
!fldMM_LastName = TempName 'Direct update of the fields without need for a 2nd SQL statement
!fldMM_MiddleName = TempName 'Direct update of the fields without need for a 2nd SQL statement
.Update 'Again this is one of the special command MS-Access has for writing the record out
.MoveNext
Loop
End With
DoCmd.SetWarnings True
Closefiles:
rst.Close: Set rst = Nothing
dbs.Close: Set dbs = Nothing
End Function
Code: Select all
Function funcResetTempMembers() {
global $con;
global $AnyErrors;
global $fldJLTR_Key;
global $ResultMF;
Include 'qryMemberTempList.php';
$qstring = qryMemberTempList($fldJLTR_Key);
$result = @mysqli_query($con,$qstring);
if (!$result) {
$AnyErrors = "Y";
$ResultMessTemp = "Error retrieving member master for temps! (data) 1. " . mysqli_error($con);
}
if ($AnyErrors == "N") {
$MyDate = date('Y-m-d H:i:s');
$lngTempNameNumber = 0;
while($row = mysqli_fetch_array($result)) {
$lngTempNameNumber = $lngTempNameNumber + 1;
$TempName = 'Temp_' . $fldJLTR_Key . $MyDate . $lngTempNameNumber;
//START Commands that MS-Acccess is doing with rst.edit and rst.update
$fldMM_Key = $row['fldMM_Key'];
$sql = "
UPDATE
tblMemberMaster
SET
fldMM_FirstName='$TempName',
fldMM_MiddleName='$TempName',
fldMM_LastName='$TempName'
WHERE
fldMM_Key='$fldMM_Key';
";
if (!@mysqli_query($con, $sql)) {
$AnyErrors = "Y";
$ResultMF = "Error resetting the temp member names on the member master. " . mysqli_error($con);
}
//END Commands that MS-Acccess is doing with rst.edit and rst.update
} //while($row = mysqli_fetch_array($result))
} //if ($AnyErrors == "N")
} //Function funcResetTempMembers()