Reply to comment

Useful code snippets for me

Simple XML/XSLT Parser

<?php
  $xml_filename
= 'name.xml';
 
$xsl_filename = 'name.xsl';
 
$doc = new DOMDocument();
 
$xsl = new XSLTProcessor();
 
$doc->load($xsl_filename);
 
$xsl->importStyleSheet($doc);
 
$doc->load($xml_filename);
 
$content = $xsl->transformToXML($doc);
?>

MySQL snippet with cursors:

DECLARE done int default 0;
DECLARE currentProfileID bigint;
DECLARE dateCreatedPrm DATETIME;
DECLARE profileCursor CURSOR FOR SELECT ID FROM Profiles WHERE ID NOT IN (SELECT pID FROM Profiles_storage);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

START TRANSACTION;

OPEN profileCursor;
REPEAT
FETCH profileCursor INTO currentProfileID;
    IF NOT done THEN
        SELECT date_created INTO dateCreatedPrm FROM Accounts WHERE ID = (SELECT account_id FROM Profiles WHERE ID = currentProfileID);
        CALL Routine_add(currentProfileID, asd, DATE_ADD(dateCreatedPrm, INTERVAL 2 YEAR));
END IF;
UNTIL done
END REPEAT;

CLOSE profileCursor;

COMMIT;

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Это простая проверка на то, что со мной общается человек, а не глупая машина. Умные машины тоже не приветствуются :)
Image CAPTCHA
Enter the characters shown in the image.
© 2008-2009. Konstantin Artemov