cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Saving models issue in 0.7.0 & 0.8.0

Open ddenysov opened this issue 13 years ago • 6 comments

When I save model it inserts two records in table.

$user = new Users(); $user->save(array( "name" => "Foo", "password" => "Bar" ));

Users table: 1 Foo Bar 2 Foo Bar

The same result when I using: $user->name = 'assad';

UPDATE: Found strange behavior

Controller: Index Action: Index

Inserts 2 records per one save

Controller: Index Action: Test (and others)

Inserts 1 record, this is ok

ddenysov avatar Dec 28 '12 14:12 ddenysov

Hi, sorry but there are unit-tests in the testsuite to test that a single save/create doesn't create more than one record, so that scenario is not possible.

Maybe there are forwards/redirects to the index/index action that produce this behavior. Please add the following code to your index method to check where these forwards come from:

file_put_contents('log.txt', print_r(debug_backtrace(), true), FILE_APPEND);

ghost avatar Dec 28 '12 16:12 ghost

Thats weird. Becaus I check it on empty created project with developers tool. =/ Here is a log: https://docs.google.com/file/d/0B2Z2j9phj5MHYnBUMFVUMTc5eW8/edit

Also I have override save method in model (to check redirects) and exit from program like this:

public function save($options = null) {
    parent::save($options);
    die("Shutdown...");
}

Still add 2 records ...

ddenysov avatar Dec 28 '12 17:12 ddenysov

The log seems to be fine :/

Could you send me please the whole app or code to test it?

ghost avatar Dec 28 '12 19:12 ghost

Sorry, it something wrong with my NGINX settings. It runs index.php twice for unknown reason. Thanx anyway)

ddenysov avatar Dec 28 '12 20:12 ddenysov

Hi denisov, I have the same issue with NGINX how did you solve it?

diegogub avatar Nov 21 '13 20:11 diegogub

This sounds similar to an issue I've had before where the browser is actually requesting the favicon.ico file and Phalcon renders the indexAction. The resolution can be found here

http://forum.phalconphp.com/discussion/2702/facebook-php-sdk-version-4

TommyBs avatar Jul 13 '14 09:07 TommyBs