CodeCanyon

Simple API class

  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 1 and 100 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 50 and 99 users
Eight7Teen says
Purchased

Ok, so I’m trying to setup the API to allow requests that filter the results by using multiple “WHERE” conditions… However, I keep getting this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND AND' at line 1

Here’s the API setup call:

  $api = new Api($db);

  $api->register('quotes')
    ->setTable('quotes')
    ->setOutput(array(
      'xml'
    ))
    ->setKey(true)
    ->setColumns(array(
      'id',
      'author',
      'text',
      'category',
      'citation',
      'adult_lang',
      'release_ver'
    ))
    ->setWhere(array(
      'category' => array(
        'route'     => 'category',
        'connect'   => 'AND'
      ),
      'author' => array(
        'route' => 'author',
        'connect' => 'AND'
      )
    ))
    ->setLimit(200);

    $api->render($_GET);

Any ideas?

6 months ago
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 1 and 100 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 50 and 99 users
Eight7Teen says
Purchased

Nevermind, I’ve solved it…

6 months ago
  • Has been a member for 2-3 years
  • Bought between 50 and 99 items
Gamerholic says
Purchased

What format is the read me file?

3 months ago
  • Has been a member for 0-1 years
  • Bought between 1 and 9 items
  • Mexico
Rigter says
Purchased

Nice class :D

1 month ago
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 1 and 100 dollars
  • Bought between 50 and 99 items
  • United States
  • Referred between 50 and 99 users
Eight7Teen says
Purchased

Just wanted to let you know that you have quite a few typos in the class itself. Most are in regards to the Error message strings, but some are in the actual code itself which may inhibit some functionality of the class from working properly… (haven’t fully tested to verify that claim tho)

Here’s an example of one such typo I found:
$this->_namespaces[$this->_current_namaspace]['table'] = $table;
Whereas the correct version would be:
$this->_namespaces[$this->_current_namespace]['table'] = $table;

I found about 10 or more examples of “_namaspace” being used rather than “_namespace”. Fixed them on my end, but you may want to release another version with them fixed for everyone else.

Thanks for a great class though!

15 days ago
  • Has been a member for 0-1 years
  • Bought between 10 and 49 items
tommyinnn says
Purchased

Hello, got this working but I wondered if someone could assist me with code—this is for a white page directory for the US, I have it working with the lastname but cannot get it to work with both This would be the code for SQL , which is un-related to this but it will give you a idea what I am trying to do

WHERE lastname = ’$lastname’ AND firstname LIKE ’%$firstname’

and this is for my API code

->setWhere(array(‘lastname’ => array(‘route’ => ‘lastname’))

how would I code this for first and last name?

11 days ago
by
by
by
by
by