2

I have problem with Medoo framework, all work fine on localhost (php > 5.4+) but on my server I have instaled PHP 5.3+, can you help me how I can convert this code to old array version and execute code on PHP 5.3. platform.

$database = new medoo array(
    // required
    'database_type' => 'mysql',
    'database_name' => 'mytable',
    'server' => 'localhost',
    'username' => 'root',
    'password' => '',

 // optional
    'port' => 3306,
    'charset' => 'utf8',
        'option' => [
        PDO::ATTR_CASE => PDO::CASE_NATURAL
    ]
);


$database->insert("table", [
    "project_name" => "Some text",
    "project_owner" => "Some Text",
    "project_time" => "10/10/2014",
    "project_target" => "- Target one, - Target two, - Target three",
    "project_details" => "This is my project."
]);
Machavity
  • 30,841
  • 27
  • 92
  • 100
user3300811
  • 105
  • 1
  • 1
  • 7

2 Answers2

3
<?php
require  'medoo.php';

$database = new medoo(array(
    'database_type' => 'mysql',
    'database_name' => 'test',
    'server' => 'localhost',
    'username' => 'testu',
    'password' => 'asdf'


));

$database->insert("table", array(
    "project_name" => "x",
    "project_owner" => "x",
    "project_time" => "x",
    "project_target" => "x",
    "project_details" => "x"
))
?>
user3300811
  • 105
  • 1
  • 1
  • 7
2

Replace the brackets with an array call. All the brackets are a short form for array.

http://www.php.net/manual/en/language.types.array.php

Joshua Bixler
  • 531
  • 2
  • 6
  • Yes, first I do this and do not want work. $database = new medoo(array( // required 'database_type' => 'mysql', 'database_name' => 'mytable', 'server' => 'localhost', 'username' => 'root', 'password' => '' )); – user3300811 Apr 10 '14 at 21:49
  • Exist and show error: PHP Parse error: syntax error, unexpected '[', expecting ')' in /home/test/public_html/sql/index.php on line 13 – user3300811 Apr 10 '14 at 22:39