* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPLinq * @package PHPLinq * @copyright Copyright (c) 2008 - 2009 PHPLinq (http://www.codeplex.com/PHPLinq) * @license http://www.gnu.org/licenses/lgpl.txt LGPL * @version 0.4.0, 2009-01-27 */ /** Error reporting */ error_reporting(E_ALL); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/' . PATH_SEPARATOR . './resources/'); /** PHPLinq_LinqToZendDb */ require_once 'PHPLinq/LinqToZendDb.php'; PHPLinq_LinqToZendDb::setQueryCallback('print'); // Output generated queries to console // Create data source require_once 'employees.db.inc.php'; $result = from('$employee')->in($employeeTable)->orderBy('$employee => $employee->Name')->select('new { "EmailAddress" => $employee->Email, "Domain" => substr($employee->Email, strpos($employee->Email, "@") + 1) }'); print_r($result);
/** * Set query callback (static for all PHPLinq_LinqToZendDb !) * * Function accepting a string to which query strings can be logged. * * @param mixed $value */ public static function setQueryCallback($value = null) { self::$_queryCallback = $value; }