-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Is this SVN set up properly? I don't think I'm in Trunk.
kicken replied to DeX's topic in Other Web Server Software
All your files are in the root beside your trunk, tags, and branches directory. You need to move them from the root into the trunk. After you've moved everything and committed the change svn ls ^/ should only show trunk, tags, and branches directories. kicken@web1:~/svn-wc/my-super-project$ svn ls ^/ branches/ tags/ trunk/ Rename your current working copy to something else as a backup then re-checkout the repository but specify the trunk in the url. kicken@web1:~/svn-wc$ svn co svn://localhost/my-super-project/trunk my-super-project -
Is this SVN set up properly? I don't think I'm in Trunk.
kicken replied to DeX's topic in Other Web Server Software
Running svn info in your working copy will tell you what you checked out. svn ls ^/ (use ^^/ if your in a windows command prompt) will list the root of that repository so you can see what it contains. If you do not see your trunk / tags / branches folders in the root then you goofed something up. Based on your description I suspect you might have created trunk, tags, and branches as separate repositories. -
Is this SVN set up properly? I don't think I'm in Trunk.
kicken replied to DeX's topic in Other Web Server Software
If I'm understanding you correctly then no, what you have setup does not sound correct. I've never used svnserve (I serve via apache) but from what it sounds like the -r parameter should point to a folder which contains a bunch of repositories. Each repository needs to be initialized via svnadmin create. So for example you should have within /var/local/svn a single folder for your project, say my-super-project. After you create that folder you'd cd into it and initialize it with svnadmin create . After it's initialized it should look something like: kicken@web1:~/svn/my-super-project$ ls -l total 24 drwxrwxr-x 2 kicken kicken 4096 Dec 19 17:20 conf drwxrwsr-x 6 kicken kicken 4096 Dec 19 17:20 db -r--r--r-- 1 kicken kicken 2 Dec 19 17:20 format drwxrwxr-x 2 kicken kicken 4096 Dec 19 17:20 hooks drwxrwxr-x 2 kicken kicken 4096 Dec 19 17:20 locks -rw-rw-r-- 1 kicken kicken 246 Dec 19 17:20 README.txt Checkout that repository into another folder somewhere. kicken@web1:~/svn-wc$ svn co svn://localhost/my-super-project Checked out revision 0. kicken@web1:~/svn-wc$ ls -l total 4 drwxrwxr-x 3 kicken kicken 4096 Dec 19 17:23 my-super-project Setup your trunk/tags/branches structure by adding it to the working copy you just checked out. kicken@web1:~/svn-wc/my-super-project$ svn mkdir branches tags trunk A branches A tags A trunk If you want you could also add your initial project files to trunk at this point or any other directories you want. Then commit the first revision. kicken@web1:~/svn-wc/my-super-project$ svn commit -m "Initial setup" Adding branches Adding tags Adding trunk Committing transaction... Committed revision 1. -
My users always have to refresh multiple times after deployment
kicken replied to DeX's topic in Javascript Help
We've had this issue in the past with a system I help maintain. Adding a URL parameter on each update wasn't really feasable as the system is kind of a hodge-podge of scripts all with their own set of <script> tags to pull in various resouces. What I did was configure the server (IIS in my case) to add a 3-hour limit to the cache time. Since the system is mostly just used during working hours this works well as the caches expire over night and everyone gets fresh copies in the morning including any updates made that night. Adding a limit to the cache is done by either including a Cache-Control header with the max-age specifier which indicates the length of time the cache is valid in seconds or an Expires header with the date when the resource should be re-requested. For apache you can add both headers using mod_expires and a configuration like: <FilesMatch "\.js$"> ExpiresActive On ExpiresDefault "access plus 5 minutes" </FilesMatch> Or you can add the Cache-control header with mod_headers with: <FilesMatch "\.js$"> Header set "Cache-control" "max-age=300" </FilesMatch> -
Agreed, I thought he'd be well over that mark already. Congrats Barand, every one is well deserved.
-
From the manual:
-
INSERT ON DUPLICATE KEY UPDATE with Composite key
kicken replied to NotionCommotion's topic in MySQL Help
You could go back to just using an UPDATE statement rather than an INSERT hack. I posted another alternative method in your original thread. -
Another alternative is to do a multi-table update where one of the tables is derived of your values. Unfortunately the mysql way of doing this is a bit verbose as you have to do a bunch of unions. For example: UPDATE t INNER JOIN ( SELECT NULL as pk, NULL as c1, NULL as c2 UNION ALL SELECT 2, 4, 12 UNION ALL SELECT 4, 6, 6 UNION ALL SELECT 15, 8, 2 ) v SET t.c1 = v.c1 , t.c2 = v.c2 The first row in the derived table is just to set the column names. By just adding a row with nulls you avoid having to handle naming in your code when generating the union block and the nulls won't match anything on the join. Using an inner join means you'll only be updating matching rows so there's no need for an explicit where clause in the query.
-
INSERT ON DUPLICATE KEY UPDATE with Composite key
kicken replied to NotionCommotion's topic in MySQL Help
Yes, but that is irrelevant. Mysql is going to error on the "try to insert" part of the query due to the missing column and never actually get to the update part. In pseudo-code it'd be something like: if ($query->isValidInsert()){ if (!$query->insert() && $query->getError() == 'duplicate'){ $query->update(); } } It's failing on the isValidInsert part because it's missing data. -
INSERT ON DUPLICATE KEY UPDATE with Composite key
kicken replied to NotionCommotion's topic in MySQL Help
Because your statement is basically an INSERT to start with you have to satisfy all the conditions that a normal insert would have. That includes providing a value for all the NOT NULL columns that do not have a default. The ON DUPLICATE KEY clause is basically just a way to provide some automatic error handling. Think of it as mysql attempting the insert but if it returns an error indicating a duplicate key violation then it re-issues an UPDATE query instead. -
Yes. If you are using foreign keys replace is not ideal.
-
auto change of quotes...in php urgent help!
kicken replied to akhilkumar332's topic in PHP Coding Help
Or even more specifically Javascript random quote. Here's basic random quote tutorial to get you started. -
My statement is just based on what the documentation says. From some brief testing however it seems as though it may only increment if at least one row is successfully inserted. If even a single row is added then the ID will increment for every row, even those that were updated. If however all rows end up being updates it appears to not affect the increment value.
-
From the manual Basically attempting to do an INSERT will increment your ID, even if the insert fails. As such if you tried to "insert" 1000 rows just to update them via ON DUPLICATE you would basically add 1000 to your next actual inserted row's ID value. I'd agree with Jacques1 though, test first to see if it's even necessary to try and batch the updates. I've only encountered a couple instances in the past where using the CASE WHEN trick provided any significant benefit over just doing multiple single updates.
-
Using INSERT ... ON DUPLICATE would work, but may have undesirable side-effects such as incrementing the pk if it's an AUTO_INCREMENT value. Another option is to use CASE WHEN conditions to select the appropriate value and a simple IN condition on the where clause. UPDATE t SET c1 = CASE WHEN pk = 2 THEN 4 WHEN pk = 4 THEN 6 WHEN pk = 15 THEN 8 ELSE c1 END , c2 = CASE WHEN pk = 2 THEN 12 WHEN pk = 4 THEN 6 WHEN pk = 15 THEN 2 ELSE c2 END WHERE pk IN (2,4,15) If you're concerned about possibly hitting the maximum packet size, break your updates into chunks, say like 1000 rows at a time. You can prepare the query once then just re-execute it with different parameter values for each chunk.
-
I think you need to provide more code. It's not clear from the code you posted what is supposed to be happening or why you may be having issues. All three of your conditional branches add the order id to your array, so why have the conditions at all?
-
Making changes to a page without a refresh requires Javascript not PHP. What exactly do you want to do? Display numbers where?
-
Those changes were not needed. The only changes you needed to make to pass the HTML back is: Change $form = sprintf($html); to return $html; and change $regform->renderForm(); to return $regform->renderForm();
-
You need to return your HTML string from your renderForm function, not try to print it. Your use of sprintf does nothing, that line is basically the same as just doing $form = $html which is pointless. Once you return the HTML from renderForm you also need to return it from your buildForm method. That will then let you assign it to your $newform variable and pass it to twig.
-
Is there any problem if I require_once a file at top of every php page?
kicken replied to colap's topic in PHP Coding Help
I think you might be confusing how Symfony uses twig and twig itself. Twig does not require any of the symfony stack to use it for your own stuff. Twig also has nothing special with regards to how forms work. All the form stuff is part of the Symfony framework and irrelevant if you're not using it. To use twig for your own non-symfony project all you have to do is download it (or add it via composer) and start using it per the getting started documentation. -
User experience with PHP generated emails
kicken replied to NotionCommotion's topic in PHP Coding Help
That's exactly what the Reply-to header is for. When the user clicks reply the email client will use the reply-to address rather than the from address. Using noreply (or similar) as the from address should make it apparent that the user shouldn't try and use that address thus stopping them from copying it to a new message. There's really not much you can do about it if someone wants to be dumb/silly and do that though. -
If you have some sort of setter method for object 1 that accepts instances of object 2 and vice versa you could setup a link there. class object1 { private $object2 public function setObject2($obj){ $this->object2 = $obj; $obj->setObject1($this); } } class object2 { private $object1 public function setObject1($obj){ $this->object1 = $obj; } } I agree with requinix though in that everything is too abstract to really give any good advice. There's not any generic solution to giving an object access to just a specific method of another object. The closest generic idea is you just give each object a reference to the other and they both have access to the public methods.
-
The strict flag basically means php uses the === operator to compare instead of the == operator, which you can read about in the manual. There's also a comparison table
-
Change React loop addPeriodicTimer timer
kicken replied to NotionCommotion's topic in PHP Coding Help
Depends a bit on what I'm looking for. In this case I was looking for a method to either re-register the timer or a way to change the interval of the timer so I started by just looking at the LoopInterface and TimerInterface. Neither of those have a way to change just the interval but the loop interface does have a cancel method. I didn't really spend time looking around at any implementations as I figured if there is no way on the official interface then there's probably just not a way at all. If I were more interested in knowing how something actually worked then I'd go directly to the implementation code rather than the interfaces. -
Change React loop addPeriodicTimer timer
kicken replied to NotionCommotion's topic in PHP Coding Help
From digging around in the react code it looks like you just have to remove the timer then re-add it. $timer1 = $loop->addPeriodicTimer($interval1, function() use ($app) { $app->do_something(); }); $socket->on('data', function($data) use ($app, $loop, &$timer1) { $loop->cancelTimer($timer1); $newInterval = 10; $timer1 = $loop->addPeriodicTimer($newInterval, function() use ($app){ $app->do_something(); }); });