classes.other/PSM.php
/*Will create a statement depending on the inputs.*/
Will create a statement depending on the inputs.
Will create a statement depending on the inputs .
public function cstatement($array, $build = false)
          {
            if (isset($array['columns'])) $array['cols'] = $array['columns'];
            $statement = 'SELECT';
            $binds     = [];
            if (isset( $array['cols'] )) $statement .= " {$array['cols']}";
            else $statement .= ' *';
            if (isset( $array['table'] )) $statement .= " FROM {$array['table']}";
            if (isset( $array['where'] ))
              {
                $where_clauses = explode(' = ', $array['where']);
                $statement .= " WHERE {$where_clauses[0]} = ?";
                array_push($binds, $where_clauses[1]);
              }
            if (isset( $array['order'] )) $statement .= " ORDER BY {$array['order'][0]} {$array['order'][1]}";
            if (isset( $array['limit'] )) $statement .= " LIMIT {$array['limit']}";
            if ($build)
              {
                $q = $this->cquery( $statement, $binds );
                return $q;
              }
            else
              {
                if (count($binds) == 0)
                  {
                    $this->tempstatement = $statement;
                    return $statement;
                  }
                else
                  {
                    $this->tempbinds     = $binds;
                    $this->tempstatement = $statement;
                    return [
                      'statement' => $statement,
                      'binds'     => $binds
                    ];
                  }
              }
          }
public function cstatement ( $ array , $ build = false ) { if ( isset ( $ array [ 'columns' ] ) ) $ array [ 'cols' ] = $ array [ 'columns' ] ; $ statement = 'SELECT' ; $ binds = [ ] ; if ( isset ( $ array [ 'cols' ] ) ) $ statement .= " { $ array [ 'cols' ] } " ; else $ statement .= ' *' ; if ( isset ( $ array [ 'table' ] ) ) $ statement .= "  FROM  { $ array [ 'table' ] } " ; if ( isset ( $ array [ 'where' ] ) ) { $ where_clauses = explode ( ' = ' , $ array [ 'where' ] ) ; $ statement .= "  WHERE  { $ where_clauses [ 0 ] }  = ? " ; array_push ( $ binds , $ where_clauses [ 1 ] ) ; } if ( isset ( $ array [ 'order' ] ) ) $ statement .= "  ORDER BY  { $ array [ 'order' ] [ 0 ] } { $ array [ 'order' ] [ 1 ] } " ; if ( isset ( $ array [ 'limit' ] ) ) $ statement .= "  LIMIT  { $ array [ 'limit' ] } " ; if ( $ build ) { $ q = $ this -> cquery ( $ statement , $ binds ) ; return $ q ; } else { if ( count ( $ binds ) == 0 ) { $ this -> tempstatement = $ statement ; return $ statement ; } else { $ this -> tempbinds = $ binds ; $ this -> tempstatement = $ statement ; return [ 'statement' => $ statement , 'binds' => $ binds ] ; } } }
Will create a statement depending on the inputs.
Will create a statement depending on the inputs .
// Reset definitions. // Creating the statement container as well as the binds contains. // COLUMNS. // TABLE. // WHERE. // ORDER. // LIMIT. // RETURN. // Manager for returning data. // Sets the temporary statement for later retrieval if needed. // Sets the temporary binds / statement for later retrieval if needed.