Im new to PHP, i just want to know if theres any rule in php in terms of single statement multiple lines. for example in VB.Net we uses "&_"(w/o the quote) to tell vb.net that it is a single statment and it has a continuation. is there any in php?

Heres the sample in In VB.Net

                    "INSERT INTO table(field1," &_
                     field2)VALUES(value1," &_ 
                     "Value2)"

in php= ????

It will be a big help for a newbie like me.

Thanks

I am not sure if this is exactly what you are looking for, but in PHP it is called transaction. The mysql ENGINE directives must be set to innodb.

Normally, if you are using PHP MVC frameworks like fuel PHP, laravel, and even CI (lower level), these frameworks are pre-packaged with database library that can easily handle transactions.

The idea is pretty similar to the ADODB objects. Similar to other programming languages, PHP trasactions can be roll-back. Meaning, if later on we don't want the latest modification on our database, we can roll it back to the previous state e.g.

$this->db->trans_begin();

$this->db->query('Your_First_Query.....');
$this->db->query('Maybe_a_Second_Query..');
$this->db->query('And_yet_another_a_third_Query...');

if ($this->db->trans_status() === FALSE)
{
    $this->db->trans_rollback();
}
else
{
    $this->db->trans_commit();
}

if this

$this->db->trans_status()

evaluates to FALSE, then we can roll-back. Otherwise, we commit to finalize the transaction.

This topic is pretty huge and it requires practice and full understanding of ORM. At the moment, I really don't know what to recommend as far as tutorial is concern.

You can read more about it here and here.

If I got your question right you want to know whether a special character is required in PHP to write a statement on multiple lines. The code in PHP would be:

$query = "INSERT INTO table(field1," .
"field2)VALUES(value1," .
"Value2)";

or

$query  = "INSERT INTO table(field1,";
$query .= "field2)VALUES(value1,";
$query .= "Value2)";

or simply

$query = "INSERT INTO table(field1,
field2)VALUES(value1,
Value2)";

You use a dot (.) to concatenate strings or use any whitespace (line break, spaces) within a string to format the code.

commented: That was my take as well +15

Thanks for all the reply guys, i already applied it.. cheers!

If no more questions please mark thread as solved. Happy coding in PHP :-)

@broj1 really hit this one on the head. Good job. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.