diff --git a/README.md b/README.md index 57c8a4f..a6c325a 100644 --- a/README.md +++ b/README.md @@ -150,8 +150,8 @@ Search is implemented with the "filter" parameter. You need to specify the colum - le: lower or equal (number is lower than or equal to value) - ge: greater or equal (number is higher than or equal to value) - gt: greater than (number is higher than value) - - in: in (number is in comma seperated list of values) - - ni: not in (number is not in comma seperated list of values) + - in: in (number is in comma separated list of values) + - ni: not in (number is not in comma separated list of values) - is: is null (field contains "NULL" value) - no: not null (field does not contain "NULL" value) @@ -186,7 +186,7 @@ Output: ### List + Column selection -By default all columns are selected. With the "columns" parameter you can select specific columns. Multiple columns should be comma seperated. An asterisk ("*") may be used as a wildcard to indicate "all columns": +By default all columns are selected. With the "columns" parameter you can select specific columns. Multiple columns should be comma separated. An asterisk ("*") may be used as a wildcard to indicate "all columns": ``` GET http://localhost/api.php/categories?columns=name diff --git a/extras/core.php b/extras/core.php index ba3f688..ad97305 100644 --- a/extras/core.php +++ b/extras/core.php @@ -39,7 +39,7 @@ switch ($method) { $sql = "delete `$table` where id=$key"; break; } -// excecute SQL statement +// execute SQL statement $result = mysqli_query($link,$sql); // die if SQL statement failed diff --git a/tests/blog_mysql.sql b/tests/blog_mysql.sql index b1cf252..5d20dce 100644 --- a/tests/blog_mysql.sql +++ b/tests/blog_mysql.sql @@ -14,7 +14,7 @@ CREATE TABLE `categories` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `categories` (`id`, `name`, `icon`) VALUES -(1, 'anouncement', NULL), +(1, 'announcement', NULL), (2, 'article', NULL); DROP TABLE IF EXISTS `comments`; diff --git a/tests/blog_postgresql.sql b/tests/blog_postgresql.sql index b3dc92b..3e24e61 100644 --- a/tests/blog_postgresql.sql +++ b/tests/blog_postgresql.sql @@ -97,7 +97,7 @@ CREATE TABLE users ( -- INSERT INTO "categories" ("name", "icon") VALUES -('anouncement', NULL), +('announcement', NULL), ('article', NULL); -- diff --git a/tests/blog_sqlite.sql b/tests/blog_sqlite.sql index 0642090..9d147bd 100644 --- a/tests/blog_sqlite.sql +++ b/tests/blog_sqlite.sql @@ -7,7 +7,7 @@ CREATE TABLE "categories" ( "icon" blob NULL ); -INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'anouncement', NULL); +INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'announcement', NULL); INSERT INTO "categories" ("id", "name", "icon") VALUES (2, 'article', NULL); DROP TABLE IF EXISTS "comments"; diff --git a/tests/blog_sqlserver.sql b/tests/blog_sqlserver.sql index c52c47e..2ad8303 100644 --- a/tests/blog_sqlserver.sql +++ b/tests/blog_sqlserver.sql @@ -141,7 +141,7 @@ CREATE TABLE [users]( GO SET IDENTITY_INSERT [categories] ON GO -INSERT [categories] ([id], [name], [icon]) VALUES (1, N'anouncement', NULL) +INSERT [categories] ([id], [name], [icon]) VALUES (1, N'announcement', NULL) GO INSERT [categories] ([id], [name], [icon]) VALUES (2, N'article', NULL) GO diff --git a/tests/tests.php b/tests/tests.php index 921b036..da17852 100644 --- a/tests/tests.php +++ b/tests/tests.php @@ -329,14 +329,14 @@ class PHP_CRUD_API_Test extends PHPUnit_Framework_TestCase { $test = new API($this); $test->get('/posts?include=categories,tags,comments&filter=id,eq,1'); - $test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[["1","1","1","blog started"]]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[["1","1","1"],["2","1","2"]]},"categories":{"relations":{"id":"posts.category_id"},"columns":["id","name","icon"],"records":[["1","anouncement",null]]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[["1","funny"],["2","important"]]},"comments":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","message"],"records":[["1","1","great"],["2","1","fantastic"]]}}'); + $test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[["1","1","1","blog started"]]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[["1","1","1"],["2","1","2"]]},"categories":{"relations":{"id":"posts.category_id"},"columns":["id","name","icon"],"records":[["1","announcement",null]]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[["1","funny"],["2","important"]]},"comments":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","message"],"records":[["1","1","great"],["2","1","fantastic"]]}}'); } public function testListExampleFromReadmeWithTransform() { $test = new API($this); $test->get('/posts?include=categories,tags,comments&filter=id,eq,1&transform=1'); - $test->expect('{"posts":[{"id":"1","post_tags":[{"id":"1","post_id":"1","tag_id":"1","tags":[{"id":"1","name":"funny"}]},{"id":"2","post_id":"1","tag_id":"2","tags":[{"id":"2","name":"important"}]}],"comments":[{"id":"1","post_id":"1","message":"great"},{"id":"2","post_id":"1","message":"fantastic"}],"user_id":"1","category_id":"1","categories":[{"id":"1","name":"anouncement","icon":null}],"content":"blog started"}]}'); + $test->expect('{"posts":[{"id":"1","post_tags":[{"id":"1","post_id":"1","tag_id":"1","tags":[{"id":"1","name":"funny"}]},{"id":"2","post_id":"1","tag_id":"2","tags":[{"id":"2","name":"important"}]}],"comments":[{"id":"1","post_id":"1","message":"great"},{"id":"2","post_id":"1","message":"fantastic"}],"user_id":"1","category_id":"1","categories":[{"id":"1","name":"announcement","icon":null}],"content":"blog started"}]}'); } public function testEditCategoryWithBinaryContent() @@ -487,7 +487,7 @@ class PHP_CRUD_API_Test extends PHPUnit_Framework_TestCase { $test = new API($this); $test->get('/categories?filter[]=icon,is,null&transform=1'); - $test->expect('{"categories":[{"id":"1","name":"anouncement","icon":null},{"id":"2","name":"alert();","icon":null}]}'); + $test->expect('{"categories":[{"id":"1","name":"announcement","icon":null},{"id":"2","name":"alert();","icon":null}]}'); } public function testFilterCategoryOnNotNullIcon() @@ -522,7 +522,7 @@ class PHP_CRUD_API_Test extends PHPUnit_Framework_TestCase { $test = new API($this); $test->get('/posts?include=categories&columns=categories.name&filter=id,eq,1&transform=1'); - $test->expect('{"posts":[{"category_id":"1","categories":[{"id":"1","name":"anouncement"}]}]}'); + $test->expect('{"posts":[{"category_id":"1","categories":[{"id":"1","name":"announcement"}]}]}'); } public function testColumnsOnWrongInclude()