Jump to content

optikalefx

Members
  • Posts

    363
  • Joined

  • Last visited

    Never

Posts posted by optikalefx

  1. I know this won't be possible with DOC, but it should be with DOCX.

     

    Basically I want to have someone write up a docx file using special tokens in certain places.  Then my PHP would find and replace those tokens when the users needs to.  It would create and serve a NEW docx file with the tokens replaced.

     

    Any ideas on this? I'm reading up on a ton of libraries, but nearly all of them, their examples don't work out of the box.

     

    Thanks!

  2. sure np.  A little extra tip.  For yes or no type storage, you should really use TINYINT(1) and store 1 or 0 instad of yes or no.  Your database will be smaller and all your code will be simpler.

     

    Instead of checking WHERE blah ='yes'  you will be able to just do WHERE blah. 

    and if you want to display yes or no, you can do that with SELECT IF(blah,'yes','no') as blah

  3. Seriously - just calculate the end date and store that.  There is an awesome mysql date function called DATE_DIFF that you can use in all your selects to return the duration without ever going to PHP. 

     

    If you REALLY wanna store duration, you need to store a concatted string.  1:Y  would be 1 Year. and you can use Y from the php date functions. So in PHP you would explode(":","1:y") to get that as an array. Or just store 2 fields.

     

    Either way you should just store the end date.

  4. SELECT Sales.*, otherTable.USQuantity, otherTable.USDollars, otherTable.MXQuantity, otherTable.MXDollars

    FROM Sales

    LEFT JOIN otherTable ON (Sales.Product = otherTable.Product)

     

    basically your using the Product field on both tables to JOIN those 2 tables together. Left join means i dont care if the join results in null values, just give me the row no matter what. JOIN alone (without the left) would do the same but not give you the row if the key did not exist on the other table.

  5. if you were 100% that it will never be a many to 1 relationship than an 'answer' is just a property of a question.  Therefore it can just be a field on the question table.

     

    But you also have to ask, will there ever be information about an answer that isn't directly about the question?  Like, how long it took to answer that question, what order the answer appeared in, etc..  That all could still be on the question table, but you wanna make sure that an answer is just 1 piece of info about a question and it isn't an entity of its own.

  6. I have a users table, and I have a table of videos that a user has permission for.  So there are many rows in the permissions table for 1 user.

     

    I want to show all user info including a count() on the number of videos for all users in 1 list.

     

    doing select * from users works fine of course.

    but doing

     

    select 
    users.UserID,
    COUNT(userpermissions.`UserPermissionsID`)
    FROM users
    LEFT JOIN userpermissions ON (userpermissions.UserID = users.UserID)
    GROUP BY users.UserID
    LIMIT 200
    

     

    hangs and never finishes.  Even with a limit of 1.  There are 16,000 users and 27,000 total permissions.

     

    What does work - kind of. Is doing JOIN instead of LEFT JOIN.  But that obviously won't grab users that have no videos.

    So what can i do to make the LEFT JOIN query work? Do i have an index problem? Or are these tables too large for the left join?

  7. So i'm taking over a big database for a client.  I really need to make a unique index on the table, but I can't because there are already tons of duplicates from bad design in the past.

     

    What is a quick way to kill all these duplicates so I can set the unique index?

  8. I know there has got to be some server config somewhere.  But I have a site with about 8000 users.  And 20% or so can never receive "forgot email" passwords.  A lot of them checked their junk and its not there, it just never gets delivered.  But for a lot of people it works fine.

     

    So... How can i get PHP mail() to work better.

     

    Right now im using swift mailer with this code

     

    function email($to,$subject,$body,$from="") {
    	require_once 'packages/swift/swift_required.php';
    	$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
    	$mailer = Swift_Mailer::newInstance($transport);
    	$message = Swift_Message::newInstance($subject);
    	$message->setFrom($from);
    
    	$headers = $message->getHeaders();
    	if (!$headers->has('Reply-To')) {
    	  $headers->addTextHeader('Reply-To',$from);
    	}
    
    	if(!is_array($to)) $to = array($to);
    	$message->setTo($to);
    	$message->setBody($body,'text/html');
    	$result = $mailer->batchSend($message);
    	$toString = implode(",",$to);
    	$this->_log("EMAIL to $toString - $body - $result");
    	return $result;
    }
    

     

    What have you guys used for this kind of thing? Is there some server config everyone should do?

    Thanks!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.