There is an issue existing with usort() function. Problem is purely related to php version, the old syntax is not work well in php 5.3 Here is the fix for usort() function Issue with PHP 5.3 usort($aResult, function ($elem1, $elem2) { return strcmp($elem1[‘title’], $elem2[‘title’]); }); solution Use a different function. usort($aResult,”mySort“); function mySort($elem1,$elem2){ return strcmp($elem1[‘title’],…
Category: PHP
Export large sql table data to csv using php(socialengine)
//function to download all users deatails to csv public function downloadcsvAction() { ob_end_clean(); set_time_limit(0); ini_set(‘memory_limit’, ‘2024M’); $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); $query=Engine_Db_Table::getDefaultAdapter()->select() ->from(‘engine4_users’,array(‘user_id’,’email’,’displayname’,’level_id’,’enabled’,’approved’,’intro_page’,’creation_date’)) ->where(‘user_id <> ?’, 1) ->where(‘user_id not in (?)’, array(‘685′,’870′,’948′,’965′,’1031′,’1249′,’1279′,’1283’)) ->where(‘user_id <> ?’, 6); $aResult= $query->query()->fetchAll(); $fileName = “users_”.time().’.csv’; header(‘Content-Type: application/csv’); header(‘Content-Disposition: attachement; filename=”‘.$fileName.’”‘); $f = fopen(‘php://output’, ‘w’) or show_error(“Can’t open php://output”); $n = 0; $line…
session in socialengine
socialengine basically using zendframework for development. Zendframework methods can see all through the socialengine code. Session is an important functionality in programming. For achieving the session in socialengine use the following code $session = new Zend_Session_Namespace(‘invite’); $session->invite_code = $this->_getParam(‘code’); $session->invite_email = $this->_getParam(’email’);
How to download or print a page using PHP and javascript
jQuery(‘.payment-print’).live(‘click’, function() { var sUrl = jQuery(‘#base-url’).val() + ‘/jobs/paymentprint/id/’ + jQuery(this ).attr(“id”); jQuery.post(sUrl, function(data){ var HTML = data; var WindowObject = window.open(” “, “PrintWindow”, “width=769,height=601,top=40,left=40,toolbars=no”); WindowObject.document.writeln(HTML); WindowObject.document.close(); WindowObject.focus(); WindowObject.print(); WindowObject.close(); }) });
File download zend framework php script
File download zend framework php script <?php $imagePath = getcwd().’/public/images/smartips_log.png’; header(‘Content-Type: image/jpeg’); header(‘Content-Disposition: attachment; filename=smartips_log.png’); readfile($imagePath); ?>