Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:56:40+00:00 2026-06-10T01:56:40+00:00

I am trying to test a Model and i need to insert into the

  • 0

I am trying to test a Model and i need to insert into the ‘created’ field the current time-stamp.

I am using a Fixture for it but using ‘NOW()’ doesn’t seem to work. It writes 0000-00-00 00:00:00.

This is my fixture record:

public $records = array(
        array(
            'id' => 1,
            'body' => 'esto es una prueba',
            'idUser' => 2,
            'created' => 'NOW()',
            'ip' =>'1.1.1.1',
         )
)

Any idea about this?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:56:41+00:00Added an answer on June 10, 2026 at 1:56 am

    As $recordsis a class property, you cannot use functions inside the definition.
    If you want to use functions (like in your case date()or similar) you’ve to do it inside the init function like this:

    public function init() {
      $this->records = array(
        // ...
        'created' => date('Y-m-d H:i:s'),
        // ...
      );
    
      // dont forget to call parent::init() if you're overwriting init().
      parent::init();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test a model method using Play Framework 2.0 and Specs2. Global.scala
I'm trying to test that a UserProfile model is created as a new User
I'm trying to test using SFML's full screen mode, however it crashes every time
I trying to test an AccountController that uses DotNetOpenAuth but I am running into
I need to validate data in my model and then test this model using
I need some help guys, trying to make this test to pass but with
Is it good to use an autoloader that load root/app/model/test.php when trying to use
just trying to test for equality in this piece of code, but getting a
Im trying to test my successfully creates a new user after login (using authlogic).
I'm trying to test a model that has an implicit has_many association, and am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.