Download Zend Server Cluster Manager Reference Manual

Transcript
Zend Server Reference Manual
Example:
The following example shows what the original code looks like. How it will look like using the Job
Queue API, and what the new Job file looks like.
Before converting to a job:
<?php
function validate_credit_card_number($string)
{
if(preg_match('/^([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([09]{4})[\-|\s]*([0-9]{2,4})$/', $string))
{
return TRUE;
}
else
{
return FALSE;
}
}
// here we call the function to validate the credit card validate_cr
edit_card_number($_POST['credit_code']);
Instead of calling the function from inside the script we will create a job that will be executed when
we specify it to run. The script will be replaced with a call to the Job Queue API as follows:
The application script after modification:
<?php
$cc = $_POST['credit_card'];
$q = new ZendJobQueue();
$ts = date('Y-m-d H:i:s', time()+10);
$id=$q>createHttpJob('/jobs/validate_credit_card.php',array('credit_card'=
171