Hi,

I think your question is out of context with the CakePHP group. I
suggest you write this up on the comp.lang.php group. This group only
serves discussions for CakePHP related issues.

Thanks,
OJ

On Nov 18, 5:26 am, big tekno <bigte...@gmail.com> wrote:
> Hello,
>
> firstly, i am a beginner, 2nd , Thank you google translate ;-). it's
> URGENT Thank you.i want to write a handler for relational database.
> This handler will load a database and provide an opportunity for the
> user to perform read operations, additions and deletions (see list of
> commands). The user can then enter a number of commands that will be
> interpreted by the manager.
> The file format of the database is free. It has you find the format
> easier to manage. In other words, we do not require a loader file
> database made by another group.
> Program Synopsis:
>
> Program Synopsis:
>
> $> Php. / db.php
> Usage:. / db.php [-i inputfile] [-o outputfile] dbfile
> $>
>
>     * Mandatory Parameter:
>           o 'dbfile': path to the file that contains the database on
> which to work.
>     * Options:
>           o-i 'filename': specifies standard input program. If this
> option is not enabled, standard input program is the system (stdin).
>           o-o 'filename': specifies the standard output of the
> program. If this option is not enabled, standard output of the program
> is that the system (stdout).
>
> Once the program starts, it waits on its standard input commands that
> execute if they sound good. The program ends when it encounters the
> QUIT command or if the input stream reaches EOF.
> Orders:
>
> All orders are delineated by a semicolon ';'. An order can be multiple
> lines. If a syntax error is detected, the program displays the message
> 'syntax error' and continues to await further orders.
> QUIT
> ----------------------------------------------------------------------------
>
> Exits the program.
> Synopsis:
>
> QUIT;
>
> CREATE TABLE
>
> CREATE TABLE creates a table in the database.
> Synopsis:
>
> CREATE TABLE table_name
> (
> name_col_1 type [OPTIONS]
> name_col_2 type [OPTIONS]
> ...
> );
>
>     * 'Table_name': table name to create.
>     * 'name_col_1': column name to create.
>     * 'Type': data type of column.
>       Possible types:
>           o integer
>           o float
>           o bool
>           o string
>     * [Options]: Optional.
>           o primary_key: defines the primary key of the table. (It can
> not have one)
>           o not_null: Defines a field as being necessarily different
> from NULL
>
> The name, type and different options are separated by one or more
> tabs.
>
> In our database, a table should always have a single primary key.
>
> Example:
>
> CREATE TABLE customers
> (
> id integer primary_key,
> name not_null string,
> surname string,
> age integer
> );
> -> Table 'customers' created.
>
> The program should display a message informing the user if the
> instruction went well.
> If the table already exists, the command will display an error.
> DESC
>
> Used to describe a table in the database.
>
> Synopsis
>
> DESC table_name;
>
>     * 'Table_name': table name to describe.
>
> Example:
>
> ...
> DESC customers;
> ------- TABLE 'customers' -------
> 'id' integer primary_key
> 'name' string not_null
> 'surname' string
> 'age' integer
> ------- TABLE 'customers' -------
>
> ...
>
> INSERT
> ----------------------------------------------------------------------------
>
> The INSERT command adds a record in a table.
> Synopsis:
>
> INSERT table_name
> (
> name_col = val [...]
> );
>
>     * 'Table_name': name of the table or insert data
>     * 'Col_name': name of the column.
>     * 'Val': value of the column.
>
> If during an insert a column has no assigned value, NULL is written.
> If this column can be NULL, an error is generated.
> If a primary key is duplicated, the program displays an error and does
> not realize the recording. Examples:
>
> INSERT Customers
> (
> id = 1
> name = dupond,
> surname = jeans
> age = 24
> );
> -> Insert done.
>
> INSERT Customers
> (
> id = 42
> name = "name with spaces"
> surname = jeans
> age = 24
> );
> -> Insert done.
>
> INSERT Customers
> (
> id = 2
> surname = stone
> );
> -> Error: Column 'name' can not be null.
>
> INSERT Customers
> (
> id = 1
> name = smith,
> surname = stone
> );
> -> Error: duplicate primary key 'id'.
>
> TRUNCATE
> ----------------------------------------------------------------------------
> The TRUNCATE command erases all records in a table (ie the drain).
> Synopsis:
>
> TRUNCATE table_name;
>
>     * 'Table_name': table name is empty.
>
> Example:
>
> TRUNCATE customers;
> -> Table 'customers' is truncate.
>
> If the table does not exist, the statement displays an error.
> DROP
>
> The DROP can destroy a table and thus all his recordings.
> Synopsis:
>
> DROP tablename;
>
>     * 'Table_name': table name was erased.
>
> If the table does not exist, the statement displays an error.
> DELETE
>
> The DELETE command can delete records from a table that match one or
> more conditions.
> Synopsis:
>
> DELETE
> FROM table_name
> WHERE condition
> [AND condition2 ...];
>
>     * 'Table_name': table name on which to perform the treatment.
>     * 'Condition': a condition for the selection of elements (see the
> conditions.)
>
> Examples:
>
> DELETE
> FROM customers
> WHERE id = 1;
> -> 1 row (s) deleted.
>
> DELETE
> FROM customers
> WHERE name LIKE '% to'
> AND Pname = 'john';
> -> 0 row (s) deleted.
>
> If the table does not exist, the statement displays an error.
>
> SELECT
> ----------------------------------------------------------------------------
>
> This command displays information from the database according to
> criteria of selection.
> Synopsis:
>
> SELECT col_1 [, col2 ...]
> FROM name_table_1 [, name_table_2 ...]
> [WHERE condition_1]
> [AND condition_2 ...]
> [ORDER BY col_tri [DESC]];
>
>     * Col_x name of the column display. May be replaced by '*' and
> displays it in this case all the columns / tables (s) question (s).
>     * name_table_x name of the table concerned by the treatment.
>     * Condition_x: conditions to filter the results (see chapter on
> conditions)
>     * ORDER BY col_tri [DESC]: Allows results in a column in ascending
> or descending when DESC is specified.
>
> Examples:
>
> SELECT id, name
> FROM customers;
> -> Result: 2 row (s)
> id name
> --------------------------
> 1 smith
> 2 dupond
> --------------------------
>
> SELECT * FROM customers
> WHERE id> 0
> ORDER BY name;
> -> Result: 4 row (s)
> id name age Pname
> --------------------------------------------------
> 5 Abido laurent 24
> 2 dupond jean 25
> 1 smith stone 25
> Zorro 8 NULL NULL
> --------------------------------------------------
>
> SELECT clients.name, villes.cp
> FROM customers, cities
> WHERE clients.villeid = villes.id
> AND clients.id = 42;
> -> Result: 1 row (s)
> cp name
> --------------------------------------------------
> Plop 94,500
> --------------------------------------------------
>
> The command will display the number of records that matchent, then
> these records
>
> If the table does not exist, the statement displays an error.
> Conditions
>
> A WHERE condition or AND (or even GOLD bonus) are always related 2
> operands separated by an operator. The operands may be columns or
> static data.
> Example:
>
> WHERE client.id> = 1
> AND clients.ville = ville.id
>
> If the command connects more than 2 tables, the column name is
> preceded by the name of the table.
>
> The possible operators are:
>
>     * =: Equality
>     * NOT: not equality
>     * <: Less than
>     *>: Higher
>     * <=: Less than or equal
>     *> =: Greater than or equal
>     * LIKE: match a pattern. So the 2nd operand is a string that is a
> pattern.
>       The magic of this pattern are:
>           o '%': replace 0 or more characters, and what are
> quelqu'ils. (either REGEXP '%' <=> ".*")
>           o '_' (underscore): replaces a single character.
>           o You do not handle the fact of backslashes these special
> characters
>
> My first code :
> _________________
>
> #!/usr/bin/php
> <?php
>
> function GetNextLine()
> {
>   $line = rtrim(fgets(STDIN));
>   if (feof(STDIN))
>     return (false);
>   return ($line);
>
> }
>
> $arg = $_SERVER['argv'][1];
> if ($arg== NULL)
> {
> echo "Usage: ./bdphp.php [-i inputfile] [-o outputfile] dbfile";
> echo "\n";
>
> }
>
> function FunWrite()
> {
>   $i=0;
>   while($a != "QUIT;")
>   {
>      echo "\n";
>      $a=GetNextLine();
>      $i++;
>      echo "syntax error";
>    }}
>
> FunWrite();
> ?>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=.


Reply via email to