Hi there, in my site I have a console which optionally outputs any sql queries run, plus various debugging info. Nw when running the query which I want to see the timeout info of - the following snippet of script is used.
The result being that the sql query’s info is not always sent via xml. The following code attempts to parse the sql string, to get the line mentioning the time taken to process - saving that to rcnt. Then if match() does not return null, it is supposed to get the time taken in seconds. note the two lines in bold below. after this it is supposed to replace a %SEC% flag in the innerHTML of the topmost field (id cntf) in the data table.
if (sql != undefined) {
[B] var rcnt = sql.match(/^line [\\d]+[\\/a-z\\. ]*[\\d]+.[\\d]+ seconds.$/mgi);[/B]
[I]salert(sql);[/I]
[I]salert(rcnt);[/I]
if (rcnt !== null) {
[B] var ncnt = rcnt[0].match(/[\\d]*.[\\d]*/g);[/B]
document.getElementById("cntf").innerHTML.replace(/%SEC%/g,ncnt[0]);
}
}
the value of sql is shown below, returned from ajax - followed by the value of rnct (which is shown to be null):
‘0’ => "SELECT
UPPER(SC.text_ServiceDescription) AS Service,
GROUP_CONCAT(DISTINCT IF(
R.bigint_ParentRegionID=0,
R.text_RegionDescription,
R1.text_RegionDescription
) SEPARATOR ’
') AS Country,
UPPER(IF(
R.bigint_ParentRegionID!=0,
R.text_RegionDescription,
R0.text_RegionDescription
)) AS Region,
UPPER(S.text_SupplierName) AS Supplier,
GROUP_CONCAT(DISTINCT UPPER(CASE S.smallint_SupplierStatus
WHEN 0 THEN ‘Premium’
WHEN 1 THEN ‘Paused’
WHEN 2 THEN ‘Trial’
WHEN 3 THEN ‘Inactive’
WHEN 4 THEN ‘Freemium’
END) SEPARATOR ’
') AS Status,
GROUP_CONCAT(DISTINCT UPPER(IF (
SC.bigint_PrimaryAttributeKey = 0 OR SA1.text_AttributeValue = NULL,
‘DEFAULT’,
SA1.text_AttributeValue
)) SEPARATOR ’
') AS Prim_Att_Val
FROM
4_servicesuppliers SS
INNER JOIN 2_servicescatalogue SC ON (SS.bigint_ServiceID = SC.bigint_ServiceID)
INNER JOIN 1_regions R ON (SS.bigint_RegionID = R.bigint_RegionID)
INNER JOIN 5_suppliers S ON (SS.bigint_SupplierID = S.bigint_SupplierID)
LEFT JOIN 3_serviceattributes SA0 ON (SC.bigint_PrimaryAttributeKey = SA0.bigint_AttributeID AND SC.bigint_ServiceID = SA0.bigint_AttributeServiceID)
LEFT JOIN 3_serviceattributes SA1 ON (SA0.text_AttributeDescription = SA1.text_AttributeDescription AND SC.bigint_ServiceID = SA1.bigint_AttributeServiceID)
LEFT JOIN 1_regions R0 ON (R.bigint_ParentRegionID = 0 AND R.bigint_RegionID = R0.bigint_ParentRegionID)
LEFT JOIN 1_regions R1 ON (R.bigint_ParentRegionID != 0 AND R.bigint_ParentRegionID = R1.bigint_RegionID)
LEFT JOIN 9_supplierattributes SA3 ON (S.bigint_SupplierID = SA3.bigint_SupplierID AND SC.bigint_ServiceID = SA3.bigint_ServiceID AND ((R.bigint_RegionID = SA3.bigint_RegionID OR R.bigint_ParentRegionID = SA3.bigint_RegionID) OR (R0.bigint_RegionID = SA3.bigint_RegionID OR R0.bigint_ParentRegionID = SA3.bigint_RegionID) OR (R1.bigint_RegionID = SA3.bigint_RegionID OR R1.bigint_ParentRegionID = SA3.bigint_RegionID)) AND SA1.bigint_AttributeID = SA3.bigint_AttributeID)
LEFT JOIN 3_serviceattributes SA2 ON (SA3.bigint_AttributeID = SA2.bigint_AttributeID AND SC.bigint_ServiceID = SA2.bigint_AttributeServiceID)
WHERE SA2.text_AttributeValue IS NULL
GROUP BYService
,Region
,Supplier
ORDER BYService
ASC,Region
ASC,Supplier
ASC;
$_SESSION =
$_POST = Array
(
[orderby] => ORDER BY Service
ASC, Region
ASC, Supplier
ASC
[where] => WHERE
[groupby] => GROUP BY Service
, Region
, Supplier
[groupcnct] => ,Country
,Status
,Prim_Att_Val
)
Line 829 in /var/www/performatix.co/production/scripts/ajax_services.php executed in 0.089391946792603 seconds.
"
‘0’ …
However, I am struggling to match the bold, italic and underlined with regular expressions. What am I doing wrong here? 0o
sincerely - Pierre.