-
Posts
332 -
Joined
-
Last visited
Everything posted by sasori
-
i've seen the manual before i postid that query..i don't really understand it...would ya like to explain how to use it using your own words then? ..that would be cool
-
hi, cane somebody please explain how to use the declare contruct of PHP some code snippets may help..thanks in advance
-
thanks alot.it helps a bit part in my problem
-
How to solve this? I have a dateCreate column at my table and it was created as DATETIME as the data type. the sample data is being saved as e.g 2011-04-05 12:22:32 The issue is, I need to have an option in my app to pull out datas based from 1) the last day it was created 2) 3 days ago 3) 5 days ago 4) 1 week ago 5) fortnight ago 6) month ago 7) quarter ago 8 ) 6 months ago 9) year ago 10) year+ ago
-
Hi, is there anyone of you who had messed with edirectory CMS kit before? I need some tips / advice/ suggestions how to integrate a 3rd party data tables with it. because this kit allows importing of data only if it's a CSV format, but this kit has it's own format of acceptable CSV data. it has it's own columns..if you tried to import a CSV that doesn't match their desired column, it'll get rejected I was given 6 tables with different columns from that of edirectory's CSV columns..arghh
-
hi, i need help.. i use to have a complete dev environment before within my 32 bit win 7.. now I just reformatted to 64bit win 7..how can i set up a PHP dev environment for 64 bit ?..will xampp or wamp work ? or there's a specific way to do things right ?
-
I have a problem , the question is a the bottom, but first let me show you the directory, routing, code structure of my practice app This is the Member_LoginController Code class Member_LoginController extends Zend_Controller_Action { public function init(){} /* * index actin where the main login * form resides */ public function indexAction() { $form = $this->getLoginForm(); if($this->getRequest()->isPost()) { if($form->isValid($this->getRequest()->getPost())) { if($this->_process($form->getValues())) { $this->_helper->redirector('index','index'); } } } $this->view->form = $form; } public function getLoginForm() { $form = new Zend_Form(); $form->setAttrib('sitename', 'Noob'); //login form; $myElements = new Noob_Form_Register(); $form->addElement($myElements->getLoginField()); //password field $form->addElement($myElements->getPasswordField()); $form->addElement('submit','submit'); $submitButton = $form->getElement('submit'); $submitButton->setLabel('Login'); $form->addDisplayGroup(array('loginName','password','submit'),'login'); $form->getDisplayGroup('login') ->setOrder(10) ->setLegend('Member Login'); return $form; } /* * main process for the main login */ protected function _process($values) { $adapter = $this->_getAuthdapter(); $adapter->setIdentity($values['loginName']); $adapter->setCredential($values['password']); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if($result->isValid()) { $user = $adapter->getResultRowObject(); $auth->getStorage()->write($user); return true; } return false; } /* * get auth adapter for the main login */ protected function _getAuthdapter() { $dbAdapter = Zend_Db_Table::getDefaultAdapter(); $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter); $authAdapter->setTableName('members') ->setIdentityColumn('LoginName') ->setCredentialColumn('LoginPassword') ->setCredentialTreatment('SHA1(CONCAT(?,salt))'); return $authAdapter; } /* * main logout */ public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::destroy(); $this->_redirect('member/login'); } } here's the Member_IndexController Code class Member_IndexController extends Zend_Controller_Action { public function preDispatch() { //set member gateway layout $url = $this->getRequest()->getRequestUri(); $this->_helper->layout->setLayout('member'); } public function init(){} public function indexAction() {} and here's a helper /* credit goes to rob allen */ <?php class Zend_View_Helper_LoggedInAs extends Zend_View_Helper_Abstract { public function loggedInAs() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $username = $auth->getIdentity()->WSLoginName; $logoutUrl = $this->view->url(array('controller' => 'login', 'action' => 'logout', 'module' => 'member'), null, true); return 'Welcome '. $username . '. <a href="'. $logoutUrl . '">Logout</a>'; } $request = Zend_Controller_Front::getInstance()->getRequest(); $controller = $request->getControllerName(); $module = $request->getModuleName(); $action = $request->getActionName(); if($controller == 'login' && $action == 'index'){ return ''; } $loginUrl = $this->view->url(array('controller' => 'login', 'action' => 'index')); return '<a href="'. $loginUrl . '">Login</a>'; } } ?> now here's the layout <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Member Gateway</title> <link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('/css/member.css'); ?>" /> </head> <body> <div id="container"> <div id="header"> <div id="menu"> <ul> <li><a href="<?php echo $this->url(array(),'member-account'); ?>">My Account</a></li> <li><a href="<?php echo $this->url(array(),'member-details');?>">Membership Details</a></li> <li><a href="<?php echo $this->url(array(),'member-staff'); ?>">Members Staff</a></li> <li><a href="#">Members Account</a></li> <li><a href="#">Members Products</a></li> <li><a href="#">WSM</a></li> <li><a href="#">Web Products</a></li> </ul> </div><!-- end menu --> <div align="right" id="login"><?php echo $this->loggedInAs(); ?></div> </div><!-- end header --> <div id="content"> <?php echo $this->layout()->content; ?> </div><!-- end content --> <hr /> <div align="center" id="footer"> <img src="<?php echo $this->baseUrl('/images/zendframeworklogo1.png'); ?>" /> </div><!-- end footer --> </div><!-- end container --> </body> </html> and here's the new Member_DetailsController Account code class Member_DetailsController extends Zend_Controller_Action { public function preDispatch() { //set member gateway layout $url = $this->getRequest()->getRequestUri(); $this->_helper->layout->setLayout('member'); } public function indexAction() { } So here's what my problem is, 1 ) when I log in, i get redirected to the IndexController of the member module, so, the "logout" link works there 2) when I click a link within that index view that points to another module controller (Details controller) , the logout doesn't work . - I am using firebug to see the session/cookies. I don't know why it disappears once I go to another controller, 1) what should I do in order to make this logout helper work in all the additional controllers within the same modules that I am about to create ? - Is there a problem with my routing ? :please answer my question or post some useful code snippets that can help me accomplish this objective . thanks in advance
-
someone told me, it's automatically created. so I did not put anything at the ini file, index.php and bootstrap . then I added this in one of my controllers $sess = new Zend_Session_Namespace('userNamespace'); $sess->username = $q->$loginName; $sess->datejoined = $q->FieldDateSetup; then I called it at the view file like this Hello <?php echo $sess->username; ?> how come there's an error that says Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\zf\myapp\application\modules\member\views\scripts\profile\index.phtml on line 2 where line 2 is the script i posted above
-
Hi, can you give me a snippet how to include Zend_Session::start() in bootstrap file ? thanks in advance
-
why is it that the captcha image doesn't appear in firefox ? but it does appear in chrome, is there something wrong with this code ? //create captcha for verification $captcha = new Zend_Form_Element_Captcha('Captcha', array( 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'width' => 300, 'height' => 100, 'imgUrl' => 'public/captcha', 'imgDir' => APPLICATION_PATH .'/../public/captcha', 'font' => APPLICATION_PATH .'/../public/fonts/LiberationSansRegular.ttf' ) ));
-
problem solved after several trial and errors...the generated models went to the c:\ ,
-
I was able to generate models using this script, slightly modified the one i posted above include_once 'doctrine1/lib/Doctrine.php'; spl_autoload_register(array('Doctrine', 'autoload')); $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection('mysql://root:pass@localhost/dbname','doctrine'); Doctrine::generateModelsFromDb('/a/models', array('doctrine'), array('classPrefix' => 'Square_Model_') ); but I got this error at the cmd , i dunno what it means I deleted the generated models and repeated the same procedure and it doesn't work anymore btw, I placed the Doctrine folder inside the PEAR folder of my PHP installation
-
hi, can you guys tell me or type here howto generate models from an existing db using the doctrine 1.2 ? currently, what I did was, I placed the Doctrine folder + Doctrine.php in a directory named e.g test, then in the test directory, I created a file named test1.php , and I added this code include_once('Doctrine.php'); spl_autoload_register(array('Doctrine','autoload')); $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection('mysql://username:password@localhost/dbname','doctrine'); Doctrine::generateModelsFromDb('/test', array('doctrine'), array('classPrefix'=>'Square_Model_') ); then I ran it via shell using "php -f test1.php" , and boom!, nothing happened. actually this code snippet is from a book, I dunno why it's not working
-
never mind.. problem solved with INSERT SELECT syntax ..hooray
-
Hi, I got a problem here, need help I got a country table it has - country id - country name - country code <!-- this is ok --> I got states table it has - state id - country id (empty) :-\ - region id (empty ) :-\ - state name - state code <!-- this not ok --> I got cities table and it has - city id - country code - region code - city name <-- this is ok --> now, what i want to happen is, fill in those empty field I indicated above that are empty , with their corresponding data..the reason they were empty is that, I filled all these tables with datas coming from chop-chopped chunks of text files .. can anyone help me ?
-
nevermind....was able to solve by creating a non-OOP script instead lol
-
hi, i have the class here, and am trying to save the read column of the textfile to db. but unfortunately it's not being save, i don't know what's wrong... I also attached the textfile so you'll have an idea what am i trying to read from class Extractor { public $filehandler; public $data = array(); // set your db access details private $host = HOST; private $username = USERNAME; private $password = PASSWORD; private $dbname = DBNAME; public function __construct($file) { $this->filehandler = $file; } //prints col1 of textfile public function printcol1() { $fp = fopen($this->filehandler,'r'); while(($this->data = fgetcsv($fp,1000,",")) !== FALSE) { # $this->data[0]."<br />"; $this->savetodb($this->data[0]); } fclose($fp); } public function savetodb($data) { try{ $pdo = new PDO("mysql:host=$this->host;dbname=$this->dbname",$this->username,$this->password); $pdo->exec("INSERT INTO test(col,id) VALUES ({$data},null)"); $pdo = null; }catch(PDOException $e){ echo $e->getMessage()."<br />"; } } } $file = 'iso3166.txt'; $shit = new Extractor($file); $shit->printcol1(); [attachment deleted by admin]
-
cool, thanks...am sooo noob lol
-
hello, i have this text file attached, and I am currently extracting the data from it. and yeah, I know how..but the problem is the double quotation marks. the last double quotation mark doesn't go away,,,am also aware that trim() only accepts strings. but how come, it does remove the first double quotation mark and leave the 2nd one. here's my script, feel free to download the file and try my script in your own localhost and tell me what's wrong . Thanks in advance $fh = fopen('iso3166.txt','r'); while(!feof($fh)) { $lines = fgets($fh); $parts = explode(",",$lines); print trim($parts[1],'"')."<br />"; } fclose($fh); [attachment deleted by admin]
-
ok, am set the max_execution time now to 360, i hope that limit is enough to render everything
-
Objectives: 1) to view the whole data of the text file and render it via browser 2) if step 1 is ok and was able to see the complete file, then I'll extract one of the comma delimited column and insert it in a db table field by setting the ini_set to a higher memory_limit , the file's data was rendered half way, the other half got halted. and i got this error Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\test3\test2.php on line 17
-
What did it show? Quite likely you're using up all the memory. Try increasing it with: ini_set('memory_limit', '150M'); Although I'll add; displaying 128mb worth of data in a browser isn't the best idea. it rendered only 1/4 of the data from the text file... I'm currently running it with the ini_set you said..lemme see it that would help
-
what do you mean purge data every 12 hours or archive ? can you explain this further ? (btw, nice avatar hehe )