In this line of code, it only selects the first 20, but I want to select the first 20 first and Second and the other and so on: 'How can I solve this problem?
function some_cron () $ query = db_select (' Watchdog ',' wa ') - & gt; Extension ('pager default') -> Order ('wid') - & gt; Field ('or', array ('variable', 'type', 'severity', 'message', 'wide', ' Timestamp ')) -> Segment 20); $ Result = $ query- & gt; carry about (); // Loop through each item and add it to $ line. Foreach ($ line result $ line) {someother ();}
I also want to avoid this pager default but I can not ..
First of all, you do not need it pager default if you are not displaying pager, you can use it and without it.
If I understand your post, the cron is run every time, then you want the first 20 lines of watchdog table. The case is, I will suggest the ng track of the last watchdog ID (legal) that you received from the table and use it for every subsequent run. Something like this:
$ wid = variable_get ('my_last_wid', 0); $ Result = db_select ('watchdog') - & gt; Field ('Watchdog', Array ('variable', 'type', 'severity', 'message', 'wide', 'timestamp')) - & gt; Condition 'wide', 'rs, rs,' & gt; ') - & gt; 'Wid' - & gt; Category (0, 20) - & gt; Performance (); Foreign currency ($ result as $ wardog) {// Whatever you want to do} If (!! (Watchdog)), {variable_set ('my_last_wid', $ watchdog- & gt; wid); }
No comments:
Post a Comment